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

insert copyright info into leaflet attribution control for all layers automatically #842

Merged
merged 1 commit into from
Sep 9, 2016

Conversation

jgravois
Copy link
Contributor

@jgravois jgravois commented Sep 7, 2016

closes #837, #840

  • interrogate dynamicMapLayer, imageMapLayer, and featureLayer for copyright text in service and add it to the control automatically (unless custom attribution is supplied)
  • trim attribution to slightly less than the width of the map (and update when the map is resized) using an ellipsis to denote overflow
  • make the attribution expandable (and collapsible) when the user hovers over the control.

this includes commits from #841. i'm planning on a rebase/squash after that one lands.

@jgravois jgravois force-pushed the auto-copyright-layers branch 2 times, most recently from 97e2bad to bef1841 Compare September 9, 2016 18:57
wip

trim all attribution and make control expandable

remove import

better hover than click

give attribution hover a timeout

cleanup

no
@jgravois jgravois merged commit 2cf1b3b into Esri:master Sep 9, 2016
@blq
Copy link

blq commented Sep 20, 2016

It seems the attribution width calculation doesn't correctly take other map controls into account. I use the scale-control for example and it now ends up partially below the attribution text.

@jgravois
Copy link
Contributor Author

jgravois commented Sep 20, 2016

@blq thanks for bringing this to my attention. i was under the (mistaken) impression that other bottom oriented controls would automatically be positioned above the attribution.

i've proposed #849 to resolve the problem. in the meantime, you could inject something like this in your own code.

var attribution = document.getElementsByClassName('esri-truncated-attribution')[0]
// make sure the attribution is trimmed to reserve 150px for other controls
attribution.style.maxWidth = (map.getSize().x - 150) + 'px';

you could even execute the code above each time the map is resized if you'd like to retain the dynamic trimming the API provides.

@blq
Copy link

blq commented Sep 22, 2016

Ok, thanks, I'll give it a try!

@jgravois jgravois deleted the auto-copyright-layers branch October 18, 2016 23:24
@blq
Copy link

blq commented Oct 20, 2016

I tried the new 2.0.4 and I think the attributionWidthOffset margin of 55px is still a bit too low for the scale-control (if in lower left). I'd say it has to be doubled, i.e more close to your example nr above in this thread! Or use calculations that take controls into account explicitly.

@jgravois
Copy link
Contributor Author

i wasn't attempting to accomodate a scale control in the lower left with the new default value, but rather only the zoom control placed in the same position. if you need more room, its up to you to use the newly exposed configuration option.

L.esri.options.attributionWidthOffset = 150;

this will be explicitly documented soon: Esri/esri-leaflet-doc#105

jgravois added a commit to jgravois/esri-leaflet that referenced this pull request Apr 23, 2022
insert copyright info into leaflet attribution control for all layers automatically
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.

make sure esri leaflet fetches/displays service attribution automatically
2 participants