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() では実行できません。directionService.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 に答える