我正在使用谷歌地图显示2个地方之间的行车路线。代码是这样的:
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
$(document).ready(function(){
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(34.044756,-118.546677);
var myOptions = {
zoom:14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
directionsDisplay.setMap(map);
});
function calcRoute() {
if(document.getElementById("end_point").value != ""){
var directionsService = new google.maps.DirectionsService();
var start = document.getElementById("start_point").value;
var end = document.getElementById("end_point").value;
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
}
现在,正如您所看到的默认位置,它只需要纬度和经度(点)。我想使用地址(如-910 Lincoln,Blvd,Santa Monica,CA)而不是lat-long。这是因为默认位置是动态的。我怎样才能做到这一点??任何的想法???
答案 0 :(得分:0)