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?

1 Answer 1

1

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 and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.