|
@@ -10,6 +10,7 @@ import { systemLocation } from "@/services/common";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
import showAlert from "@/components/basic/Alert";
|
|
import showAlert from "@/components/basic/Alert";
|
|
|
import { kIsAndroid, kIsIOS } from "@/utils/tools";
|
|
import { kIsAndroid, kIsIOS } from "@/utils/tools";
|
|
|
|
|
+import { AtActivityIndicator } from "taro-ui";
|
|
|
|
|
|
|
|
// let LeafletView = require('react-native-leaflet-maps').LeafletView
|
|
// let LeafletView = require('react-native-leaflet-maps').LeafletView
|
|
|
let location: any = null
|
|
let location: any = null
|
|
@@ -17,15 +18,21 @@ export default function map() {
|
|
|
// const [location, setLocation] = useState<any>(null)
|
|
// const [location, setLocation] = useState<any>(null)
|
|
|
const navigation = useNavigation()
|
|
const navigation = useNavigation()
|
|
|
const [current, setCurrent] = useState<any>(null)
|
|
const [current, setCurrent] = useState<any>(null)
|
|
|
- const [centerLocation, setCenterLocation] = useState(null)
|
|
|
|
|
|
|
+ const [centerLocation, setCenterLocation] = useState<any>(null)
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const [show, setShow] = useState(false)
|
|
const [show, setShow] = useState(false)
|
|
|
- const [count, setCount] = useState(0)
|
|
|
|
|
|
|
+ const [isLoading, setIsLoading] = useState(false)
|
|
|
const router = useRoute()
|
|
const router = useRoute()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- if ((router.params! as any).lat){
|
|
|
|
|
- debugger
|
|
|
|
|
|
|
+ if ((router.params! as any).lat) {
|
|
|
|
|
+ setCenterLocation({
|
|
|
|
|
+ latitude: (router.params! as any).lat,
|
|
|
|
|
+ longitude: (router.params! as any).lng
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ getCurrent()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
navigation.setOptions({
|
|
navigation.setOptions({
|
|
@@ -36,7 +43,7 @@ export default function map() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- getCurrent()
|
|
|
|
|
|
|
+ // getCurrent()
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
function confirmChoose() {
|
|
function confirmChoose() {
|
|
@@ -73,6 +80,7 @@ export default function map() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getCurrent() {
|
|
function getCurrent() {
|
|
|
|
|
+ setIsLoading(true)
|
|
|
Taro.getLocation({
|
|
Taro.getLocation({
|
|
|
success(res) {
|
|
success(res) {
|
|
|
// showAlert({
|
|
// showAlert({
|
|
@@ -81,13 +89,16 @@ export default function map() {
|
|
|
// })
|
|
// })
|
|
|
setShow(true)
|
|
setShow(true)
|
|
|
setCurrent(res)
|
|
setCurrent(res)
|
|
|
|
|
+ setCenterLocation(res)
|
|
|
location = {
|
|
location = {
|
|
|
lat: (res as any).latitude, lng: (res as any).longitude
|
|
lat: (res as any).latitude, lng: (res as any).longitude
|
|
|
}
|
|
}
|
|
|
|
|
+ setIsLoading(false)
|
|
|
},
|
|
},
|
|
|
fail(res) {
|
|
fail(res) {
|
|
|
console.log('location update failed reason', res)
|
|
console.log('location update failed reason', res)
|
|
|
if (res.errMsg == 'Permissions denied!') {
|
|
if (res.errMsg == 'Permissions denied!') {
|
|
|
|
|
+ setIsLoading(false)
|
|
|
showAlert({
|
|
showAlert({
|
|
|
title: t('feature.auth_sys.location_title'),
|
|
title: t('feature.auth_sys.location_title'),
|
|
|
content: kIsIOS ? t('feature.auth_sys.location_desc') : t('feature.auth_sys.location_android_service_desc'),
|
|
content: kIsIOS ? t('feature.auth_sys.location_desc') : t('feature.auth_sys.location_android_service_desc'),
|
|
@@ -117,8 +128,14 @@ export default function map() {
|
|
|
location = {
|
|
location = {
|
|
|
lat: (res as any).latitude, lng: (res as any).longitude
|
|
lat: (res as any).latitude, lng: (res as any).longitude
|
|
|
}
|
|
}
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
+ }).catch(e => {
|
|
|
|
|
+ setIsLoading(false)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ else {
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -130,8 +147,8 @@ export default function map() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function centerPosition() {
|
|
function centerPosition() {
|
|
|
- if (current) {
|
|
|
|
|
- return { lat: current.latitude, lng: current.longitude }
|
|
|
|
|
|
|
+ if (centerLocation) {
|
|
|
|
|
+ return { lat: centerLocation.latitude, lng: centerLocation.longitude }
|
|
|
}
|
|
}
|
|
|
return null
|
|
return null
|
|
|
}
|
|
}
|
|
@@ -190,7 +207,16 @@ export default function map() {
|
|
|
>
|
|
>
|
|
|
<Image src={require('@/assets/images/center.png')} style={styles.center} />
|
|
<Image src={require('@/assets/images/center.png')} style={styles.center} />
|
|
|
</View>
|
|
</View>
|
|
|
- <Image src={require('@/assets/images/current_location.png')} onClick={showCurrent} style={styles.location_btn} />
|
|
|
|
|
|
|
+ <View style={styles.location_btn}>
|
|
|
|
|
+ {
|
|
|
|
|
+ isLoading ? <View style={{width:20,height:20,overflow:'hidden'}}>
|
|
|
|
|
+ <AtActivityIndicator size={20} color="#000" content="" />
|
|
|
|
|
+ </View> :
|
|
|
|
|
+ <Image src={require('@/assets/images/current_location.png')} onClick={showCurrent} style={styles.location_icon} />
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ </View>
|
|
|
|
|
+
|
|
|
{/* <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>
|
|
location && <Text style={{ fontSize: 14, color: '#000' }}>Center位置:lat {(location as any).lat.toFixed(4)} lng {(location as any).lng.toFixed(4)}</Text>
|
|
@@ -225,8 +251,16 @@ const styles = StyleSheet.create({
|
|
|
position: 'absolute',
|
|
position: 'absolute',
|
|
|
left: 40,
|
|
left: 40,
|
|
|
bottom: 80,
|
|
bottom: 80,
|
|
|
- width: 40,
|
|
|
|
|
- height: 40
|
|
|
|
|
|
|
+ width: 50,
|
|
|
|
|
+ height: 50,
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
|
+ backgroundColor: '#fff',
|
|
|
|
|
+ borderRadius: 5
|
|
|
|
|
+ },
|
|
|
|
|
+ location_icon: {
|
|
|
|
|
+ width: 35,
|
|
|
|
|
+ height: 35
|
|
|
},
|
|
},
|
|
|
footer: {
|
|
footer: {
|
|
|
position: 'absolute',
|
|
position: 'absolute',
|