Good day,
I'm trying to create a google map link that will redirect to a map with directions. I will pass the coordinates in the link. Here is my code:
var latDes = this.items[id].LongitudeWD;
var longDes = this.items[id].LatitudeWD;
var url = "https://www.google.com/maps/dir/?api=1";
var origin = "origin=" + tempLatitude + "," + tempLongitude;
var destination = "&destination=" + latDes + "," + longDes;
var newUrl = new URL(url + origin + destination);
var win = window.open(newUrl, '_blank');
win.focus();
Here is the sample link that it is currently producing https://www.google.com/maps/dir/?api=1origin=34.1030032,-118.41046840000001&destination=-118.368152,34.059808
As you can see it does not have read the coordinates that I'm passing I want something like this
https://www.google.com/maps/dir/?api=1&origin=760+West+Genesee+Street+Syracuse+NY+13204&destination=314+Avery+Avenue+Syracuse+NY+13204
but if possible instead of using the full address can it be with latitude longitude?
Create a mapOn your computer, sign in to My Maps. Click Create a new map. Go to the top left and click "Untitled map." Give your map a name and description.
Seems like you missed '&' just before the 'origin' parameter. Also destination parameter have values, seems like not correct. It should be like
https://www.google.com/maps/dir/?api=1&origin=34.1030032,-118.41046840000001&destination=34.059808,-118.368152
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With