I am new to geo locations and I am using PHP. I want to get a map on my website in web where a person in my website knows his exact location. He should also be able to change his location on the map like as in swiggy.com
Ok, I will asume you've read the Google Map API documentation. Googling what you're asking should drive you here:
https://developers.google.com/maps/articles/geolocation
What I'm gonna tell you is how to add a Draggable Marker.
var map = new google.maps.Map([...])
//After using geolocation and getting the user coordinates
var marker = new google.maps.Marker({
//Note this variable contains the previously created LatLng Object
//with the user position
position: userPosLatLng,
//Important so the user can realocate
draggable: true,
map: map,
title: 'You're here'
});
You want to update the user coordinates when he stops dragging the marker right?
Here you do it. Add this event listener after the previous lines:
google.maps.event.addListener(marker, 'dragend', function(event) {
userPosLatLng = event.latLng;
});