1
I have a marker on my map, it is "draggable", I would like to know how I can find the latitude and longitude of this marker, and later store in the database.
I read the google map api documentation but couldn’t find how to do it.
@Edit:
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: franca
});
function CarregarEnderecoPorLatLng(latitude, longitude){
var latlong = [latitude, longitude];
var marker5 = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map
});
return latlong;
}
map.addListener('click', function (e) {
CarregarEnderecoPorLatLng(e.latLng.lat(), e.latLng.lng());
})
In this attempt to click he adds a marker, I thought of returning an array with latitude and longitude, but I’m confused on how I’m going to get the return of that latitude and longitude through that function.
Let me get this straight. You by means of a draggable marker go walking by google maps and position in such place, pick up these coordinates, put in the bank so that when giving refresh, it appears "Static" in that coordinate?
– brnTwp
Exactly, I also tried to click on the map to add a marker, and I thought this function return the latitude and longitude it received through an array, and consume in php this array to make the Insert, I will give an Edit in what I tried...
– veroneseComS
Got it, check it out, I have a google maps project that has a function similar to what you want. Through clicks on the map, it dynamically sends the latitude and longitude to an input field, so from this input field I copy and paste in a window.open and register the marker, after registration it gives an auto refresh in index.php and voilá, the marker is in the exact location. If it fits, I can answer with that my function.
– brnTwp
I believe you can help yes, send me to try ;)
– veroneseComS