简体   繁体   English

登录后无法获取GPS

[英]Can't get GPS after login

the GPS code works fine as long as i take out the php code.只要我取出 php 代码,GPS 代码就可以正常工作。 is there some kind of overlapping interference between php and javascript php 和 javascript 之间是否存在某种重叠干扰

any help would be greatly appreciated任何帮助将不胜感激

<?php
// Initialize the session
session_start();

// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
    header("location: login.php");
    exit;
}
else
{
}
?>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
    function showPosition(position) {  x.innerHTML = "Latitude: " + position.coords.latitude +  "<br>Longitude: " + position.coords.longitude;}
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}
</script>

Kindly check out your settings for your website/localhost.请检查您的网站/本地主机的设置。 I think the location is blocked by the your end.我认为该位置已被您的一端挡住了。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM