Google maps API – Center map on client’s current location

Try using the below code to get the user’s current location (GEOLOCATION): if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); map.setCenter(initialLocation); }); } For showing an example, I’ve removed your php code. Check this JSFiddle Hope you understand.

Get exact geo coordinates along an entire route, Google Maps or OpenStreetMap

OSRM gives you routes with road geometries as they are in the OpenStreetMap database. For example, you can get the route as GPX (and post-process this file if you want). This would look like the following: GET http://router.project-osrm.org/viaroute?hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760&output=gpx Read more: OSRM API docs.