2016-05-12 102 views
1

我有这个问题未捕获的ReferenceError:未定义handleLocationError谷歌地图API

getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS.

因此,我抛出这个错误

Uncaught ReferenceError: handleLocationError is not defined

因此,我调用API

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=ADVJFGFNFV4B2wTtyywqsMs--NTpg2w0&libraries=drawing,places"></script>

生产给了我错误

enter image description here

本地作品完美

enter image description here

一种解决方案是使用https。 但还有另一种方法吗?

回答

1

Chrome已经在版本50中弃用了它。目前还没有计划允许它在HTTP中使用。

localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to test the feature on that server.

这就是为什么它适用于本地。现在,你唯一的方法就是使用HTTPS,也许你可以使用像https://letsencrypt.org/这样的服务(它是免费的,自动的,打开的)。

祝你好运。

相关问题