View } from 'react-native';
import { WebView } from 'react-native-webview';
import * as Location from 'expo-location';
const Maps = () => {
const [location, setLocation] = useState(null);
const [errorMsg, setErrorMsg] = useState(null);
useEffect(() => {
(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
setErrorMsg('Permission to access location was denied');
return;
}
try {
let location = await Location.installWebGeolocationPolyfill({});
setLocation(location);
} catch (setErrorMsg) {
this.setLocation({ setErrorMsg });
}
})();
}, []);
let text = 'Waiting..';
if (errorMsg) {
text = errorMsg;
} else if (location) {
text = JSON.stringify(location);
}
return (
<View style={{flex:1}}>
<WebView
style={{flex:1}}
originWhitelist={['*']}
source={{ html: '<iframe src="https://map.blitzortung.org/index.php?interactive=1&NavigationControl=0&FullScreenControl=0&Cookies=0&InfoDiv=1&MenuButtonDiv=1&ScaleControl=1&LinksCheckboxChecked=1&LinksRangeValue=10&MapStyle=3&MapStyleRangeValue=4&Advertisment=0#5/36.5/135.0" width="800" height="400"></iframe>' }}
geolocationEnabled={true}
javaScriptEnabled={true}
/>
<Text>{text}</Text>
</View>
);
}
export default Maps
А так помоги если я все не правильно делаю, поправьте пожалуйста!
Обсуждают сегодня