You can also use: map. setView(new L. LatLng(40.737, -73.923), 8);
Used to load and display tile layers on the map, implements ILayer interface.
The Clusterer can handle 10,000 or even 50,000 markers (in chrome).
When you instantiate your Leaflet map, you just need to pass in a maxBounds option among your map options. When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method.
You can use L.LatLngBounds in order to create an area to zoom to.
First, create a bounds and pass it an array of L.LatLngs:
var bounds = new L.LatLngBounds(arrayOfLatLngs);
This will create a bounds that will encapsulate every point that is contained in the array. Once you have the bounds, you can fit the bounds of the map to match your created bound:
map.fitBounds(bounds);
This will zoom the map in as far as it can go, while still containing every point in your array.
Alternatively, you can also call the fitBounds
method by simply calling it and passing in an array of L.LatLng
objects. For example:
map.fitBounds([[1,1],[2,2],[3,3]]);
This would function exactly the same, without the need to create a specific L.LatLngBounds
object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With