Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-amap3d
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-amap3d
Commits
837bd8c9
Commit
837bd8c9
authored
Nov 14, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add android offline maps module
parent
3e1f8eb1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
1 deletion
+128
-1
AMap3DPackage.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
+4
-1
AMapOfflineModule.kt
...c/main/java/cn/qiuxiang/react/amap3d/AMapOfflineModule.kt
+101
-0
app.js
example/src/app.js
+2
-0
examples.js
example/src/examples.js
+2
-0
offline.js
example/src/examples/offline.js
+19
-0
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
View file @
837bd8c9
...
@@ -11,7 +11,10 @@ import com.facebook.react.uimanager.ViewManager
...
@@ -11,7 +11,10 @@ import com.facebook.react.uimanager.ViewManager
class
AMap3DPackage
:
ReactPackage
{
class
AMap3DPackage
:
ReactPackage
{
override
fun
createNativeModules
(
reactContext
:
ReactApplicationContext
):
List
<
NativeModule
>
{
override
fun
createNativeModules
(
reactContext
:
ReactApplicationContext
):
List
<
NativeModule
>
{
return
listOf
(
AMapUtilsModule
(
reactContext
))
return
listOf
(
AMapUtilsModule
(
reactContext
),
AMapOfflineModule
(
reactContext
)
)
}
}
override
fun
createViewManagers
(
reactContext
:
ReactApplicationContext
):
List
<
ViewManager
<*,
*>>
{
override
fun
createViewManagers
(
reactContext
:
ReactApplicationContext
):
List
<
ViewManager
<*,
*>>
{
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapOfflineModule.kt
0 → 100644
View file @
837bd8c9
package
cn.qiuxiang.react.amap3d
import
com.amap.api.maps.offlinemap.OfflineMapCity
import
com.amap.api.maps.offlinemap.OfflineMapManager
import
com.amap.api.maps.offlinemap.OfflineMapProvince
import
com.amap.api.maps.offlinemap.OfflineMapStatus
import
com.facebook.react.bridge.*
import
com.facebook.react.modules.core.DeviceEventManagerModule
@Suppress
(
"unused"
)
class
AMapOfflineModule
(
private
val
reactContext
:
ReactApplicationContext
)
:
ReactContextBaseJavaModule
(
reactContext
),
OfflineMapManager
.
OfflineMapDownloadListener
{
private
val
manager
=
OfflineMapManager
(
reactContext
,
this
)
override
fun
getName
():
String
{
return
"AMapOffline"
}
@ReactMethod
fun
getProvinces
(
promise
:
Promise
)
{
val
provinces
=
Arguments
.
createArray
()
manager
.
offlineMapProvinceList
.
forEach
{
provinces
.
pushMap
(
buildProvince
(
it
))
}
promise
.
resolve
(
provinces
)
}
@ReactMethod
fun
getCities
(
promise
:
Promise
)
{
val
cities
=
Arguments
.
createArray
()
manager
.
offlineMapCityList
.
forEach
{
cities
.
pushMap
(
buildCity
(
it
))
}
promise
.
resolve
(
cities
)
}
@ReactMethod
fun
download
(
name
:
String
)
{
manager
.
offlineMapProvinceList
.
forEach
{
if
(
it
.
provinceName
==
name
)
{
return
manager
.
downloadByProvinceName
(
name
)
}
it
.
cityList
.
forEach
{
if
(
it
.
city
==
name
)
{
return
manager
.
downloadByCityName
(
name
)
}
}
}
}
@ReactMethod
fun
stop
()
{
manager
.
stop
()
}
@ReactMethod
fun
remove
(
name
:
String
)
{
manager
.
remove
(
name
)
}
private
fun
buildCity
(
city
:
OfflineMapCity
):
WritableMap
{
val
map
=
Arguments
.
createMap
()
map
.
putString
(
"name"
,
city
.
city
)
map
.
putString
(
"code"
,
city
.
code
)
map
.
putString
(
"state"
,
getState
(
city
.
state
))
map
.
putInt
(
"size"
,
city
.
size
.
toInt
())
return
map
}
private
fun
buildProvince
(
province
:
OfflineMapProvince
):
WritableMap
{
val
map
=
Arguments
.
createMap
()
map
.
putString
(
"name"
,
province
.
provinceName
)
map
.
putString
(
"state"
,
getState
(
province
.
state
))
map
.
putInt
(
"size"
,
province
.
size
.
toInt
())
val
cities
=
Arguments
.
createArray
()
province
.
cityList
.
forEach
{
cities
.
pushMap
(
buildCity
(
it
))
}
map
.
putArray
(
"cities"
,
cities
)
return
map
}
private
fun
getState
(
code
:
Int
):
String
{
var
state
=
""
when
(
code
)
{
OfflineMapStatus
.
SUCCESS
->
state
=
"downloaded"
OfflineMapStatus
.
LOADING
->
state
=
"expired"
OfflineMapStatus
.
NEW_VERSION
->
state
=
"expired"
}
return
state
}
override
fun
onDownload
(
state
:
Int
,
progress
:
Int
,
name
:
String
?)
{
if
(
state
==
OfflineMapStatus
.
LOADING
)
{
val
data
=
Arguments
.
createMap
()
data
.
putString
(
"name"
,
name
)
data
.
putInt
(
"progress"
,
progress
)
reactContext
.
getJSModule
(
DeviceEventManagerModule
.
RCTDeviceEventEmitter
::
class
.
java
).
emit
(
"onDownload"
,
data
)
}
}
override
fun
onCheckUpdate
(
p0
:
Boolean
,
p1
:
String
?)
{}
override
fun
onRemove
(
p0
:
Boolean
,
p1
:
String
?,
p2
:
String
?)
{}
}
\ No newline at end of file
example/src/app.js
View file @
837bd8c9
...
@@ -12,6 +12,7 @@ import Polyline from './examples/polyline'
...
@@ -12,6 +12,7 @@ import Polyline from './examples/polyline'
import
Polygon
from
'./examples/polygon'
import
Polygon
from
'./examples/polygon'
import
Circle
from
'./examples/circle'
import
Circle
from
'./examples/circle'
import
Events
from
'./examples/events'
import
Events
from
'./examples/events'
import
Offline
from
'./examples/offline'
import
Navigation
from
'./examples/navigation'
import
Navigation
from
'./examples/navigation'
import
HeatMap
from
'./examples/heat-map'
import
HeatMap
from
'./examples/heat-map'
import
MultiPoint
from
'./examples/multi-point'
import
MultiPoint
from
'./examples/multi-point'
...
@@ -29,6 +30,7 @@ export default StackNavigator({
...
@@ -29,6 +30,7 @@ export default StackNavigator({
Polygon
:
{
screen
:
Polygon
},
Polygon
:
{
screen
:
Polygon
},
Circle
:
{
screen
:
Circle
},
Circle
:
{
screen
:
Circle
},
Events
:
{
screen
:
Events
},
Events
:
{
screen
:
Events
},
Offline
:
{
screen
:
Offline
},
Navigation
:
{
screen
:
Navigation
},
Navigation
:
{
screen
:
Navigation
},
HeatMap
:
{
screen
:
HeatMap
},
HeatMap
:
{
screen
:
HeatMap
},
MultiPoint
:
{
screen
:
MultiPoint
},
MultiPoint
:
{
screen
:
MultiPoint
},
...
...
example/src/examples.js
View file @
837bd8c9
...
@@ -43,6 +43,8 @@ export default class Examples extends Component {
...
@@ -43,6 +43,8 @@ export default class Examples extends Component {
{
this
.
_renderItem
(
'动画移动'
,
'Animated'
)}
{
this
.
_renderItem
(
'动画移动'
,
'Animated'
)}
<
View
style
=
{
styles
.
separator
}
/
>
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'地图事件'
,
'Events'
)}
{
this
.
_renderItem
(
'地图事件'
,
'Events'
)}
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'离线地图'
,
'Offline'
)}
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
group
}
>
<
View
style
=
{
styles
.
group
}
>
{
this
.
_renderItem
(
'添加标记'
,
'Marker'
)}
{
this
.
_renderItem
(
'添加标记'
,
'Marker'
)}
...
...
example/src/examples/offline.js
0 → 100644
View file @
837bd8c9
import
React
,
{
Component
}
from
'react'
import
{
Offline
}
from
'react-native-amap3d'
export
default
class
IndoorExample
extends
Component
{
static
navigationOptions
=
{
title
:
'离线地图'
,
}
componentDidMount
()
{
// Offline.download('铜陵市')
setTimeout
(
async
()
=>
{
console
.
log
(
await
Offline
.
getProvinces
())
},
2000
)
}
render
()
{
return
null
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment