Following the example, you can see the plunker http://plnkr.co/edit/lJHyP3dhT3v8aHVdt3D3?p=preview
No matter what scaling value is provided when initializing the map, I want to automatically scale the map so that all the markers are inside the view. Here is my code
var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors, Points © 2012 LINZ' }), latlng = L.latLng(-37.82, 175.24); var map = L.map('map', {center: latlng, zoom: 10, layers: [tiles]}); var markers = L.markerClusterGroup(); for (var i = 0; i < addressPoints.length; i++) { var a = addressPoints[i]; var title = a[2]; var marker = L.marker(new L.LatLng(a[0], a[1]), { title: title }); marker.bindPopup(title); markers.addLayer(marker); } map.addLayer(markers); var group = new L.featureGroup(markers); map.fitBounds(group.getBounds());
leaflet markerclusterer
coure2011
source share