ダイアログでマップの方向をルーティングできません
<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で実行されます