如何从Google Map API的参数变量中获取城市名称

时间:2013-02-21 10:17:51

标签: google-maps

我正在使用此功能:getDirection(glat,glon,acity)使用此功能,我必须画一条从城市到格拉特和[经度和纬度]位置的路线。我完成了一切,但我不知道如何设置变量acity作为原点。

var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var default_latitude=22.5936840;//12.9715987;
var default_longitude=78.962880;//77.5945627;
var myOptions = 
{
    center: new google.maps.LatLng(default_latitude,default_longitude),
    zoom: 4,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("mapp"),myOptions);


var latlng=new google.maps.LatLng(glat,glon);

$('#mapDiv1').modal({closeClass: "mapCloseImg1"});

directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("panel"));

var request = {
  origin: [WANT TO PUT ACITY AS ORIGIN BUT DONT KNOW HOW]
  destination:latlng,
  travelMode: google.maps.DirectionsTravelMode.DRIVING
};

directionsService.route(request, function(response, status) {
  if (status == google.maps.DirectionsStatus.OK) {
    directionsDisplay.setDirections(response);
  }
}); 
}

0 个答案:

没有答案