Javascript 地理定位在本地工作,但不';远程服务器上的t

Javascript 地理定位在本地工作,但不';远程服务器上的t,javascript,php,jquery,mysql,geolocation,Javascript,Php,Jquery,Mysql,Geolocation,我将正在使用的web应用程序上载到远程服务器。 除了地理位置以外,一切都很好。我不明白是什么问题,因为我没有收到任何错误消息。 这是涉及地理位置的HTML代码 <tr> <td>Ti trovi qui: <span id="location"></span></td> </tr> </table> <input type="hidden" id="latitude" name="latitude">

我将正在使用的web应用程序上载到远程服务器。 除了地理位置以外,一切都很好。我不明白是什么问题,因为我没有收到任何错误消息。 这是涉及地理位置的HTML代码

<tr>
<td>Ti trovi qui: <span id="location"></span></td>
</tr>
</table>
<input type="hidden" id="latitude" name="latitude">
<input type="hidden" id="longitude" name="longitude">
</form>
这是getLocation.php文件(但我认为这不是问题所在):


然后我在另一个php文件中获取隐藏输入的值。

getCurrentPosition()
是异步的。当你打两次电话时,不能保证第一个电话会在第二个电话之前完成。两次背对背地打电话也没有意义

它还依赖第三方服务返回数据

只调用一次,并将响应值传递给一个回调中的两个函数

改变

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(getUserCoordinates);
    navigator.geolocation.getCurrentPosition(showLocation);
} else { 


还要检查您是否未在浏览器中为远程域禁用地理定位。添加一些控制台日志以查看代码中运行和未运行的内容如果您的网站使用https运行,您还需要更改此设置

http://maps.googleapis.com/maps/api/geocode/json?latlng=
对此

https://maps.googleapis.com/maps/api/geocode/json?latlng=

“返回状态”字段中有什么内容吗<代码>echo$status我刚刚添加了这些代码行,它开始工作了。。。我不知道为什么xD
navigator.geolocation.getCurrentPosition(getUserCoordinates,geoError);函数georerror(error){console.log(error.code);}
但我想了解。。你能解释一下吗?对我来说没什么意义。它可能只是暂时不可用。我同意xD我正在考虑共享主机的IP限制可能是一个因素,谢谢。。我打开了chrome控制台,它给了我这个错误消息:
getCurrentPosition()和watchPosition()不再适用于不安全的源代码。要使用这个特性,您应该考虑将应用程序切换到安全的原点,例如HTTPS。见[链接](https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins)有关更多详细信息。
因此我认为我发现了问题。。。我会做这个切换,我会告诉你最新情况。。
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position){
        getUserCoordinates(position);
        showLocation(position);
   });

} else { 
http://maps.googleapis.com/maps/api/geocode/json?latlng=
https://maps.googleapis.com/maps/api/geocode/json?latlng=