由于大多数人在使用谷歌地图时遇到错误,例如“未捕获的类型错误:无法读取未定义的属性SOMETHING
”,
同样我也得到错误,但我的错误SOMETHING是text
,
完整错误消息如下:
Uncaught TypeError: Cannot read property 'text' of undefined
callback
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
d
(anonymous function)
我甚至使用了Google的Snippet https://developers.google.com/maps/documentation/javascript/examples/distance-matrix
刚刚修改过的地点,即
var origin1 = new google.maps.LatLng(40.728156999999996, -74.077642);
var destinationA = new google.maps.LatLng(18.470410048659726, 73.83044242858887);
我认为这不重要,因为当我将这些地点改为
时var origin1 = new google.maps.LatLng(19.14322218193555, 73.135986328125);
var destinationA = new google.maps.LatLng(18.470410048659726, 73.83044242858887);
然后它完全正常,
calculateDistances方法如下:
function calculateDistances() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin1],
destinations: [destinationA],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
请帮助。