|
|
@@ -1,4 +1,4 @@
|
|
|
-import { View, StyleSheet } from "react-native";
|
|
|
+import { View, StyleSheet, Linking } from "react-native";
|
|
|
import { Image, Text } from "@tarojs/components";
|
|
|
import './map.scss'
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
@@ -7,6 +7,9 @@ import { LeafletView } from 'react-native-leaflet-maps';
|
|
|
import { useNavigation } from "@react-navigation/native";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
import { systemLocation } from "@/services/common";
|
|
|
+import { useTranslation } from "react-i18next";
|
|
|
+import showAlert from "@/components/basic/Alert";
|
|
|
+import { kIsAndroid, kIsIOS } from "@/utils/tools";
|
|
|
|
|
|
// let LeafletView = require('react-native-leaflet-maps').LeafletView
|
|
|
let location: any = null
|
|
|
@@ -14,6 +17,7 @@ export default function map() {
|
|
|
// const [location, setLocation] = useState<any>(null)
|
|
|
const navigation = useNavigation()
|
|
|
const [current, setCurrent] = useState<any>(null)
|
|
|
+ const { t } = useTranslation()
|
|
|
const [show, setShow] = useState(false)
|
|
|
const [count, setCount] = useState(0)
|
|
|
|
|
|
@@ -65,11 +69,51 @@ export default function map() {
|
|
|
function getCurrent() {
|
|
|
Taro.getLocation({
|
|
|
success(res) {
|
|
|
+ // showAlert({
|
|
|
+ // title: 'location',
|
|
|
+ // content: JSON.stringify(res)
|
|
|
+ // })
|
|
|
setShow(true)
|
|
|
setCurrent(res)
|
|
|
location = {
|
|
|
lat: (res as any).latitude, lng: (res as any).longitude
|
|
|
}
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ console.log('location update failed reason', res)
|
|
|
+ if (res.errMsg == 'Permissions denied!') {
|
|
|
+ showAlert({
|
|
|
+ title: t('feature.auth_sys.location_title'),
|
|
|
+ content: kIsIOS ? t('feature.auth_sys.location_desc') : t('feature.auth_sys.location_android_service_desc'),
|
|
|
+ showCancel: true,
|
|
|
+ cancelText: t('feature.auth_sys.location_cancel'),
|
|
|
+ confirmText: kIsIOS ? t('feature.auth_sys.location_confirm') : t('feature.auth_sys.service_confirm'),
|
|
|
+ confirm: () => {
|
|
|
+ if (kIsIOS) {
|
|
|
+ Linking.openURL('app-settings:')
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // Linking.openSettings()
|
|
|
+ var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
+ Jto.openNotificationSettings()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (kIsAndroid) {
|
|
|
+
|
|
|
+ var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
+ Jto.getLocation().then(result => {
|
|
|
+ var res = JSON.parse(result)
|
|
|
+ setCurrent(res)
|
|
|
+ location = {
|
|
|
+ lat: (res as any).latitude, lng: (res as any).longitude
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -141,11 +185,11 @@ export default function map() {
|
|
|
<Image src={require('@/assets/images/center.png')} style={styles.center} />
|
|
|
</View>
|
|
|
<Image src={require('@/assets/images/current_location.png')} onClick={showCurrent} style={styles.location_btn} />
|
|
|
- <View style={styles.footer}>
|
|
|
+ {/* <View style={styles.footer}>
|
|
|
{
|
|
|
location && <Text style={{ fontSize: 14, color: '#000' }}>Center位置:lat {(location as any).lat.toFixed(4)} lng {(location as any).lng.toFixed(4)}</Text>
|
|
|
}
|
|
|
- </View>
|
|
|
+ </View> */}
|
|
|
</View>
|
|
|
}
|
|
|
|