Page 1 of 1

application to a secure origin

Posted: Thu Jan 14, 2016 12:55 pm
by B5107656409

Hello All,
I am facing with message below when running codes below:

getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

function setCurrentLocation() {
var geoOptions = {
enableHighAccuracy: true
};

Code: Select all

 var geoSuccess = function(position) { 

         var currentposition = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); 
         localStorage.setItem('_newlat',position.coords.latitude); 
         localStorage.setItem('_newlng',position.coords.longitude); 

         ggeocoder.geocode( {'latLng': currentposition}, function(results, status) { 
         if (status == google.maps.GeocoderStatus.OK) { 
             var address = results[0].formatted_address; 
             document.getElementById("current_location").value = address; 
             }  
         });  

         gmarker.setPosition(currentposition); 
         gmarker.setMap(null); 
         gmarker.setMap(gmap); 

         gmap.setCenter(currentposition); 
     gmap.setZoom(17); 
       }; 

       var geoError = function(error) { 
         alert('Error occurred. Error code: ' + error.code); 
         // error.code can be: 
         //   0: unknown error 
         //   1: permission denied 
         //   2: position unavailable (error response from location provider) 
         //   3: timed out 
       }; 

    navigator.geolocation.watchPosition(geoSuccess,geoError,geoOptions); 

}


application to a secure origin

Posted: Thu Jan 14, 2016 1:06 pm
by John de Quarius

B510, this issue will go away if you install the app. I think when the app is installed it uses the the secure layer but not during the preview. I maybe wrong but worth a try and output the error callback to a div somewhere on your page so that you can see what's going on.