简体   繁体   English

地理定位在 Jsfiddle 中工作但不在任何其他 JS 编辑器中工作?

[英]Geolocation working in Jsfiddle but not in any other JS editor?

When i am using Gelocation code example on Jsfidlle or google demo example on google developers website , i am able to get the latitude and longitude but when I use that code in some other JS editors i am getting error geolocation service failed当我在 Jsfdlle 上使用 Gelocation 代码示例或在 google 开发者网站上使用 google demo 示例时,我能够获得纬度和经度,但是当我在其他一些 JS 编辑器中使用该代码时,我收到错误地理定位服务失败

HERE GOES MY CODE这是我的代码

if (navigator.geolocation) {
var latitude = '';
var longitude = '';
navigator.geolocation.getCurrentPosition(function (position) {
    latitude = position.coords.latitude;
    longitude = position.coords.longitude;
    alert(latitude);
     });
     } else {
    alert("Geolocation API is not supported");
    };

Do you use Chrome50?你使用 Chrome50 吗? They removed GeoLocation support for non https Sites.他们删除了对非 https 站点的 GeoLocation 支持。 but ( http://localhost:xx ) is still whitelisted for developing但是( http://localhost:xx )仍然被列入开发白名单

https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only

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

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