0
I’m having trouble picking up my location and moving on to the php post with onload
. How can I do that ? The values I’m trying to capture are the lat and long google.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 6
});
var infoWindow = new google.maps.InfoWindow({map: map});
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
Make an asynchronous request by passing the values, if you are using jquery, you can use the
$.post
– Jeferson Assis
but what can’t you do? Get the location(lat, lng) of google maps, or send this data to php?
– Neuber Oliveira
pass the coordinates to php.
– R.tavares1010