Hi all,
I am trying to display a google map that has a starting and ending point. If I hard code the coordinates like I’ve illustrated below I get the map I want.
//** Enable below for Traffic layer
//var trafficLayer = new google.maps.TrafficLayer();
//trafficLayer.setMap(map);
directionsDisplay.setMap(map);
directionsService.route({
origin: new google.maps.LatLng(40.7986638, -73.9657349),
destination: new google.maps.LatLng(40.7980343, -73.970139),
travelMode: google.maps.TravelMode.DRIVING
},
If, on the other hand, I try to insert dynamic data (as a numeric field) in place of the hard coded numbers I get an HTML syntax error. the code looks like this.
//** Enable below for Traffic layer
//var trafficLayer = new google.maps.TrafficLayer();
//trafficLayer.setMap(map);
directionsDisplay.setMap(map);
directionsService.route({
origin: new google.maps.LatLng(Search for LatLng’s Seeker Lat, Search for LatLng’s Seeker Lng),
destination: new google.maps.LatLng(Search for LatLng’s Spot Lat, Search for LatLng’s Spot Lng),
travelMode: google.maps.TravelMode.DRIVING
},
Is there a way to move a variable into this html statement so that the map reflects the users input?
Thanks
Chris
Please pick a subcategory to help organize the information. Thanks!
Also, the more context you provide with your questions (screenshots, link to an open app, etc.), the more likely you’ll get good help quickly