【发布时间】: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