About navigator.geolocation

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 years ago
When i add this function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude +
  "<br>Longitude: " + position.coords.longitude;
}

code in any nopCommerce project it gives me error
--Error
1.Geolocation has been disabled in this document by Feature Policy.-
2.PERMISSION_DENIED: 1

Only not support in nopcommerce project any idea how to i use this in nopcommerce

Please help me
2 years ago
see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy/geolocation

edit your webDOTconfig file, and try 'self' to start:

<!--Feature-Policy is a new header that allows a site to control which features and APIs can be used in the browser. ref.: https://wicg.github.io/feature-policy/ -->
<add name="Feature-Policy" value="accelerometer 'none'; camera 'none'; geolocation 'self'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'" />


Note that many people are going to have this disabled in their browser.  You may want to look at extending the GeoLookupService to make use of MaxMind's geo-City database (not free) which will get you approximate lat/long:  https://www.maxmind.com/en/geoip2-city
2 years ago
Great , It Works

Thank You , That's really helpfull
1 year ago
af1racing wrote:
see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy/geolocation

edit your webDOTconfig file, and try 'self' to start:

<!--Feature-Policy is a new header that allows a site to control which features and APIs can be used in the browser. ref.: https://wicg.github.io/feature-policy/ -->
<add name="Feature-Policy" value="accelerometer 'none'; camera 'none'; geolocation 'self'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'" />



Thank you very much..  
1 year ago
'none'; geolocation
Web.config
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.