【发布时间】:2016-01-03 13:31:46
【问题描述】:
我正在尝试从给定 lat、lng 中获取 formatted_address,但我遇到错误“断言失败:InvalidValueError:在属性 latLng:不是 LatLng 或 LatLngLiteral:在属性 lat:不是数字” 我正在使用 GMap.js 下面是我的代码: 首先我得到用户的当前位置
GMaps.geolocate({
success: function (position) {
getSetFormattedAddressLatLng( {
H: position.coords.latitude,
L: position.coords.longitude
});
},
error: function (error) {
notificationService.error('Geolocation failed: ' + error.message);
},
not_supported: function () {
alert("Your browser does not support geolocation");
},
always: function () {
//alert("Done!");
}
});
调用getSetFormattedAddressLatLng()函数获取用户当前位置成功后,函数如下所示
function getSetFormattedAddressLatLng(latLng) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
latLng: latLng
}, function (responses) {
if (responses && responses.length > 0) {
//set the formatted_address on originOrDestination
} else {
debugger;
notificationService.error('Cannot determine address at this location.');
}
});
}
但是当我调用 geocoder.geocoder() 时,我收到错误消息“断言失败:InvalidValueError:在属性 latLng:不是 LatLng 或 LatLngLiteral:在属性 lat:不是数字”。 我做错了什么?
问候, 赤胆
【问题讨论】:
标签: google-maps google-maps-api-3