I used this code to get latitude and longitude. I want to expand to multiple geo-code for multiple locations.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript">
var geocoder = new google.maps.Geocoder(); var address = "new york";
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert(latitude); } }); </script>
If I modify to, include two locations. Any ideas why this doesn't write to the webpage, any idea on how to store the latitude and longitude of multiple locations into an array.
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<script type="text/javascript" src="http://maps.google.com/maps/api/js? sensor=false"></script>
<script type="text/javascript">
var geocoder = new google.maps.Geocoder();
var address = [['New York City'],['Chicago, IL']];
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
document.write(latitude);
document.write(longitude);
}
});
</script>
</body>
</html>