2013-02-22 15 views
11

Il marcatore non si presenta, ho letto i documenti ma non riesco a trovare il problema, qualcuno può aiutarmi?Indicatore di Google Maps che non mostra API v3

heres i JS:

function initialize() { 
     var mapOptions = { 
     center: new google.maps.LatLng(-8.064903, -34.896872), 
     zoom: 16, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
     }; 
     var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 

     var marker = new google.maps.Marker({ 
      position: location, 
      title:"Hello World!", 
      visible: true 
     }); 
     marker.setMap(map); 
    } 
+3

Che cos'è 'posizione'? – alestanis

risposta

22

mia ipotesi è che l'oggetto location non è definito. Prova a impostare la posizione dell'indicatore sullo stesso LatLng del centro della mappa e controlla se funziona:

function initialize() { 
    latLng = new google.maps.LatLng(-8.064903, -34.896872) 
    var mapOptions = { 
    center: latLng, 
    zoom: 16, 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 

    var marker = new google.maps.Marker({ 
     position: latLng, 
     title:"Hello World!", 
     visible: true 
    }); 
    marker.setMap(map); 
} 
+0

ho appena creato var location = new google.maps.LatLng (-8.064903, -34.896872); e ha funzionato! Grazie! –

+1

@RamonVasconcelos Ottimo! Non dimenticare di accettare la risposta se ha risolto il tuo problema e buona fortuna con GMaps! – alestanis

Problemi correlati