【问题标题】:Google Map API V3 directionsService.route not work in mvc 4Google Map API V3 DirectionsService.route 在 mvc 4 中不起作用
【发布时间】:2013-07-18 06:59:23
【问题描述】:

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

<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(request, function (response, status)

在我的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 上运行

【问题讨论】:

    标签: jquery-ui google-maps asp.net-mvc-4 google-maps-api-3 dialog


    【解决方案1】:

    我相信这来得太晚了,但只是通过查看它和将来查看

    google.maps.DirectionsTravelMode.DRIVING
    

    应该是

    google.maps.TravelMode.DRIVING
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 2014-09-07
      • 2015-12-12
      • 1970-01-01
      • 2014-10-30
      相关资源
      最近更新 更多