@@ -18,12 +18,14 @@ import { SOnlineService } from 'imobile_for_reactnative'
1818import { scaleSize } from '../../../../utils/screen'
1919import NavigationService from '../../../NavigationService'
2020import { Const } from '../../../../constants'
21-
22- var GeolocationIOS = require ( 'Geolocation' )
23-
24- import { Geolocation } from "react-native-amap-geolocation"
25-
26-
21+ var Geolocation = undefined
22+ if ( Platform . OS === 'ios' ) {
23+ var GeolocationIOS = require ( 'Geolocation' )
24+ } else {
25+ import ( "react-native-amap-geolocation" ) . then ( result => {
26+ Geolocation = result . default . Geolocation
27+ } )
28+ }
2729
2830// eslint-disable-next-line no-unused-vars
2931const ICONS = context => [
@@ -88,23 +90,37 @@ export default class CustomActions extends React.Component {
8890 if ( Platform . OS === 'android' ) {
8991 Geolocation . init ( {
9092 ios : "9bd6c82e77583020a73ef1af59d0c759" ,
91- android : "043b24fe18785f33c491705ffe5b6935 " ,
93+ android : "078057f0e29931c173ad8ec02284a897 " ,
9294 } ) . then ( ( ) => {
9395 Geolocation . setOptions ( {
9496 interval : 8000 ,
9597 distanceFilter : 20 ,
9698 } )
9799 Geolocation . addLocationListener ( location => {
98- GeoLocation . stop ( )
100+ Geolocation . stop ( )
99101 console . log ( location )
102+ SOnlineService . reverseGeocoding (
103+ location . longitude ,
104+ location . latitude ,
105+ {
106+ onResult : result => {
107+ this . props . sendCallBack ( 3 , {
108+ address : result ,
109+ longitude : location . longitude ,
110+ latitude : location . latitude ,
111+ } )
112+ // alert(result)
113+ } ,
114+ } ,
115+ )
100116 } )
101117 } )
102118 }
103119 }
104120 componentWillUnmount ( ) {
105121 if ( Platform . OS === 'android' ) {
106- GeoLocation . removeLocationListener ( ) ;
107- GeoLocation . stop ( )
122+ // Geolocation .removeLocationListener();
123+ Geolocation . stop ( )
108124 }
109125 }
110126 setModalVisible ( visible = false ) {
@@ -201,7 +217,7 @@ export default class CustomActions extends React.Component {
201217 } ,
202218 )
203219 } else {
204- GeoLocation . start ( )
220+ Geolocation . start ( )
205221 }
206222 }
207223}
0 commit comments