我正在尝试使用谷歌的 api 距离矩阵从两个地理点检索米,但永远不会调用回调函数。也许是范围问题?
prove: function(){
var origin = new google.maps.LatLng(50.087, 40.087);
var destination= new google.maps.LatLng(38, 39);
function calculateDistances() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback); <--netbeans tell me callback is not declared
}
function callback(response, status) {
console.log("incallback"); <---never called
}
}