var map; var idInfoBoxAberto; var infoBox = []; var markers = []; function initialize() { //var latlng = new google.maps.LatLng(-13.065490, -55.929617); //var latlng = new google.maps.LatLng(-13.065494, -55.929614); var latlng = new google.maps.LatLng(g_sessionLatitude, g_sessionLongitude); var options = { zoom: 17, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("mapa"), options); } initialize(); function abrirInfoBox(id, marker) { if (typeof(idInfoBoxAberto) == 'number' && typeof(infoBox[idInfoBoxAberto]) == 'object') { infoBox[idInfoBoxAberto].close(); } infoBox[id].open(map, marker); idInfoBoxAberto = id; } function carregarPontos() { $.getJSON('/js/pontos.json.php', function(pontos) { var latlngbounds = new google.maps.LatLngBounds(); $.each(pontos, function(index, ponto) { var marker = new google.maps.Marker({ position: new google.maps.LatLng(g_sessionLatitude, g_sessionLongitude), title: "Inexa Técnologia", icon: '/img/indicadormapainexa.png' }); var myOptions = { content: "

" + ponto.Descricao + "

", pixelOffset: new google.maps.Size(-150, 0) }; infoBox[ponto.Id] = new InfoBox(myOptions); infoBox[ponto.Id].marker = marker; infoBox[ponto.Id].listener = google.maps.event.addListener(marker, 'click', function (e) { abrirInfoBox(ponto.Id, marker); }); markers.push(marker); latlngbounds.extend(marker.position); }); var markerCluster = new MarkerClusterer(map, markers); map.fitBounds(latlngbounds); setTimeout(function(){ map.setZoom(17); }, 1000); }); } carregarPontos();