0

在我的对话框中无法路由地图方向

<script>

var directionsDisplay;
var directionsService = new google.maps.DirectionsService(); 


function calcRoute() {  
    var myLoc = MyLoc; // My location 
    var Dest = DesLoc; // Destination Location

    var request = {
        origin: myLoc,
        destination: Dest,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };   

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

function initialize() {      
    myLatLng = new google.maps.LatLng(lat, lng);
    var mapOptions = {
        center: myLatLng,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("maplarge_canvas"),
                    mapOptions);

    directionsDisplay = new google.maps.DirectionsRenderer({
        suppressMarkers: true
    });
    directionsDisplay.setMap(map);       
}

function success(position) {
    document.getElementById("hidMyLoc").value = position.coords.latitude + ',' + position.coords.longitude;
} 

$(function () {
   // google.maps.event.addDomListener(window, 'load', initialize);
    initialize();
});

在函数 calcroute() 中无法运行。方向Service.route(请求,功能(响应,状态)

在我的 html

<input type="button" id="btn_submit" value="Get Direction" onclick="calcRoute();" />
<div id="maplarge_canvas" style="width: 850px; height: 500px;"></div>

单击按钮调用 calRoute() 函数时

此函数无法通过directionService.route运行,firebug在js中看不到错误

PS。此代码在 Dialog Jquery UI 上运行

4

1 回答 1

0

我相信这来得很晚,但只是通过观察它和未来的观察

google.maps.DirectionsTravelMode.DRIVING

应该

google.maps.TravelMode.DRIVING
于 2014-03-25T17:06:37.343 回答