我已使用Google Map API自动完成我的项目。有时地址给出错误的纬度和经度。
21 King Street West,Toronto,ON,Canada
我第一次得到:
40.7917804,-74.14482129999999 - wrong (USA Address)
我第二次得到:
43.64877740000001,-79.37871480000001
这是我的代码:
var address = new google.maps.places.Autocomplete((document.getElementById(id)), {
types: ['geocode'],
componentRestrictions: {
country: 'ca'
}
});
address.addListener('place_changed', function() {
var place = address.getPlace();
$j('#' + txtboxid).attr({
'data-lat': place.geometry.location.lat(),
'data-lon': place.geometry.location.lng()
});
});