-
Notifications
You must be signed in to change notification settings - Fork 889
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 other controls in v1 TODO #100
Conversation
Here is one solution I've been working on for the LayersControl. In your <Map bounds={this.state.bounds}>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
layerName='OpenStreetMap'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
layerName='OpenStreetMap2'
url='http://otile4.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png'
/>
<LayersControl baseLayers={['OpenStreetMap', 'OpenStreetMap2']}/>
</Map> The difference is that you pass I'm not sure we can look at all the layers synchronously, so in the |
Hey, thanks for the PR! I'll try to have a look at Leaflet's doc this week for these controls, see if there any specific cases to consider. |
Add other controls in v1 TODO
Thanks! |
Sorry to dig this up - I'm having issues with understanding how to use the layers control? It seems to "work" when I pass actual leaflet objects in as you would normally to Much appreciated - happy to submit a PR with updated Readme instructions and even an example once I get it working :-) |
What do you mean by default? The default options are Leaflet's ones, this library simply passes the props to the relevant Leaflet constructor. |
Hi,
What do you mean by default? The default options are Leaflet's ones, this library simply passes the props to the relevant Leaflet constructor.
OK right I see. I was wondering if it was possible to pass in a <TileLayer> through to LayersControl but it looks like as you say it's just a shim around the leaflet options. In the leaflet options for the L.control.layers you need to pass an object where the key is the title shown on the control and the value is a L.TileLayer class. I was hoping instead I could pass a <TileLayer> from here :-)
Thanks for the help
|
Hi - I'm having a similar issue - I have a |
@chriswiggins Could you give a code example of this?
I think I had a similar idea when I first wrote these wrappers (see my earlier comment), but I think it would involve writing some more logic into the guts of LayersControl to pull it off. |
@jonboiser I was thinking of something like this:
Come to think of it, that could actually be fairly straightforward if the LayersControl element "rendered" its children and then added to the layers control. I'll have a play today and get back to you all on whether or not this works! |
So I've given this a go and no immediate luck - mainly because the TileLayers are expecting a Any other ideas around how we could do this? |
So you would wrap the LayersControl-composed-with-TileLayers in a Map like this? I think this would be a nice way to work with Leaflet.
|
Filling out some of the missing controls in #87.
I've done some basic testing on Attribution and Scale. The Layers control gets placed on the map, but I'm not sure how to correctly pass a base layer reference from a, say,
TileLayer
component into the Layers control.