Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

soulindo

Google maps APi nao funciona

Recommended Posts

Boas

Tenho um pequeno problema com a api do google nao sei porque e que deixou de funcionar ainda ontem estava a dar bem e nao lhe mexi no codigo .

Se alguem me poder ajudar a detectar qual e o problema agradecia .

Eu mando lhe os pontos atravez de uma funcao de php que retorna um array de pontos para o javascript.

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
	<script>
function initialize() {
//variáveis
var i, array_lat,array_long, string_arraylat,string_arraylong,string_conteudo,array_cont;
//recebe a string com elementos separados, vindos do PHP
string_arraylat = "<?php echo $string_arraylat;?>";
string_arraylong = "<?php echo $string_arraylong;?>";
string_conteudo = "<?php echo $string_cont;?>";
//transforma esta string em um array próprio do Javascript
array_lat = string_arraylat.split("|");
array_long = string_arraylong.split("|");
array_cont =string_conteudo.split("|");
   if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);
var mapOptions = {
	//aproximidade do mapa
	zoom: 10,
	center: pos,
  }
  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  var image = 'css/images/imagem.png';
// Criar Pontos
//for (e in array_lat)
marker = new Array();
markercont = new Array();
for (e=0; e < array_lat.length; e++)
{
    //var myLatlng = new google.maps.LatLng(array_lat[e],array_long[e]);
    debugger;

    marker[e] = new google.maps.Marker({
	  position: new google.maps.LatLng(array_lat[e],array_long[e]),
	  map: map,
	  title: array_cont[e],
	  icon: image
  });
  marker[e].mycontent = array_cont[e];

  var infowindow = new google.maps.InfoWindow()/*, marker*/;

  markercont[e] = array_cont[e];
/* google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
        debugger;
        infowindow.setContent(thismarkercont);
        infowindow.open(map, marker);
    }
})(marker)); */

google.maps.event.addListener(marker[e], 'click',  function() {
        debugger;
        infowindow.setContent(this.mycontent);
        infowindow.open(map, this);
    });
}
}, function() {
      handleNoGeolocation(true);
    });
  } else {
    // Browser doesn't support Geolocation
    handleNoGeolocation(false);
  }
}


google.maps.event.addDomListener(window, 'load', initialize);

	</script>

Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.