在我的对话框中无法路由地图方向
<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()中无法运行。 directionsService.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上运行
答案 0 :(得分:0)
我相信这已经很晚了,只是通过观察和未来观看
google.maps.DirectionsTravelMode.DRIVING
应该是
google.maps.TravelMode.DRIVING