Code Monkey home page Code Monkey logo

Comments (3)

robpvn avatar robpvn commented on September 28, 2024

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.

dylanparry avatar dylanparry commented on September 28, 2024

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.

dylanparry avatar dylanparry commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.