I am trying to add an array of randomly placed markers to a Google Map in Flash with the API V3 and AS3.
I can create the markers no problem, but I’m having a bit of trouble putting them into an array and then clearing them afterwards as I need to provide this functionality.
I saw another post where people were talking about the lack of map.clearOverlays(); in V3? and I need a bit of help incorporated my code .
var markers:Array = new Array();
function addmarkers()
{
// Add 10 markers to the map at random locations
var bounds:LatLngBounds = map.getLatLngBounds();
var southWest:LatLng = bounds.getSouthWest();
var northEast:LatLng = bounds.getNorthEast();
var lngSpan:Number = northEast.lng() - southWest.lng();
var latSpan:Number = northEast.lat() - southWest.lat();
for (var i:int = 0; i < 10; i++)
{
var newLat:Number = southWest.lat() + (latSpan * Math.random());
var newLng:Number = southWest.lng() + (lngSpan * Math.random());
var latlng:LatLng = new LatLng(newLat,newLng);
map.addOverlay(new Marker(latlng));
markers.push();
}
}
I’ve got a button that calls this but then I also want a button that
my working code with yours incorporated, thanks.