有没有办法得到lat/long
into PHP
在单个文件解决方案中?通常使用JS
我会用它来纯粹JS
解决方案,但现在我需要中的值PHP
变量:
<script>
$(document).ready(function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showLocation);
} else {
$('#location').html('Geolocation is not supported by this browser.');
}
});
function showLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
return latitude;
}
</script>
我需要得到lat/lon
g 变量变为PHP
不使用AJAX
发布到 url: xxx.php 类型的解决方案。仅单个文件。有什么关于以干净的方式执行此操作的想法吗?
顺便说一句-如果我将它们写入 cookie,则只有在重新加载文档时才有效。 :-(
Thanks!
您可以使用geoplugin apiLink https://www.geoplugin.com/webservices/php
<?php
echo var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp?
ip='.$_SERVER['REMOTE_ADDR'])));
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)