开发者

Error on Latitude and Longitude - Google Maps API JS 3.0

开发者 https://www.devze.com 2023-04-02 00:27 出处:网络
After a while, Google Maps seems to change the property name (Qa or Pa) to Na or another name. var map;

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

var map;
function initial开发者_如何学Cize() {
  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?


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());
}
0

精彩评论

暂无评论...
验证码 换一张
取 消