Comments (3)
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.
from leaflet-minimap.
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 :)
from leaflet-minimap.
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.
from leaflet-minimap.
Related Issues (20)
- Fit the zoom to map size on minimap HOT 1
- Conflict with Leaflet.contextmenu.js and L.VisualClick.js? HOT 1
- Way to display only MiniMap HOT 1
- way to move shadow rectangle HOT 1
- Minimap is empty HOT 1
- Static image on minimap but allow dragging for aimingRect and shadowRect
- .leaflet-touch style
- help
- Show minimap with image overlay HOT 1
- "worldCopyJump":true HOT 2
- autoToggleDisplay: true
- change the layers with a layergroup HOT 1
- How do I attach a click handler to the minimap?
- Position relative to a sidebar
- Request: Allow dragging aimingRect or shadowRect when both centerFixed and zoomLevelFixed are specified
- Bug: Mousewheel zooms minimap despite both centerFixed and zoomLevelFixed being specified HOT 1
- Ist this maintained anymore?
- requestAnimationFrame Forced reflow
- scroll mousewheel firefox
- Docs for React + TS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet-minimap.