I want to access the geolocation feature from the webshim library but i have failed to figure out the right setup to get it working ?
I am already accessing the inbuilt browser geolocation feature, but want to setup the polyfill in the case of browsers that dont have the geolocation feature.
import React from "react";
import webshim from 'webshim';
import $ from 'jquery';
class PlayGround extends React.Component{
pickLocation = () => {
console.log("Inside here")
webshim.ready('geolocation', () => {
navigator.geolocation.getCurrentPosition(function(pos){
alert("Thx, you are @ latitude: "+ pos.coords.latitude +"/longitude: " + pos.coords.longitude);
});
});
console.log("end inside")
}
}
Using polyfill to fill the support for Geolocations won't work. Getting location from the browser requires native support.
Almost all of the browser supports geolocation, https://caniuse.com/#feat=geolocation
Instead, you should check if a browser has support for geolocation or not. If it's not supported, fail with grace (show some error to the user)