Brad
Brad

Reputation: 241

What is the best route to create an interactive map-based website?

An example of what I would want to do is allow a user to set a start and end point on a map, get directions, show various routes between the two points, and store this route in a MySQL database using PHP. Does anyone have advice on the best way to go about doing this?

Upvotes: 0

Views: 408

Answers (1)

duncan
duncan

Reputation: 31912

Google Maps API 3 will do all this for you. You want to create a map and assign it an event listener so when the user clicks on the map, you draw either the start marker (if first click), end marker (if second click) (and presumably nothing else for subsequent clicks). You would then pass the latlng coordinates of both markers to the DirectionsService which will draw the directions and give you them in written form too. You can set the provideRouteAlternatives parameter to true to get alternative routes.

Then how you store that in the DB is up to you, perhaps saving the waypoints[] array.

Upvotes: 1

Related Questions