1

I have implemented a minimap and I'm trying to hang a type click event to change the base layer. Like google maps.

But it does not work. This is my code:

_onBaselayerChanger: function (e) {
  var currentBaselayer = [];
  this._map.eachLayer(function(layer) {
      if( layer instanceof L.TileLayer )
          currentBaselayer.push(layer);
  });
  this._map.removeLayer(currentBaselayer[0]);
  this._map.addLayer(this._layer);
}

Is there a plugin or something to help me?

1

There is not enough code in your post to get it testing (maybe you can create a simple fiddle?). However, in case you didn't run into those links before, here are examples that may be helpful for you to implement the action under your minimap click event:

http://leafletjs.com/examples/layers-control/

https://leaflet-extras.github.io/leaflet-providers/preview/

To find minimap plugin google the names: L.Control.Layers.Minimap.js or Norkart/Leaflet-MiniMap.

  • yep, L.Control.Layers.Minimap.js is the excellent base! Thx – carlo Mar 4 '17 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.