Norkart / Leaflet-MiniMap

A minimap control plugin for Leaflet
BSD 2-Clause "Simplified" License
395 stars 125 forks source link

Change of minimap layer #60

Closed Coroico closed 9 years ago

Coroico commented 10 years ago

as new feature, I added a changeLayer method to manage the change of the minimap layer when the main map layer change:

changeLayer: function (layer) {
    this._miniMap.removeLayer(this._layer);
    this._layer = layer;
    this._miniMap.addLayer(this._layer);
},
robpvn commented 10 years ago

This seems like it could be a useful feature! Could you please provide a pull request where you have implemented the change along with a demo page to show off how you would use it in practice?

:thumbsup:

Coroico commented 10 years ago

For the demo look at this page : http://bdvllrd.o2switch.net/eurovelo3/wpdev/tests/minimap-2.html Change the map layer to see how the minimap change.

I am a leaflet newbie so may be this is not the better implementation:

map.on('baselayerchange', function(e) {
    // if needed update minimap
    if (e.name != iLayer){
        minimap.changeLayer(baseminimap[e.name]);
    }
    iLayer = e.name;
});
hoge6b01 commented 9 years ago

Hello you two,

I've got a map with minimap code here: http://gis.stackexchange.com/questions/124996/minimap-in-leaflet/125111#125111

I've got some baselayers that I would like to see changing in Minimap as the baselayer changes. But first problem is that minimap doesn't show a map at all.

Any suggestions how to fix that problem? thanks a lot!

robpvn commented 9 years ago

@hoge6b01, I answered on the StackExchange post. Be a darling and accept the answer. :heavy_check_mark:

hoge6b01 commented 9 years ago

@robpvn Thank you so much. I'll accept the answer. What about the minimap showing the same baselayer as the real basemap?

hoge6b01 commented 9 years ago

I tried Coroico's code but I am sure I did something wrong. All I got was a blank miniMap. Do you have any suggestions? Thanks

robpvn commented 9 years ago

I don't have any suggestions when you don't give any details or show any code. Try making a JSFiddle with your code, remove everything that isn't related to your problem and showing us that. You might even fix the problem yourself while you do that work!

hoge6b01 commented 9 years ago

Sorry, you're right. I updated the JSFiddle with my last code I tried to use. Would be great if you find any suggestion. http://jsfiddle.net/y4z9e9os/5/

robpvn commented 9 years ago

Your main problem was that @Coroico's code isn't in the plugin yet, so it needed to be added, secondly that you were using the other code wrong. I forked the fiddle and fixed it for you: http://jsfiddle.net/hk9f5dq0/

Now that I've taken the time to look at this properly, I might go ahead and add the relevant code into the plugin to make this easier in the future.