1

I want to change the values of Leaflet MiniMap object after it is already created.

e.g. miniMap.options.width:

var miniMap = new L.Control.MiniMap(
  tileLayer01, { centerFixed: new L.LatLng(50.0, 20.0) }
  ).addTo(map01);

console.log("miniMap.options.width: " + miniMap.options.width);
// prints 150 (the default value the minimap was initialized with)

miniMap.options.width = 80;

console.log("miniMap.options.width: " + miniMap.options.width);
// prints 80 (the newly set value)

However, that has no effect, the minimap is not rendered accordingly but stays unchanged.

How can I change MiniMap values after creation so that it affects the minimap?

0

The L.Control.MiniMap control obviously does not support dynamic change of width and height options, so you have to set control container style values. Since control can be minimized and maximazed again, you also have to set option values, since these are taken into account when maximizing control.

var miniMap = new L.Control.MiniMap(
  tileLayer01, {centerFixed: new L.LatLng(50.0, 20.0)}
).addTo(map01);

miniMap.options.width = 80;
miniMap.options.height = 80;

var miniMapContainer = miniMap.getContainer();
miniMapContainer.style.height = "80px";
miniMapContainer.style.width = "80px";

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.