I’ve got a list of points in my database, which I want to show neatly in a Google Maps Flash Map.
Thus, I …
- calculate the bounding box around these points
- calculate the center of this bounding box
- set the zoom level of the map in a way that the zoomed cutout contains all points
- set the center of the map
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //1. var bounds:LatLngBounds = new LatLngBounds(); for each(var mapObject in tripMessages){ var currentLatLon:LatLng = new LatLng(mapObject.latitude, mapObject.longitude); bounds.extend(currentLatLon); } //2. var center:LatLng = bounds.getCenter(); //3. map.setZoom(map.getBoundsZoomLevel(bounds)); //4. map.setCenter(center); |