Hi, How can I pick a random place from anywhere in the world (but not in sea obviously) using some Service like Yahoo Geo, YQL, Google maps or something like that?? Thanks!
A:
I'm no expert and I have not tried this myself but from what information I can find online this should at least get you part of the way there. You would also need to figure out how to try with a different random GLatLong point if the reverse geocoding did not return a suitable placemark.
See reference: http://code.google.com/apis/maps/documentation/services.html#ReverseGeocoding
Related stackoverflow question: http://stackoverflow.com/questions/990148/how-to-add-random-markers-to-a-map-but-avoiding-the-sea
Google search: google maps api random land location
Hope this helps, cheers.
Code:
var map;
var geocoder;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
geocoder = new GClientGeocoder();
var point = new GLatLng(-90 + 180 * Math.random(), -180 + 360 * Math.random());
geocoder.getLocations(point, checkPoint);
}
}
function checkPoint(response) {
if (!response || response.Status.code != 200) {
alert("Status Code:" + response.Status.code);
} else {
var place = response.Placemark[0];
var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
redj
2010-05-03 04:55:31
pcalessio
2010-05-03 18:15:28