Google マップ v2 を v3 にアップグレードする際に問題が発生しました。
次のコードは v2 です。
function routing(target, width, lenght, name, zip, city, street) {
if (GBrowserIsCompatible()) {
if (counter > 0) {directions.clear()};
counter++;
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
directionsPanel = document.getElementById("route");
directions = new GDirections(map, directionsPanel);
var startpoint = name+', '+zip+' '+city+', '+street
if (target == 'messe') {
directions.load("from: "+startpoint+"@"+width+","+lenght+" to: Messe, 50679 #T_koeln#, Deutz-Mülheimer Straße 40@50.9473327,6.98312820000001");
};
if (target == 'airport') {
directions.load("from: "+startpoint+"@"+width+","+lenght+" to: Flughafen Koeln, 50679 #T_koeln#, Kennedystraße@50.8782914,7.122399800000039");
};
}
}
ここにv3コードがあります:
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
function routing(target, width, lenght, name, zip, city, street) {
if (counter > 0) {directionsDisplay.setMap(null)};
counter++;
var mapOptions = {
zoom: #zoomfaktor_detail#,
center: new google.maps.LatLng(width, length),
overviewMapControl: true,
overviewMapControlOptions:{opened:true},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("route"));
var startpoint = name+', '+zip+' '+city+', '+street
if (target == 'messe') {
end = 'Messe, 50679 #T_koeln#, Deutz-Mülheimer Straße 40@50.9473327,6.98312820000001';
start = startpoint+"@"+width+","+lenght;
request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
}
if (target == 'airport') {
end = 'Flughafen Koeln, 50679 #T_koeln#, Kennedystraße@50.8782914,7.122399800000039';
start = startpoint+"@"+width+","+lenght;
request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
}
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
なぜ機能しないのですか?誰かがアイデアを持っていますか?