jieter / Leaflet.Sync

Synchronized view of two maps.
http://jieter.github.io/Leaflet.Sync/examples/dual.html
BSD 3-Clause "New" or "Revised" License
235 stars 53 forks source link

How to manage same layer between 2 sync maps ? #28

Closed sylvain-m closed 8 years ago

sylvain-m commented 8 years ago

Hello,

Perhaps it's more a question than an issue, but i don't know where to ask question about this Leaflet plugin. I have to manage 2 sync map, in which some layers are the same. If i use the same var for each one, i have conflicts on the layer control button.

To make it work, i have to state 2 var from the same parameters :

        var mylayer1 = L.tileLayer('mylayerurl', {mylayeroptions});
        var mylayer2 = L.tileLayer('mylayerurl', {mylayeroptions});

I do not think it's the best choice (layers URL and option are pretty big).

I have test with this, but it do not work :

        var mylayer = L.tileLayer('mylayerurl', {mylayeroptions});
        var mylayer1 = mylayer;
        var mylayer2 = mylayer;

Does someone could tell me the right method ?

Thanks in advance !

Sylvain M.

jieter commented 8 years ago

Use leaflet-clonelayer for this: https://github.com/jieter/leaflet-clonelayer

sylvain-m commented 8 years ago

Thanks : its perfect for me ! :+1: