cloudmade

How to get the bounds of a group of markers in Cloudmade Leaflet map


I have created a mobile map with Cloudmade Leaflet and have it so a number of markers are generated to coincide with LatLong values in a database. However, I can't figure out how to set the initial Map view to set the zoom and centre the map on the group of markers. I presume I need to use setBounds but for this I need to know what the NorthEast and SouthWest coordinates are.

Do I need to go through the whole array of marker coordinates to find the North-most, East-most, South-most and West-mode values or is there an easier way?


Solution

  • You can use the fitBounds() method. Leaflets reference