Vian Esterhuizen
Vian Esterhuizen

Reputation: 3904

Create a link to Google Maps that will populate with markers

I have a page that lists a series of locations, essentially a road trip with predefined stops, and all the locations are marked on a Google Maps map on the page. So I've already created Google Maps markers with locations/coordinates.

Is there a way to send these locations via a link or something to open in Google Maps? Allowing Google to handle all the directions and so forth.

EDIT: I'm not sure how to clear this up but I'll try

I have on my page:

What I need:
A way to send this marker information to Google Maps. Potentially through a URL or something but I'm not sure.

My team feels it makes more sense for Google Maps to handle all the directions features and prints features and save features etc.

Upvotes: 0

Views: 441

Answers (1)

Vian Esterhuizen
Vian Esterhuizen

Reputation: 3904

Working as of August 2015

Google Maps /dir/ URL
Using the following format you can generate a link to Google Maps containing a string of forward slash delimited coordinates.

https://www.google.com/maps/dir/51.0872877,-115.3715704/51.1627618,-115.5600419/53.5451428,-113.4850327/

Very basic implementation example:

var GMapsDirURL = "https://www.google.com/maps/dir/"
var GMapsURLMarkers = "";

for (){
 // Your for loop where creating Markers
 GMapsURLMarkers += Marker.coordinates + "/";
}

GMapsDirURL += GMapsURLMarkers;

Append your final GMapsDirURL to an href and you've got a link to Google maps with directions between all points.

Upvotes: 1

Related Questions