0
我使用谷歌地图显示2个地方之间的行车路线。该代码是这样的:地图中心在谷歌地图GEO编码
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林肯,大道,圣莫尼卡,加利福尼亚州)而不是经纬度。这是因为默认位置是动态的。我怎样才能做到这一点??任何想法???