From 121b5f0ed8933c89f0879a0e727045188ded0c5f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 01:27:51 +0000 Subject: [PATCH 1/2] Initial plan From edf019543ff67e468924deed2794d239ae37583a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 01:34:09 +0000 Subject: [PATCH 2/2] Update Route to a destination sample to use new API version 2025-01-01 with POST method Co-authored-by: dubiety <3462778+dubiety@users.noreply.github.com> --- .../Route/Route to a destination.html | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Samples/Tutorials/Route/Route to a destination.html b/Samples/Tutorials/Route/Route to a destination.html index b40ff4e8..3d2903e3 100644 --- a/Samples/Tutorials/Route/Route to a destination.html +++ b/Samples/Tutorials/Route/Route to a destination.html @@ -25,7 +25,7 @@ var map, datasource; // URL for the Azure Maps Route API. - var routeUrl = 'https://{azMapsDomain}/route/directions/json?api-version=1.0&query={query}&routeRepresentation=polyline&travelMode=car&view=Auto'; + var routeUrl = 'https://{azMapsDomain}/route/directions?api-version=2025-01-01'; function getMap() { // Initialize a map instance. @@ -85,13 +85,17 @@ var startPosition = [-122.33028, 47.60323]; var startPoint = new atlas.data.Feature(new atlas.data.Point(startPosition), { title: 'Seattle', - iconImage: 'pin-blue' + iconImage: 'pin-blue', + pointIndex: 0, + pointType: "waypoint" }); var endPosition = [-122.124, 47.67491]; var endPoint = new atlas.data.Feature(new atlas.data.Point(endPosition), { title: 'Redmond', - iconImage: 'pin-red' + iconImage: 'pin-red', + pointIndex: 1, + pointType: "waypoint" }); // Add the data to the data source. @@ -103,23 +107,20 @@ padding: 50 }); - // Create the route request with the query being the start and end point in the format 'startLongitude,startLatitude:endLongitude,endLatitude'. - var routeRequestURL = routeUrl - .replace('{query}', `${startPosition[1]},${startPosition[0]}:${endPosition[1]},${endPosition[0]}`); - - // Process the request and render the route result on the map. - processRequest(routeRequestURL).then(directions => { - // Extract the first route from the directions. - const route = directions.routes[0]; - - // Combine all leg coordinates into a single array. - const routeCoordinates = route.legs.flatMap(leg => leg.points.map(point => [point.longitude, point.latitude])); - - // Create a LineString from the route path points. - const routeLine = new atlas.data.LineString(routeCoordinates); - - // Add it to the data source. - datasource.add(routeLine); + // Create the route request body using GeoJSON FeatureCollection. + var routeRequestBody = { + type: 'FeatureCollection', + features: [startPoint, endPoint], + optimizeRoute: 'fastestWithTraffic', + routeOutputOptions: ['routePath'], + maxRouteCount: 1, + travelMode: 'driving' + }; + + // Process the POST request and render the route result on the map. + processPostRequest(routeUrl, JSON.stringify(routeRequestBody)).then(directions => { + // Add directions to the data source. + datasource.add(directions); }); }); }