Benedetto
Benedetto

Reputation: 71

Google Maps Embed API Current Location as starting point with iframe

What i'm trying to do is set an address as destination and as the origin (starting point) I would like to put the current location of the device, but i cannot find anything on line that works with the iframe, all i found is to key current location as origin, but it doesn't seem to work, i also tried my location, current address and as i'm in italy i also tried with italian language, but all the same, any one know what's the correct command to put as origin so it will automatically get the user location as starting point

.maps {
  width: 600px;
  height: 200px;
  border: 0;
}
<iframe allowfullscreen="" class="maps" frameborder="0" id="mapnavi" name="mapnavi" src="https://www.google.com/maps/embed/v1/directions?
origin=current+location
&destination=rome
&key=AIzaSyC-5CY9mOCeg5Y3IhPqi_Yd0-DZtWrJl-E">
</iframe>

Upvotes: 3

Views: 12783

Answers (2)

YMH
YMH

Reputation: 3133

One of those three parameters should work:

  1. &origin=lat,lang
  2. &center=lat,lang
  3. &ll=lat,lang

Just add one of these parameters at the end of your src URL with your desired latitude & longitude.

Upvotes: -1

Anatolii Suhanov
Anatolii Suhanov

Reputation: 2702

You can get the current position using Geolocation API and then use it in latitude,longitude format.

For instance, it could look like https://www.google.com/maps/embed/v1/directions?origin=40.871579,14.2878583&destination=Rome

Upvotes: 2

Related Questions