Closed dylanparry closed 10 years ago
Indeed that should be possible, if I've understood you intent correctly. See the README file and the examples for instructions and hints on how to do it.
Hi,
I’ve had a look at the README, but I’m not sure that it covers what I’m looking for. What I want to do is say have a map that has resolutions defined as say:
[61.736077773629106, 44.09719840973508, 26.458319045841048]
and then have my mini map set up to use a different set of resolutions, say:
[70.55551745557612, 61.736077773629106, 52.916638091682096, 44.09719840973508, 35.27775872778806, 26.458319045841048]
So the mini map zoom levels wouldn’t be a subset of the main map’s levels as there are levels either side of the min/max but also levels inbetween existing ones (does that make sense?). Because of that it’s not as simple as setting the min/max zooms for the layer used on the mini map.
I’m guessing it’s probably not possible to do what I’m trying as the mini map is presumably displaying a copy of the main map within it (albeit at a different scale)? Is it possible to alter the CRS of the map used in the mini map without affecting the main map?
Looking at the code, as it is now, I don’t see an option to do this, but it seems fairly easy to add a "crs" property that can be overridden by changing the options to:
options: {
...
crs: null
},
and:
this._miniMap = new L.Map(this._container,
{
...
crs: this.options.crs || map.options.crs
});
Which does allow me to pass in a CRS with different zoom levels, but then the mini map stays zoomed all the way out as it presumably doesn’t know what zoom level to pick because it’s no longer in sync with the main map!
I think what I’d need to do is change the function that decides on the zoom level so that it instead zooms to fit the entire main map area on the mini map, then zooms out a couple of levels.
I’m guessing this is all too much of an edge case for it to be worth doing though :)
Seems I just needed to change _decideZoom function from:
if (fromMaintoMini) {
return this._mainMap.getZoom() + this.options.zoomLevelOffset;
to:
if (fromMaintoMini) {
if (this.options.crs) {
return this._miniMap.getBoundsZoom(this._mainMap.getBounds()) + this.options.zoomLevelOffset;
}
else {
return this._mainMap.getZoom() + this.options.zoomLevelOffset;
}
}
Which makes it work exactly how I want, and doesn’t break the behaviour when not using a custom CRS.
Is it possible to tell the mini map to use a different set of resolutions to that of the main map? I’d like to be able to get the mini map to zoom out further than the main map even when you’re zoomed out at the minimum level. That way I could still show a rectangle on the mini map.
Can that be done already, or is it something that isn’t really possible?