Comments (8)
@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.
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.
I've added a pull request for this issue. #11
from leaflet.zoomhome.
@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.
@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.
@answerquest Fixed in a subsequent update. I had a variable called map which is why it worked for me. Stupid typo.
from leaflet.zoomhome.
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.
This has been closed via #12. Thanks, @m1dst!
from leaflet.zoomhome.
Related Issues (10)
- Incompatibility with GoogleMutant plugin HOT 3
- Pass zoom/pan options
- homeZoom function HOT 1
- Fix package.json with name, version, description
- Zoom home offset if sidebar is open
- Please consider changing your licence to e.g. MIT HOT 1
- Execute custom function on button click?
- Control doesn't handle browser resize if bounds are set
- `title="Home"` may be misinterpreted by blind users
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.zoomhome.