Coder Social home page Coder Social logo

Comments (8)

m1dst avatar m1dst commented on July 19, 2024 2

@answerquest I've added the code and done a brief test. Seems OK to me, give it a try and let me know if it doesn't do what you expected.

from leaflet.zoomhome.

answerquest avatar answerquest commented on July 19, 2024 1

Hi, this feature is very much needed. As an alternative to passing co-ordinates, how about passing bounds? Then I can pass in a layer's getBounds() whenever the layer has changes.

from leaflet.zoomhome.

m1dst avatar m1dst commented on July 19, 2024 1

I've added a pull request for this issue. #11

from leaflet.zoomhome.

answerquest avatar answerquest commented on July 19, 2024

@m1dst this is great! Request: can you add in a setHomeBounds method too? That would take as argument a LatLngBounds array, like from a layer.getBounds().

Possible method to use : getBoundsZoom http://leafletjs.com/reference-1.3.0.html#map-getboundszoom

from leaflet.zoomhome.

answerquest avatar answerquest commented on July 19, 2024

@m1dst a small correction is needed, once that is done it works well! I added this code to the demo page to test:

var markerLayer = new L.geoJson(null);
var marker1 = L.marker([0,0]).addTo(markerLayer);
var marker2 = L.marker([20,20]).addTo(markerLayer);
markerLayer.addTo(map);
zoomHome.setHomeBounds( markerLayer.getBounds() );

Oh, I had to change the included script from leaflet.zoomhome.min.js to leaflet.zoomhome.js ; minified version didn't have the setHomeBounds method added yet.

from leaflet.zoomhome.

m1dst avatar m1dst commented on July 19, 2024

@answerquest Fixed in a subsequent update. I had a variable called map which is why it worked for me. Stupid typo.

from leaflet.zoomhome.

m1dst avatar m1dst commented on July 19, 2024

Thanks for all your feedback. I have closed the original PR and moved the new code to a new branch targeting just this issue rather than pointing at my main branch. I raised a new PR #12 where I have also minified the file.

from leaflet.zoomhome.

torfsen avatar torfsen commented on July 19, 2024

This has been closed via #12. Thanks, @m1dst!

from leaflet.zoomhome.

Related Issues (10)

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.