Route API - how to use Current location in URL

Gonen Shoham 0 Reputation points
2023-01-18T14:10:19.3033333+00:00

hi

using this url for example -
https://dev.virtualearth.net/REST/V1/Routes?wp.0=30.85401,34.776949&wp.1=31.822634,34.895169&wp.2=30.62088,34.919876&key=<key>&routeAttributes=transitStops&o=xml&optimizeWaypoints=false&DistanceUnit=Kilometer&travelMode=Driving

is it possible to specify My Current location in wp.0 instead of the coordinates - so that routing will start dynamically from my location.

thank you very much

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
734 questions
Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
257 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. rbrundritt 18,591 Reputation points Microsoft Employee
    2023-01-26T18:10:55.5366667+00:00

    I use geolocation API on Android through a web app all the time. Try this sample and see if it works for you: [https://samples.azuremaps.com/?search=geolocation&sample=geolocation-control (Try loading it in your Android browser first to see if it works. If not, then you may not have given your browser permission to access your location which is unusual but similar to how you would have to handle the user not sharing their location in a native app.)

    1 person found this answer helpful.
    0 comments No comments

  2. rbrundritt 18,591 Reputation points Microsoft Employee
    2023-01-19T06:52:29.8366667+00:00

    No. Servers don't accurately know where you. At beast they might be able to guess your city. Accurate location data is only available through sensors on the end users device. So you have to get the users location from the device, and pass the coordinates into the route request.

    There are a lot of ways to get the users location from their device depending on the type of app you are creating. For example, if you have a web app, you can get the users location from the browser using the geolocation API: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.