Código HTML:
Ver original<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript">
//VARIABLES
var lat = [-34.58609,- 25.40101,- 25.4157,- 25.40614,- 25.42922,- 25.4211,- 25.38474,- 25.3491];
var lon = [-58.414307,- 57.57554,- 57.55637,- 57.54233,- 57.54504,- 57.53866,- 57.54989,- 57.57423];
var puntos = [];
var Clat=0;
var Clon=0;
var j=0;
var i = 0;
var markers = [];
var iterator = 0;
var map;
var geocoder;
var iterator2 = 0;
var posiciones = [];
//PROMEDIO DE LAT Y LON PARA CENTRAR EL MAPA
for (j = 0; j < lat.length; j++) {
puntos[j] = new google.maps.LatLng(lat[j], lon[j]);
Clat = Clat + lat[j];
Clon = Clon + lon[j];
}
var latitud = Clat / j;
var longitud = Clon / j;
//CENTRO EL MAPA
var center = new google.maps.LatLng(latitud, longitud);
//CARGO EL MAPA
function initialize() {
var mapOptions = {
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: center
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
//TIRO LOS MARKERS
function drop() {
for (var i = 0; i < puntos.length; i++) {
numero = i + 1;
setTimeout(function() {
addMarker();
codeLatLng();
}, i * 1000);
}
}
//AGREGO MARKER
function addMarker() {
var titulo = "Punto:" + String(iterator);
markers.push(new google.maps.Marker({
position: puntos[iterator],
map: map,
title: titulo,
draggable: false,
animation: google.maps.Animation.DROP
}));
iterator++;
}
//GEOCODIFICO
function codeLatLng() {
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': puntos[iterator2] }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var reverse_geo = results[0]
var text = "";
text = text + reverse_geo.formatted_address;
posiciones[iterator2] = text;
}
}
});
iterator2++;
}
<body onload="initialize(),drop()">
<div id="map_canvas" style="width: 500px; height: 400px;"></div>
<script type="text/javascript"> for (var i = 0; i < lat.length; i++) {
var numero = i + 1;
document.write(numero + "<br>");
}
<script type="text/javascript"> for (var i = 0; i < lat.length; i++) {
document.write(lat[i] + "<br>");
}
<script type="text/javascript"> for (var i = 0; i < lon.length; i++) {
document.write(lon[i] + "<br>");
}
<script type="text/javascript"> for (var i = 0; i < lat.length; i++) {
document.write(posiciones[i] + "<br>");
}