私はあなたが歩くことができるいくつかのルートを示すサイトに取り組んでいます. http://yi.graafhuyncollege.nl/rsn.php 開始位置に「Wevestraat 10, Geleen」と入力して、1 つまたは複数のウェイポイントと終了位置を選択します。ルートの一部、特に最初のウェイポイントまでしか表示されません。
この問題の原因はわかりません。関数 ShowStep または AttachInstruction に問題がある可能性があります。
Javascript 部分:
var map;
var directionsDisplay;
var directionsService;
var stepDisplay;
var markerArray = [];
function initialize() {
// Instantiate a directions service.
directionsService = new google.maps.DirectionsService();
// Create a map and center it on Manhattan.
var geleen = new google.maps.LatLng(50.955561,5.831895);
var myOptions = {
zoom: 13,
mapTypeId: google.maps.MapTypeId.HYBRID,
center: geleen,
panControl: false,
zoomControl: true,
mapTypeControl: true,
scaleControl: true,
streetViewControl: false,
overviewMapControl: true,
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
// Create a renderer for directions and bind it to the map.
var rendererOptions = {
map: map
}
directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions)
// Instantiate an info window to hold step text.
stepDisplay = new google.maps.InfoWindow();
}
function calcRoute() {
// First, clear out any existing markerArray
// from previous calculations.
for (i = 0; i < markerArray.length; i++) {
markerArray[i].setMap(null);
}
// Retrieve the start and end locations and create
// a DirectionsRequest using WALKING directions.
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
var waypts = [];
var checkboxArray = document.getElementById("waypoints");
for (var i = 0; i < checkboxArray.length; i++) {
if (checkboxArray.options[i].selected == true) {
waypts.push({
location:checkboxArray[i].value,
stopover:true});
}
}
var request = {
origin: start,
destination: end,
waypoints: waypts,
travelMode: google.maps.TravelMode.WALKING
};
// Route the directions and pass the response to a
// function to create markers for each step.
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var warnings = document.getElementById("warnings_panel");
warnings.innerHTML += "" + response.routes[0].warnings + "";
directionsDisplay.setDirections(response);
showSteps(response);
}
});
}
function showSteps(directionResult) {
// For each step, place a marker, and add the text to the marker's
// info window. Also attach the marker to an array so we
// can keep track of it and remove it when calculating new
// routes.
var myRoute = directionResult.routes[0].legs[0];
for (var i = 0; i < myRoute.steps.length; i++) {
var marker = new google.maps.Marker({
position: myRoute.steps[i].start_point,
map: map
});
attachInstructionText(marker, myRoute.steps[i].instructions);
markerArray[i] = marker;
}
}
function attachInstructionText(marker, text) {
google.maps.event.addListener(marker, 'click', function() {
stepDisplay.setContent(text);
stepDisplay.open(map, marker);
});
}
</script>
</head>
そして体内で:
<body onload="initialize()">
<div style="text-align:left">
<b><font color="red">Start: </font></b>
<input id="start" type="textbox" value="Thuis">
<font color="red"><b>Waypoints:</b></font>
<select multiple id="waypoints">
<option value="50.96012,5.841106">WP 1</input>
<option value="50.958758,5.850166">WP 2</input>
<option value="50.947603,5.856555">WP 3</input>
<option value="50.952706,5.867075">WP 4</input>
<option value="50.951729,5.855134">WP 5</input>
<option value="50.949353,5.850499">WP 6</input>
<option value="50.95304,5.839818">WP 7</input>
<option value="50.96291,5.847548">WP 8</input>
</select>
<b><font color="red">End: </font></b>
<select id="end" onclick="calcRoute();">
<option value="50.966958,5.842978">Station Geleen Oost</option>
<option value="50.957204,5.836648">Parkeer plaats Driepoel, Geleen</option>
<option value="50.953409,5.84662">Pastoor Thissenplein, Sweikhuizen</option>
<option value="50.936529,5.894342">Alfa brouwerij/ Restaurant, Thull</option>
<option value="50.972853,5.883254">Ijsboerderij Coumans, Windraak</option>
</select>
<input type="button" value="start" onclick="calcRoute()">
</div>
<div id="map_canvas" style="top:20px;width:50%;height:70%"></div>
<div id="warnings_panel" style="width:100%;height:10%;text-align:center"></div>
私はまったく手がかりがありません。
誰かが私を助けることができれば、私は感謝します!!!
前もって感謝します
イ