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.