【问题标题】:Map Center in google map GEO Coding谷歌地图地理编码中的地图中心
【发布时间】:2010-09-23 09:56:23
【问题描述】:

我正在使用谷歌地图来显示两个地方之间的行车路线。代码是这样的:

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。这是因为默认位置是动态的。我怎样才能做到这一点??任何想法???

【问题讨论】:

    标签: php jquery google-maps google-maps-api-3


    【解决方案1】:
    猜你喜欢
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 2011-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多