Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make max-width of attribution control configurable #849

Merged
merged 5 commits into from
Sep 28, 2016

Conversation

jgravois
Copy link
Contributor

@jgravois jgravois commented Sep 20, 2016

in the majority of applications it makes sense to leverage as much horizontal space as possible to display attribution, primarily because of small form factor devices, but 55px is a little safer default because it accommodates a bottom oriented zoom control automatically.

since other possibly bottom aligned controls like L.Control.Scale and L.Controls.Layers don't have a static predictable width our best bet is to just expose a mechanism to let developers indicate just how much space should be reserved.

i _think_ its kosher to just tack on a new L.Map control constructor option and introspect for it ourselves later. if so, we'll need to find a new location in our own API reference to document it.

in the majority of applications it makes sense to leverage as much horizontal space as possible to display attribution, primarily because of small form factor devices, but 55px is a little safer default because it accomodates a bottom oriented zoom control automatically.

since other possibly bottom aligned controls like L.Control.Scale and L.Controls.Layers don't have a static predictable width our best bet is to just expose a mechanism to let developers indicate just how much space should be reserved.
@jgravois
Copy link
Contributor Author

jgravois commented Sep 26, 2016

@tomwayson reminded me that a generic L.esri.Options object would be a more appropriate place to stash a configurable setting than asking folks to start supplying custom constructor options to other API's objects.

the snippet below is an example of how a developer could customize the amount of space reserved for other controls.

// number of pixels to crop attribution width
L.esri.options.attributionWidthOffset = 200;
var map = L.map('map').setView([37.79, -122.45], 13);

technically, the proposed implementation could lead to unexpected behavior if a developer tried to pass unique values to different resizable maps as they were created (because the value will be different when map.on('resize'... is triggered later).

to be honest, i'm perfectly fine with that.

edit:
the code snippet has been updated now that tom's suggestion has been incorporated.

@jgravois jgravois merged commit 3cf3b88 into Esri:master Sep 28, 2016
@tomwayson
Copy link
Member

A little late on this, but LGTM! Only change I would have suggested is naming it L.esri.options w/ lower case "o" just cause it's not an object you can new up, but I ain't mad atcha.

@jgravois jgravois deleted the configurable-attribution-width branch September 28, 2016 17:34
@jgravois
Copy link
Contributor Author

agreed. i'll push up soon.

jgravois added a commit to jgravois/esri-leaflet that referenced this pull request Apr 23, 2022
* make max-width of attribution control configurable

in the majority of applications it makes sense to leverage as much horizontal space as possible to display attribution, primarily because of small form factor devices, but 55px is a little safer default because it accomodates a bottom oriented zoom control automatically.

since other possibly bottom aligned controls like L.Control.Scale and L.Controls.Layers don't have a static predictable width our best bet is to just expose a mechanism to let developers indicate just how much space should be reserved.

* better to store the new option in our own namespace

* linting

* better linting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants