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
3a4d6937
Commit
3a4d6937
authored
Aug 22, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 iOS 导航代码
parent
4f47386b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
163 deletions
+91
-163
AMapDriveManager.m
ios/AMapDriveManager.m
+20
-57
AMapNavigationManager.h
ios/AMapNavigationManager.h
+37
-0
AMapRideManager.m
ios/AMapRideManager.m
+17
-53
AMapWalkManager.m
ios/AMapWalkManager.m
+17
-53
No files found.
ios/AMapDriveManager.m
View file @
3a4d6937
#import <React/RCTUIManager.h>
#import <React/RCTUIManager.h>
#import <AMapNaviKit/AMapNaviDriveView.h>
#import <AMapNaviKit/AMapNaviDriveView.h>
#import <AMapNaviKit/AMapNaviDriveManager.h>
#import <AMapNaviKit/AMapNaviDriveManager.h>
#import "AMapNavigationManager.h"
#import "AMapDrive.h"
#import "AMapDrive.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapDriveManager
:
RCTViewManager
<
AMapNaviDriveManagerDelegate
>
@interface
AMapDriveManager
:
RCTViewManager
<
AMapNaviDriveManagerDelegate
>
+
(
AMapDrive
*
)
drive
View
;
+
(
AMapDrive
*
)
navigation
View
;
+
(
AMapNaviDriveManager
*
)
drive
Manager
;
+
(
AMapNaviDriveManager
*
)
navigation
Manager
;
@end
@end
@implementation
AMapDriveManager
{
@implementation
AMapDriveManager
{
AMapDrive
*
_driveView
;
AMapDrive
*
_navigationView
;
AMapNaviDriveManager
*
_driveManager
;
AMapNaviDriveManager
*
_navigationManager
;
}
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_driveView
=
[
AMapDriveManager
driveView
];
_driveManager
=
[
AMapDriveManager
driveManager
];
_driveManager
.
delegate
=
self
;
}
return
self
;
}
}
RCT_EXPORT_MODULE
()
INIT
(
AMapDriveManager
)
NAVIGATION_VIEW
(
AMapDrive
)
NAVIGATION_MANAGER
(
AMapDriveManager
,
AMapNaviDriveManager
)
RCT_EXPORT_VIEW_PROPERTY
(
onCalculateRouteSuccess
,
RCTBubblingEventBlock
)
RCT_EXPORT_METHOD
(
calculateRoute
:
(
nonnull
NSNumber
*
)
reactTag
RCT_EXPORT_VIEW_PROPERTY
(
onCalculateRouteFailure
,
RCTBubblingEventBlock
)
start
:
(
AMapNaviPoint
*
)
start
end
:
(
AMapNaviPoint
*
)
end
RCT_EXPORT_METHOD
(
calculateRoute
:
(
nonnull
NSNumber
*
)
reactTag
start
:
(
AMapNaviPoint
*
)
start
end
:
(
AMapNaviPoint
*
)
end
way
:
(
NSArray
<
AMapNaviPoint
*>
*
)
way
)
{
way
:
(
NSArray
<
AMapNaviPoint
*>
*
)
way
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
[
_navigationManager
calculateDriveRouteWithStartPoints
:@[
start
]
[
_driveManager
calculateDriveRouteWithStartPoints
:@[
start
]
endPoints
:@[
end
]
endPoints
:@[
end
]
wayPoints
:
way
wayPoints:
nil
drivingStrategy
:
AMapNaviDrivingStrategySingleDefault
];
drivingStrategy:
AMapNaviDrivingStrategySingleDefault
];
}];
}
RCT_EXPORT_METHOD
(
start
:
(
nonnull
NSNumber
*
)
reactTag
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
[
_driveManager
startGPSNavi
];
}];
}
-
(
UIView
*
)
view
{
return
_driveView
;
}
}
-
(
void
)
driveManagerOnCalculateRouteSuccess
:
(
AMapNaviDriveManager
*
)
driveManager
{
-
(
void
)
driveManagerOnCalculateRouteSuccess
:
(
AMapNaviDriveManager
*
)
driveManager
{
if
(
_
drive
View
.
onCalculateRouteSuccess
)
{
if
(
_
navigation
View
.
onCalculateRouteSuccess
)
{
_
drive
View
.
onCalculateRouteSuccess
(
nil
);
_
navigation
View
.
onCalculateRouteSuccess
(
nil
);
}
}
}
}
-
(
void
)
driveManager
:
(
AMapNaviDriveManager
*
)
driveManager
onCalculateRouteFailure
:
(
NSError
*
)
error
{
-
(
void
)
driveManager
:
(
AMapNaviDriveManager
*
)
driveManager
onCalculateRouteFailure
:
(
NSError
*
)
error
{
if
(
_
drive
View
.
onCalculateRouteFailure
)
{
if
(
_
navigation
View
.
onCalculateRouteFailure
)
{
_
drive
View
.
onCalculateRouteFailure
(@{
_
navigation
View
.
onCalculateRouteFailure
(@{
@"code"
:
@
(
error
.
code
),
@"code"
:
@
(
error
.
code
),
});
});
}
}
}
}
+
(
AMapNaviDriveManager
*
)
driveManager
{
static
AMapNaviDriveManager
*
driveManager
;
if
(
driveManager
==
nil
)
{
driveManager
=
[
AMapNaviDriveManager
new
];
[
driveManager
addDataRepresentative
:[
AMapDriveManager
driveView
]];
}
return
driveManager
;
}
+
(
AMapDrive
*
)
driveView
{
static
AMapDrive
*
driveView
;
if
(
driveView
==
nil
)
{
driveView
=
[
AMapDrive
new
];
}
return
driveView
;
}
@end
@end
ios/AMapNavigationManager.h
0 → 100644
View file @
3a4d6937
#define INIT(clazz) \
- (instancetype)init { \
if (self = [super init]) { \
_navigationView = [clazz navigationView]; \
_navigationManager = [clazz navigationManager]; \
_navigationManager.delegate = self; \
} \
return self; \
} \
\
- (UIView *)view { \
return _navigationView; \
} \
\
RCT_EXPORT_MODULE() \
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteSuccess, RCTBubblingEventBlock) \
RCT_EXPORT_VIEW_PROPERTY(onCalculateRouteFailure, RCTBubblingEventBlock) \
RCT_EXPORT_METHOD(start:(nonnull NSNumber *)reactTag) { \
[_navigationManager startGPSNavi]; \
} \
#define NAVIGATION_VIEW(type) \
+ (type *)navigationView { \
static type *view; \
if (view == nil) view = [type new]; \
return view; \
} \
#define NAVIGATION_MANAGER(clazz, type) \
+ (type *)navigationManager { \
static type *manager; \
if (manager == nil) { \
manager = [type new]; \
[manager addDataRepresentative:[clazz navigationView]]; \
} \
return manager; \
} \
ios/AMapRideManager.m
View file @
3a4d6937
#import <React/RCTUIManager.h>
#import <React/RCTUIManager.h>
#import <AMapNaviKit/AMapNaviRideView.h>
#import <AMapNaviKit/AMapNaviRideView.h>
#import <AMapNaviKit/AMapNaviRideManager.h>
#import <AMapNaviKit/AMapNaviRideManager.h>
#import "AMapNavigationManager.h"
#import "AMapRide.h"
#import "AMapRide.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapRideManager
:
RCTViewManager
<
AMapNaviRideManagerDelegate
>
@interface
AMapRideManager
:
RCTViewManager
<
AMapNaviRideManagerDelegate
>
+
(
AMapRide
*
)
ride
View
;
+
(
AMapRide
*
)
navigation
View
;
+
(
AMapNaviRideManager
*
)
ride
Manager
;
+
(
AMapNaviRideManager
*
)
navigation
Manager
;
@end
@end
@implementation
AMapRideManager
{
@implementation
AMapRideManager
{
AMapRide
*
_
ride
View
;
AMapRide
*
_
navigation
View
;
AMapNaviRideManager
*
_
ride
Manager
;
AMapNaviRideManager
*
_
navigation
Manager
;
}
}
-
(
instancetype
)
init
{
INIT
(
AMapRideManager
)
if
(
self
=
[
super
init
])
{
NAVIGATION_VIEW
(
AMapRide
)
_rideView
=
[
AMapRideManager
rideView
];
NAVIGATION_MANAGER
(
AMapRideManager
,
AMapNaviRideManager
)
_rideManager
=
[
AMapRideManager
rideManager
];
_rideManager
.
delegate
=
self
;
}
return
self
;
}
RCT_EXPORT_MODULE
()
RCT_EXPORT_VIEW_PROPERTY
(
onCalculateRouteSuccess
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onCalculateRouteFailure
,
RCTBubblingEventBlock
)
RCT_EXPORT_METHOD
(
calculateRoute
:
(
nonnull
NSNumber
*
)
reactTag
start
:
(
AMapNaviPoint
*
)
start
end
:
(
AMapNaviPoint
*
)
end
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
[
_rideManager
calculateRideRouteWithStartPoint
:
start
endPoint
:
end
];
}];
}
RCT_EXPORT_METHOD
(
start
:
(
nonnull
NSNumber
*
)
reactTag
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
[
_rideManager
startGPSNavi
];
}];
}
-
(
UIView
*
)
view
{
RCT_EXPORT_METHOD
(
calculateRoute
:
(
nonnull
NSNumber
*
)
reactTag
return
_rideView
;
start
:
(
AMapNaviPoint
*
)
start
end
:
(
AMapNaviPoint
*
)
end
way
:
(
NSArray
<
AMapNaviPoint
*>
*
)
way
)
{
[
_navigationManager
calculateRideRouteWithStartPoint
:
start
endPoint
:
end
];
}
}
-
(
void
)
rideManagerOnCalculateRouteSuccess
:
(
AMapNaviRideManager
*
)
rideManager
{
-
(
void
)
rideManagerOnCalculateRouteSuccess
:
(
AMapNaviRideManager
*
)
rideManager
{
if
(
_
ride
View
.
onCalculateRouteSuccess
)
{
if
(
_
navigation
View
.
onCalculateRouteSuccess
)
{
_
ride
View
.
onCalculateRouteSuccess
(
nil
);
_
navigation
View
.
onCalculateRouteSuccess
(
nil
);
}
}
}
}
-
(
void
)
rideManager
:
(
AMapNaviRideManager
*
)
rideManager
onCalculateRouteFailure
:
(
NSError
*
)
error
{
-
(
void
)
rideManager
:
(
AMapNaviRideManager
*
)
rideManager
onCalculateRouteFailure
:
(
NSError
*
)
error
{
if
(
_
ride
View
.
onCalculateRouteFailure
)
{
if
(
_
navigation
View
.
onCalculateRouteFailure
)
{
_
ride
View
.
onCalculateRouteFailure
(@{
_
navigation
View
.
onCalculateRouteFailure
(@{
@"code"
:
@
(
error
.
code
),
@"code"
:
@
(
error
.
code
),
});
});
}
}
}
}
+
(
AMapNaviRideManager
*
)
rideManager
{
static
AMapNaviRideManager
*
rideManager
;
if
(
rideManager
==
nil
)
{
rideManager
=
[
AMapNaviRideManager
new
];
[
rideManager
addDataRepresentative
:[
AMapRideManager
rideView
]];
}
return
rideManager
;
}
+
(
AMapRide
*
)
rideView
{
static
AMapRide
*
rideView
;
if
(
rideView
==
nil
)
{
rideView
=
[
AMapRide
new
];
}
return
rideView
;
}
@end
@end
ios/AMapWalkManager.m
View file @
3a4d6937
#import <React/RCTUIManager.h>
#import <React/RCTUIManager.h>
#import <AMapNaviKit/AMapNaviWalkView.h>
#import <AMapNaviKit/AMapNaviWalkView.h>
#import <AMapNaviKit/AMapNaviWalkManager.h>
#import <AMapNaviKit/AMapNaviWalkManager.h>
#import "AMapNavigationManager.h"
#import "AMapWalk.h"
#import "AMapWalk.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapWalkManager
:
RCTViewManager
<
AMapNaviWalkManagerDelegate
>
@interface
AMapWalkManager
:
RCTViewManager
<
AMapNaviWalkManagerDelegate
>
+
(
AMapWalk
*
)
walk
View
;
+
(
AMapWalk
*
)
navigation
View
;
+
(
AMapNaviWalkManager
*
)
walk
Manager
;
+
(
AMapNaviWalkManager
*
)
navigation
Manager
;
@end
@end
@implementation
AMapWalkManager
{
@implementation
AMapWalkManager
{
AMapWalk
*
_
walk
View
;
AMapWalk
*
_
navigation
View
;
AMapNaviWalkManager
*
_
walk
Manager
;
AMapNaviWalkManager
*
_
navigation
Manager
;
}
}
-
(
instancetype
)
init
{
INIT
(
AMapWalkManager
)
if
(
self
=
[
super
init
])
{
NAVIGATION_VIEW
(
AMapWalk
)
_walkView
=
[
AMapWalkManager
walkView
];
NAVIGATION_MANAGER
(
AMapWalkManager
,
AMapNaviWalkManager
)
_walkManager
=
[
AMapWalkManager
walkManager
];
_walkManager
.
delegate
=
self
;
}
return
self
;
}
RCT_EXPORT_MODULE
()
RCT_EXPORT_VIEW_PROPERTY
(
onCalculateRouteSuccess
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onCalculateRouteFailure
,
RCTBubblingEventBlock
)
RCT_EXPORT_METHOD
(
calculateRoute
:
(
nonnull
NSNumber
*
)
reactTag
start
:
(
AMapNaviPoint
*
)
start
end
:
(
AMapNaviPoint
*
)
end
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
[
_walkManager
calculateWalkRouteWithStartPoints
:@[
start
]
endPoints
:@[
end
]];
}];
}
RCT_EXPORT_METHOD
(
start
:
(
nonnull
NSNumber
*
)
reactTag
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
[
_walkManager
startGPSNavi
];
}];
}
-
(
UIView
*
)
view
{
RCT_EXPORT_METHOD
(
calculateRoute
:
(
nonnull
NSNumber
*
)
reactTag
return
_walkView
;
start
:
(
AMapNaviPoint
*
)
start
end
:
(
AMapNaviPoint
*
)
end
way
:
(
NSArray
<
AMapNaviPoint
*>
*
)
way
)
{
[
_navigationManager
calculateWalkRouteWithStartPoints
:@[
start
]
endPoints
:@[
end
]];
}
}
-
(
void
)
walkManagerOnCalculateRouteSuccess
:
(
AMapNaviWalkManager
*
)
walkManager
{
-
(
void
)
walkManagerOnCalculateRouteSuccess
:
(
AMapNaviWalkManager
*
)
walkManager
{
if
(
_
walk
View
.
onCalculateRouteSuccess
)
{
if
(
_
navigation
View
.
onCalculateRouteSuccess
)
{
_
walk
View
.
onCalculateRouteSuccess
(
nil
);
_
navigation
View
.
onCalculateRouteSuccess
(
nil
);
}
}
}
}
-
(
void
)
walkManager
:
(
AMapNaviWalkManager
*
)
walkManager
onCalculateRouteFailure
:
(
NSError
*
)
error
{
-
(
void
)
walkManager
:
(
AMapNaviWalkManager
*
)
walkManager
onCalculateRouteFailure
:
(
NSError
*
)
error
{
if
(
_
walk
View
.
onCalculateRouteFailure
)
{
if
(
_
navigation
View
.
onCalculateRouteFailure
)
{
_
walk
View
.
onCalculateRouteFailure
(@{
_
navigation
View
.
onCalculateRouteFailure
(@{
@"code"
:
@
(
error
.
code
),
@"code"
:
@
(
error
.
code
),
});
});
}
}
}
}
+
(
AMapNaviWalkManager
*
)
walkManager
{
static
AMapNaviWalkManager
*
walkManager
;
if
(
walkManager
==
nil
)
{
walkManager
=
[
AMapNaviWalkManager
new
];
[
walkManager
addDataRepresentative
:[
AMapWalkManager
walkView
]];
}
return
walkManager
;
}
+
(
AMapWalk
*
)
walkView
{
static
AMapWalk
*
walkView
;
if
(
walkView
==
nil
)
{
walkView
=
[
AMapWalk
new
];
}
return
walkView
;
}
@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