0

我有关于我的自定义地图的方向。但是,我希望添加我在 Google 开发者网站上找到的下拉菜单,该下拉菜单允许选择“自行车”、“驾驶”、“公交”、“步行”等选项。


这是我调用函数的代码,我不知道它们在哪里:

var map;
var gdir;
var geocoder = null;
var addressMarker;

function initialize() {
  if (GBrowserIsCompatible()) {      
    map = new GMap2(document.getElementById("map_canvas"));
    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", handleErrors);

    setDirections(document.getElementById("fromAddress").value, document.getElementById("toAddress").value, "en_US");
  }
}

function setDirections(fromAddress, toAddress, locale) {
  gdir.load("from: " + fromAddress + " to: " + toAddress,
            { "locale": locale });
}

这是网址,我认为我需要将其放在我所拥有的某处。

--我想我可以先用一种模式来测试它,比如“WALKING”。然后在它起作用后添加下拉。

======================================

我在以下网址找到了这个网址: https ://developers.google.com/maps/documentation/javascript/examples/directions-travel-modes

==========================================

    function calcRoute() {
var selectedMode = document.getElementById('mode').value;
var request = {
  origin: haight,
  destination: oceanBeach,
  // Note that Javascript allows us to access the constant
  // using square brackets and a string value as its
  // "property."
  travelMode: google.maps.TravelMode[selectedMode]
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
  directionsDisplay.setDirections(response);
}
});
}

这是在上面的代码中,我想使用它 travelMode: google.maps.TravelMode["WALKING"]

4

1 回答 1

0

我想到了。我正在尝试将 v3 功能/语法添加到 v2。嗬!(拍了拍额头)

于 2013-06-21T17:49:33.807 回答