The Google Ajax API playground (http://code.google.com/apis/ajax/playground/?exp=maps#map_markers) provides a nice exemple to add random markers to any map:
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 9);
// Add 10 markers to the map at random locations
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(point));
}
}
}
BUT if your LatLng are next to the sea (or if you use another Zoomlevel than the exemple provided), How do you make sure your marker will avoid being placed on the sea ? Is there a flag that I can use to test if the potential LatLng of the random point is in the sea or on land ???
Txs in advance.
Hubert