Getcurrentposition() and Watchposition() Are Deprecated on Insecure Origins

getCurrentPosition() and watchPosition() are deprecated on insecure origins

Found a likely answer in /jstillwell's posts here:
https://github.com/stefanocudini/leaflet-gps/issues/15
basically this feature will not be supported (in Chrome only?) in the future, but only for HTTP sites. HTTPS will still be ok, and there are no plans to create an equivalent replacement for HTTP use.

Why do I get a getCurrentPosition() and watchPosition() insecure origins error in Chrome on localhost?

Chrome considers localhost over http as secure. As you are using hostnme localhost.example over http, this is not considered as secure.

Note: Firefox will behave similarly as of Firefox 55

Geo location getCurrentPosition() and watchPosition() not work on insecure origins

Geolocation API Removed from Unsecured Origins in Chrome 50.

This change is effective as of Chrome 50 (12PM PST April 20 2016).

Chrome's developer tools console has been providing warnings since version 44 (released July 21 2015).
There have been a number of public announcements that describe the rationale (and discussion) of why we are making this change:

Intent to deprecate set of powerful features over HTTP (Feb 2015)
Intent to deprecate Geolocation API over HTTP (Nov 2015)
Chrome Dev Summit (Nov 2016)
Chrome Beta Channel release blog (March 17, 2016)
Chrome Status website
There have been a number of other sources that have highlighted this: Mobiforge (Jan 26, 2016), Wired (March 17, 2016), VentureBeat (April 13, 2016).

Read More Documentatin here .So thats not possible to use GeoLocation Without HTTPS.

Geolocation Without SSL connection

var apiGeolocationSuccess = function(position) {
alert("API geolocation success!\n\nlat = " + position.coords.latitude + "\nlng = " + position.coords.longitude);
};

var tryAPIGeolocation = function() {
jQuery.post( "https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyDCa1LUe1vOczX1hO_iGYgyo8p_jYuGOPU", function(success) {
apiGeolocationSuccess({coords: {latitude: success.location.lat, longitude: success.location.lng}});
})
.fail(function(err) {
alert("API Geolocation error! \n\n"+err);
});
};

var browserGeolocationSuccess = function(position) {
alert("Browser geolocation success!\n\nlat = " + position.coords.latitude + "\nlng = " + position.coords.longitude);
};

var browserGeolocationFail = function(error) {
switch (error.code) {
case error.TIMEOUT:
alert("Browser geolocation error !\n\nTimeout.");
break;
case error.PERMISSION_DENIED:
if(error.message.indexOf("Only secure origins are allowed") == 0) {
tryAPIGeolocation();
}
break;
case error.POSITION_UNAVAILABLE:
alert("Browser geolocation error !\n\nPosition unavailable.");
break;
}
};

var tryGeolocation = function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
browserGeolocationSuccess,
browserGeolocationFail,
{maximumAge: 50000, timeout: 20000, enableHighAccuracy: true});
}
};

tryGeolocation();


Related Topics



Leave a reply



Submit