sending lat and long to google maps and returning directions on my web page.
if you look at this page here...
I have a google map in the center of the page
at the top of the page I have a form field that auto populates yours lat and long.
When you click the button submit it runs a file called directions.php.
I want this file to take the lat and long of the users position and then map them out
turn by turn directions in to the form field to the left you can see on the page.
I have been working on this all day and I have no clue how to set up the directions.php file.
I assume it needs to post the lat and long and waypoint address the GET the information back from
the server after its interpreted.
if anyone can help me i would appreciate it.
Possibly combine PHP and jQuery
On the directions.php page, the form that auto populates with the user's latitude and longitude uses the action page getDirections.php which is currently blank. The blank action page is why nothing happens when you press submit (obviously).
If I were you... I would remove the map and directions list box from the directions.php page, leaving just the latitude/longitude form.
Then, on the getDirections.php page, I would add the following to take the latitude and longitude from the form:
And I would then use jQuery to create the directions map and list using the new lat/long data. This should be sufficient:
$latitude = $_POST["lat"];
$longitude = $_POST["longitude"];
$lat_long = $latitude.",".$longitude;
This is just a general code. Most of the information you're looking for on how to do specific things can be found using the following websites:
origin:"<? echo $lat_long; ?>",
if (!results) return;
Let me know if this works or if you have any questions/concerns. Hope this helps! :)
- Google's API Development Page explains about the Google API and the specific options you can change.
- Gmap3 is a jQuery plugin for Google Maps that is necessary for this to work (and they provide well written Documentation).