2013-06-01 5 views
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 }); 
} 

여기에 URL과 제가 생각 것은 내가 무엇을 어딘가에 넣어 필요하다 나는 가지고있다.

- 나는 그림을 "걸어가는 것"과 같은 단 하나의 모드로 테스트 할 수 있습니다. 그런 다음 풀다운을 추가합니다.

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

URL 나는에서 이걸 발견 : 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를 사용하려면 : [ "WALKING"] google.maps.TravelMode

답변

0

나는 그것을 알아 냈다. v2에 v3 기능/구문을 추가하려고합니다. 도! (이마를 때 리다)