I'm with this script that brings the geolocation of the user:
(function() {
if(!!navigator.geolocation) {
var map;
var mapOptions = {
};
map = new google.maps.Map(document.getElementById('google_canvas'), mapOptions);
navigator.geolocation.getCurrentPosition(function(position)
{
var geolocate = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var php_latitude = position.coords.latitude;
var php_longitude = position.coords.longitude;
alert(php_latitude);
});
} else {
document.getElementById('google_canvas').innerHTML = 'No Geolocation Support.';
}
})();
<script src="//maps.googleapis.com/maps/api/js?v=3.exp&key=XXX"></script>
I need to pass latitude and longitude values to variables in PHP.
I tried doing:
<?php
$variavelphp = "<script>document.write(php_latitude)</script>";
echo "Olá $variavelphp";
?>
But it did not work.
Is it possible to pass Jquery values to PHP?