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

Add options as input argument to the getLeafletLayer() method #2125

Closed
oriolbx opened this issue May 25, 2018 · 3 comments
Closed

Add options as input argument to the getLeafletLayer() method #2125

oriolbx opened this issue May 25, 2018 · 3 comments

Comments

@oriolbx
Copy link
Contributor

oriolbx commented May 25, 2018

Context

According to the documentation, the methods getleafletLayer() , returns a leaflet layer that groups all the layers that have been added to this client, it returns a L.TileLayer layer that groups all the layers.

However, if you want to add or change the options of the layer, it is not possible using the methods of Leaflet and CARTO getLeafletLayer() method does not accepts input arguments to change the options of the Layer generated.

It would be nice to have this option in CARTO.js.

For example, at this moment we can add the option noWrap to the L.tileLayer of the basemap but not for CARTO layer. Therefore the result is the next one:

screen shot 2018-05-25 at 11 20 38

@Jesus89
Copy link
Member

Jesus89 commented May 25, 2018

Hi @oriolbx.

This is a really good point in order to enable better integration with native Leaflet Layers.

This is also easy to implement:

  • Add an options parameter to the getLeafletLayer() function
  • Merge these options with our defaults
  • Apply the merged options to the internal L.tileLayer instance

Thanks 👍

@rubenmoya
Copy link
Contributor

I've opened a PR to solve this, although your example won't work if you only use noWrap, you can read more about it here. Using this options works:

{
  noWrap: true,
  bounds: [
    [-90, -180],
    [90, 180]
  ]
}

rubenmoya added a commit that referenced this issue Jul 2, 2018
@rubenmoya
Copy link
Contributor

Fixed in @carto/[email protected]

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

No branches or pull requests

4 participants