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
4d9cbdea
Commit
4d9cbdea
authored
Nov 18, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善 ios 离线地图
parent
5f5d375c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
15 deletions
+46
-15
offline.js
example/src/examples/offline.js
+2
-2
AMapOffline.m
ios/AMapOffline.m
+44
-13
No files found.
example/src/examples/offline.js
View file @
4d9cbdea
...
@@ -9,9 +9,9 @@ export default class IndoorExample extends Component {
...
@@ -9,9 +9,9 @@ export default class IndoorExample extends Component {
async
componentDidMount
()
{
async
componentDidMount
()
{
console
.
log
(
await
Offline
.
getProvinces
())
console
.
log
(
await
Offline
.
getProvinces
())
// Offline.remove('铜陵市')
Offline
.
download
(
'河源市'
)
Offline
.
addDownloadListener
(
data
=>
console
.
log
(
data
))
Offline
.
addDownloadListener
(
data
=>
console
.
log
(
data
))
Offline
.
remove
(
'香港特别行政区'
)
Offline
.
download
(
'香港特别行政区'
)
}
}
render
()
{
render
()
{
...
...
ios/AMapOffline.m
View file @
4d9cbdea
#import <React/RCTBridgeModule.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#import <MAMapKit/MAOfflineMap.h>
#import <MAMapKit/MAOfflineMap.h>
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapOffline
:
NSObject
<
RCTBridgeModule
>
@interface
AMapOffline
:
RCTEventEmitter
<
RCTBridgeModule
>
@end
@end
@implementation
AMapOffline
@implementation
AMapOffline
...
@@ -47,10 +48,29 @@ RCT_REMAP_METHOD(getCities,
...
@@ -47,10 +48,29 @@ RCT_REMAP_METHOD(getCities,
RCT_EXPORT_METHOD
(
download
:
(
NSString
*
)
name
)
{
RCT_EXPORT_METHOD
(
download
:
(
NSString
*
)
name
)
{
MAOfflineItem
*
item
=
[
self
getItem
:
name
];
MAOfflineItem
*
item
=
[
self
getItem
:
name
];
void
(
^
downloadBlock
)(
MAOfflineItem
*
,
MAOfflineMapDownloadStatus
,
id
)
=^
(
MAOfflineItem
*
downloadItem
,
MAOfflineMapDownloadStatus
state
,
id
info
)
{
NSDictionary
*
data
=
(
NSDictionary
*
)
info
;
double
progress
=
0
;
if
(
state
==
MAOfflineMapDownloadStatusProgress
)
{
progress
=
[
data
[
MAOfflineMapDownloadReceivedSizeKey
]
doubleValue
]
/
[
data
[
MAOfflineMapDownloadExpectedSizeKey
]
doubleValue
]
*
100
;
}
[
self
sendEventWithName
:
@"download"
body
:@{
@"name"
:
name
,
@"state"
:
[
self
downloadStateString
:
state
],
@"progress"
:
@
(
progress
),
}];
};
if
(
item
!=
nil
)
{
if
(
item
!=
nil
)
{
[
MAOfflineMap
.
sharedOfflineMap
downloadItem
:
item
[
MAOfflineMap
.
sharedOfflineMap
downloadItem
:
item
shouldContinueWhenAppEntersBackground
:
YES
shouldContinueWhenAppEntersBackground
:
YES
downloadBlock
:
nil
];
downloadBlock
:
downloadBlock
];
}
}
RCT_EXPORT_METHOD
(
remove
:
(
NSString
*
)
name
)
{
MAOfflineItem
*
item
=
[
self
getItem
:
name
];
if
(
item
!=
nil
)
{
[
MAOfflineMap
.
sharedOfflineMap
deleteItem
:
item
];
}
}
}
}
...
@@ -77,18 +97,25 @@ RCT_EXPORT_METHOD(download:(NSString *)name) {
...
@@ -77,18 +97,25 @@ RCT_EXPORT_METHOD(download:(NSString *)name) {
return
nil
;
return
nil
;
}
}
-
(
NSString
*
)
stateString
:
(
MAOfflineItemStatus
)
code
{
-
(
NSString
*
)
downloadStateString
:
(
MAOfflineMapDownloadStatus
)
code
{
NSString
*
state
=
@""
;
switch
(
code
)
{
if
(
code
==
MAOfflineItemStatusCached
)
{
case
MAOfflineMapDownloadStatusWaiting
:
return
@"waiting"
;
state
=
@"downloading"
;
case
MAOfflineMapDownloadStatusStart
:
return
@"downloading"
;
}
case
MAOfflineMapDownloadStatusProgress
:
return
@"downloading"
;
if
(
code
==
MAOfflineItemStatusExpired
)
{
case
MAOfflineMapDownloadStatusCompleted
:
return
@"unzip"
;
state
=
@"expired"
;
case
MAOfflineMapDownloadStatusUnzip
:
return
@"unzip"
;
case
MAOfflineMapDownloadStatusFinished
:
return
@"downloaded"
;
default
:
return
@""
;
}
}
if
(
code
==
MAOfflineItemStatusInstalled
)
{
}
state
=
@"downloaded"
;
-
(
NSString
*
)
stateString
:
(
MAOfflineItemStatus
)
code
{
switch
(
code
)
{
case
MAOfflineItemStatusCached
:
return
@"downloading"
;
case
MAOfflineItemStatusExpired
:
return
@"expired"
;
case
MAOfflineItemStatusInstalled
:
return
@"downloaded"
;
default
:
return
@""
;
}
}
return
state
;
}
}
-
(
NSDictionary
*
)
itemData
:
(
MAOfflineCity
*
)
city
{
-
(
NSDictionary
*
)
itemData
:
(
MAOfflineCity
*
)
city
{
...
@@ -99,4 +126,8 @@ RCT_EXPORT_METHOD(download:(NSString *)name) {
...
@@ -99,4 +126,8 @@ RCT_EXPORT_METHOD(download:(NSString *)name) {
};
};
}
}
-
(
NSArray
<
NSString
*>
*
)
supportedEvents
{
return
@[
@"download"
];
}
@end
@end
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