(function($) { var PUNTOS = [], cargarpuntos = function () { $.ajax({ url: "mapa/index.php?json=1&nocache=" +new Date().getTime(), failure: function (x) { // setTimeout( function () { cargarpuntos(); }, 210 * 3000); }, success: function(data){ $.each(data, function (i, movil) { if (!PUNTOS[movil.name]) { PUNTOS[movil.name] = movil; pos = [movil.lat, movil.lng]; $('#MAPA').gmap3({ action:'addMarker', title: movil.name, name: movil.name, lat: movil.lat, lng: movil.lng, data: movil.data, options: { icon: new google.maps.MarkerImage('mapa/index.php?icono=' + movil.heading + '&color=' + movil.color ,new google.maps.Size(32, 32) ,new google.maps.Point(0,0) ,new google.maps.Point(8, 8) ), draggable: false, animation: google.maps.Animation.DROP }, events:{ click: function(marker, event, data){ var map = $(this).gmap3('get'), infowindow = $(this).gmap3({action:'get', name:'infowindow'}); if (infowindow){ infowindow.open(map, marker); infowindow.setContent(marker.contenido); } else { $(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data}}); } } }, callback: function (m) { m.contenido = movil.data; PUNTOS[movil.name].marker = m; } } , { action:'addOverlay', content: '