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

mapId is not passed to setTiles method if no tile layer is set and there are several maps on the page #279

Closed
gabrielhase opened this issue Feb 9, 2014 · 1 comment

Comments

@gabrielhase
Copy link

This concerns the calling code of the leaflet directive inside of the link method around line 71. The code calls the setTiles method of the leafletData service. It does not pass the mapId though. So if you have two maps on the page and correctly access them with their respective mapId's it will nevertheless throw an error message if the maps do not define a tile layer in their attributes. I fixed this problem locally. Below the code change:

Before (no mapId passed to setTiles):

// If no layers nor tiles defined, set the default tileLayer
if (!isDefined(attrs.tiles) && (!isDefined(attrs.layers))) {
  var tileLayerObj = L.tileLayer(defaults.tileLayer, defaults.tileLayerOptions);
  tileLayerObj.addTo(map);
  leafletData.setTiles(tileLayerObj);
}

After (mapId passed):

// If no layers nor tiles defined, set the default tileLayer
if (!isDefined(attrs.tiles) && (!isDefined(attrs.layers))) {
  var tileLayerObj = L.tileLayer(defaults.tileLayer, defaults.tileLayerOptions);
  tileLayerObj.addTo(map);
  leafletData.setTiles(tileLayerObj, attrs.id);
}
@tombatossals
Copy link
Owner

You're totally right. Solved.

Thanks for sharing.

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

No branches or pull requests

2 participants