【发布时间】:2019-06-25 09:57:51
【问题描述】:
我想从 webshim 库中访问地理定位功能,但我没有找到正确的设置来让它工作?
我已经在访问内置的浏览器 geolocation 功能,但想在没有 geolocation 功能的浏览器的情况下设置 polyfill。
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")
}
}
【问题讨论】:
-
不确定
React,但在React Native中它不起作用。你可以在 react native 中使用geolocation。 -
@TejashwiKalpTaru 我实际上只想在 React 中使用它 - 我想使用 polyfill 作为无法访问内置地理定位功能的浏览器的替代方案。 (我已经修改了问题)