Skip to content

Commit

Permalink
全体的なリファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
yadorogi committed Jan 24, 2024
1 parent 95f7799 commit 996f55c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demo2.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<body>
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBAtsxaRQmakZQsAOUPNx4N_Fh9m3IiqAg&callback=initMap" async defer></script>
<script src="ai.js"></script>
<script src="route.js"></script>
</body>
</html>
12 changes: 10 additions & 2 deletions ai.js → route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function initMap() {
// Create a new map instance
const map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 35.6895, lng: 139.6917 }, // 東京の座標
center: { lat: 35.638591, lng: 139.746087 }, // 開始、終了位置位置の座標
zoom: 12, // Set the initial zoom level
});

Expand Down Expand Up @@ -60,8 +60,9 @@ function initMap() {
(response, status) => {
if (status === "OK") {
directionsRenderer.setDirections(response);
displayRouteAddresses(response.routes[0]);
} else {
console.log("Directions request failed due to " + status);
console.log("次の理由で巡回ルートの計算に失敗しました:【" + status + "】" );
}
}
);
Expand All @@ -71,4 +72,11 @@ function initMap() {

// Call the cycleMarkers function to start cycling through the markers
cycleMarkers();

// Function to display the route addresses
function displayRouteAddresses(route) {
const addresses = route.legs.map((leg) => leg.end_address);
console.log(addresses);
// Display the addresses in your desired way (e.g., update a DOM element)
}
}

0 comments on commit 996f55c

Please sign in to comment.