【发布时间】:2015-02-15 08:10:20
【问题描述】:
我有以下数据。 1.来源名称。 2.目的地名称。 我需要在从源到目的地的路径上找到经纬度对。是否有任何 google Api 可用?我提到了这个问题Finding intermediate Lattitude Longitude between two given points,但无法理解整个事情。任何人都可以有更简单的答案吗?
编辑 这是我尝试过的
//store lat and long
var sd_array=[];
$('#processbtn').click(function(e){
//get source and destination name
var source=$('#source').val();
var destination=$('#destination').val();
if(source==''||destination==''){
alert("all fields required");
}else{
//decode lat-long from address
getLatitudeAndLongitude(source);
getLatitudeAndLongitude(destination);
}
});
function getLatitudeAndLongitude(address){
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
//store to array
sd_array.push(latitude);
sd_array.push(longitude);
}
});
}
function getInterMediateLatLong(sd_array){
//get intermediate locations
/*sd_array[0] source lat
sd_array[1] source long
sd_array[2] destination lat
sd_array[3] destination long*/
}
我需要帮助来获得中间位置。
【问题讨论】:
-
需要 3 到 5 对我也是谷歌地图 API 的新手
标签: javascript google-maps cordova