1

Hello I m trying to make an app using the tutorial here. https://developers.google.com/maps/documentation/javascript/examples/directions-panel.

the question I want to ask if is it possible to have values from a mysql database in the select box. (The destination) . Also if its possible The start value to be the location of the user that uses the app.

sorry if these are easy questions but I m fairly new to programming and I dont know where to start.

Kostenko
  • 297
  • 1
  • 4
  • 14

1 Answers1

0

If you look at the HTML the elements added to the drop down list are down list are done so from the html, you will need to query your back-end database for the locations you want and pass them to the javascript (I am unsure what language you are using in your backend) if you're using php then this answer should help: Fetching data from MySQL database to html dropdown list

If you want the start point to always use the users location I would suggest a solution such as:

var location = navigator.geolocation.getCurrentPosition();
var start = new google.maps.LatLng(location.coords.latitude, location.coords.longitude);

Instead of deriving the start point from the ddl. Not this uses html5 geolocation, may not be accurate and may not work in all browsers.

Community
  • 1
  • 1
ChrisSwires
  • 2,713
  • 1
  • 15
  • 28