Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on Latitude and Longitude - Google Maps API JS 3.0

After a while, Google Maps seems to change the property name (Qa or Pa) to Na or another name.

var map;
function initialize() {
  var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
  var myOptions = {
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  google.maps.event.addListener(map, 'click', function(event) {
    AlertPos(event.latLng);
  });
}

function AlertPos (location) {

    // try to show the latitude and longitude
    document.getElementById('lat').value = location.Qa; 
    document.getElementById('long').value = location.Pa; 
    alert(location.Qa)
    alert(location.Pa)
}

This affects my application. Can any body help?

like image 470
fmlvaz Avatar asked Sep 01 '11 16:09

fmlvaz


People also ask

What causes Google Maps JavaScript API v3 to not work properly?

API Key works properly: "This site overrides Array. from() with an implementation that doesn't support iterables, which could cause Google Maps JavaScript API v3 to not work correctly."


1 Answers

Use lat() and lng():

function AlertPos (location) {        
    // try to show the latitude and longitude
    document.getElementById('lat').value = location.lat(); 
    document.getElementById('long').value = location.lng(); 
    alert(location.lat()); 
    alert(location.lng());
}
like image 54
Jiri Kriz Avatar answered Sep 23 '22 23:09

Jiri Kriz