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
5f5d375c
Commit
5f5d375c
authored
Nov 18, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 android 离线地图下载进度事件
parent
6aa74889
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
AMapOfflineModule.kt
...c/main/java/cn/qiuxiang/react/amap3d/AMapOfflineModule.kt
+8
-7
offline.js
example/src/examples/offline.js
+6
-5
Offline.js
src/Offline.js
+3
-0
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapOfflineModule.kt
View file @
5f5d375c
...
...
@@ -79,19 +79,20 @@ class AMapOfflineModule(private val reactContext: ReactApplicationContext) : Rea
var
state
=
""
when
(
code
)
{
OfflineMapStatus
.
SUCCESS
->
state
=
"downloaded"
OfflineMapStatus
.
LOADING
->
state
=
"
expired
"
OfflineMapStatus
.
LOADING
->
state
=
"
downloading
"
OfflineMapStatus
.
NEW_VERSION
->
state
=
"expired"
OfflineMapStatus
.
WAITING
->
state
=
"waiting"
OfflineMapStatus
.
UNZIP
->
state
=
"unzip"
}
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
)
}
val
data
=
Arguments
.
createMap
()
data
.
putString
(
"name"
,
name
)
data
.
putString
(
"state"
,
getState
(
state
))
data
.
putInt
(
"progress"
,
progress
)
reactContext
.
getJSModule
(
DeviceEventManagerModule
.
RCTDeviceEventEmitter
::
class
.
java
).
emit
(
"download"
,
data
)
}
override
fun
onCheckUpdate
(
p0
:
Boolean
,
p1
:
String
?)
{}
...
...
example/src/examples/offline.js
View file @
5f5d375c
import
React
,
{
Component
}
from
'react'
import
{
Offline
}
from
'react-native-amap3d'
// TODO: 提供完整的离线地图示例
export
default
class
IndoorExample
extends
Component
{
static
navigationOptions
=
{
title
:
'离线地图'
,
}
componentDidMount
()
{
// Offline.download('铜陵市'
)
setTimeout
(
async
()
=>
{
console
.
log
(
await
Offline
.
getProvinces
()
)
},
2000
)
async
componentDidMount
()
{
console
.
log
(
await
Offline
.
getProvinces
()
)
// Offline.remove('铜陵市')
Offline
.
download
(
'河源市'
)
Offline
.
addDownloadListener
(
data
=>
console
.
log
(
data
)
)
}
render
()
{
...
...
src/Offline.js
View file @
5f5d375c
import
{
NativeModules
,
NativeEventEmitter
}
from
'react-native'
const
{
AMapOffline
}
=
NativeModules
const
eventEmitter
=
new
NativeEventEmitter
(
AMapOffline
)
export
default
{
getProvinces
:
()
=>
AMapOffline
.
getProvinces
(),
getCities
:
()
=>
AMapOffline
.
getCities
(),
download
:
name
=>
AMapOffline
.
download
(
name
),
remove
:
name
=>
AMapOffline
.
remove
(
name
),
addDownloadListener
:
callback
=>
eventEmitter
.
addListener
(
'download'
,
callback
)
}
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