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
c35dece1
Commit
c35dece1
authored
Aug 22, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 android 步行、骑行导航功能
parent
065c2f0e
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
58 deletions
+125
-58
AMap3DPackage.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
+4
-1
AMapDrive.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapDrive.kt
+19
-0
AMapDriveManager.kt
...rc/main/java/cn/qiuxiang/react/amap3d/AMapDriveManager.kt
+13
-0
AMapNavigation.kt
.../src/main/java/cn/qiuxiang/react/amap3d/AMapNavigation.kt
+11
-31
AMapNavigationManager.kt
...in/java/cn/qiuxiang/react/amap3d/AMapNavigationManager.kt
+10
-24
AMapRide.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapRide.kt
+16
-0
AMapRideManager.kt
...src/main/java/cn/qiuxiang/react/amap3d/AMapRideManager.kt
+14
-0
AMapWalk.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapWalk.kt
+16
-0
AMapWalkManager.kt
...src/main/java/cn/qiuxiang/react/amap3d/AMapWalkManager.kt
+14
-0
navigation.js
example/src/examples/navigation.js
+8
-2
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
View file @
c35dece1
...
...
@@ -18,6 +18,9 @@ class AMap3DPackage : ReactPackage {
AMapPolylineManager
(),
AMapPolygonManager
(),
AMapCircleManager
(),
AMapNavigationManager
())
AMapDriveManager
(),
AMapWalkManager
(),
AMapRideManager
()
)
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapDrive.kt
0 → 100644
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
android.annotation.SuppressLint
import
com.amap.api.navi.enums.PathPlanningStrategy
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.ThemedReactContext
@SuppressLint
(
"ViewConstructor"
)
class
AMapDrive
(
context
:
ThemedReactContext
)
:
AMapNavigation
(
context
)
{
override
fun
calculateRoute
(
args
:
ReadableArray
?)
{
val
points
=
args
?.
getArray
(
2
)
!!
navigation
.
calculateDriveRoute
(
listOf
(
latLngFromReadableMap
(
args
.
getMap
(
0
))),
listOf
(
latLngFromReadableMap
(
args
.
getMap
(
1
))),
(
0
until
points
.
size
()).
map
{
latLngFromReadableMap
(
points
.
getMap
(
it
))
},
PathPlanningStrategy
.
DRIVING_DEFAULT
)
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapDriveManager.kt
0 → 100644
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
com.facebook.react.uimanager.ThemedReactContext
class
AMapDriveManager
:
AMapNavigationManager
<
AMapDrive
>()
{
override
fun
getName
():
String
{
return
"AMapDrive"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMapDrive
{
return
AMapDrive
(
reactContext
)
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapNavigation.kt
View file @
c35dece1
@file
:
Suppress
(
"OverridingDeprecatedMember"
,
"DEPRECATION"
,
"LeakingThis"
)
package
cn.qiuxiang.react.amap3d
import
android.annotation.SuppressLint
import
com.amap.api.navi.AMapNavi
import
com.amap.api.navi.AMapNaviListener
import
com.amap.api.navi.AMapNaviView
import
com.amap.api.navi.AMapNaviViewListener
import
com.amap.api.navi.enums.NaviType
import
com.amap.api.navi.enums.PathPlanningStrategy
import
com.amap.api.navi.model.*
import
com.autonavi.tbt.TrafficFacilityInfo
import
com.facebook.react.bridge.Arguments
...
...
@@ -16,11 +16,12 @@ import com.facebook.react.bridge.WritableMap
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.events.RCTEventEmitter
@SuppressLint
(
"ViewConstructor"
)
class
AMapNavigation
(
context
:
ThemedReactContext
)
:
abstract
class
AMapNavigation
(
context
:
ThemedReactContext
)
:
AMapNaviView
(
context
.
currentActivity
),
AMapNaviViewListener
,
AMapNaviListener
{
val
eventEmitter
:
RCTEventEmitter
=
context
.
getJSModule
(
RCTEventEmitter
::
class
.
java
)
val
navigation
=
AMapNavi
.
getInstance
(
context
)
!!
private
val
eventEmitter
:
RCTEventEmitter
=
context
.
getJSModule
(
RCTEventEmitter
::
class
.
java
)
protected
val
navigation
=
AMapNavi
.
getInstance
(
context
)
!!
abstract
fun
calculateRoute
(
args
:
ReadableArray
?)
init
{
super
.
onCreate
(
null
)
...
...
@@ -28,36 +29,15 @@ class AMapNavigation(context: ThemedReactContext) :
navigation
.
addAMapNaviListener
(
this
)
}
fun
calculateWalkRoute
(
args
:
ReadableArray
?)
{
navigation
.
calculateWalkRoute
(
latLngFromReadableMap
(
args
?.
getMap
(
0
)
!!
),
latLngFromReadableMap
(
args
.
getMap
(
1
)))
}
fun
calculateRideRoute
(
args
:
ReadableArray
?)
{
navigation
.
calculateRideRoute
(
latLngFromReadableMap
(
args
?.
getMap
(
0
)
!!
),
latLngFromReadableMap
(
args
.
getMap
(
1
)))
}
fun
calculateDriveRoute
(
args
:
ReadableArray
?)
{
navigation
.
calculateDriveRoute
(
listOf
(
latLngFromReadableMap
(
args
?.
getMap
(
0
)
!!
)),
listOf
(
latLngFromReadableMap
(
args
.
getMap
(
1
))),
listOf
(),
PathPlanningStrategy
.
DRIVING_DEFAULT
)
}
fun
start
()
{
navigation
.
startNavi
(
NaviType
.
GPS
)
}
fun
latLngFromReadableMap
(
map
:
ReadableMap
):
NaviLatLng
{
protected
fun
latLngFromReadableMap
(
map
:
ReadableMap
):
NaviLatLng
{
return
NaviLatLng
(
map
.
getDouble
(
"latitude"
),
map
.
getDouble
(
"longitude"
))
}
fun
sendEvent
(
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
private
fun
sendEvent
(
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
eventEmitter
.
receiveEvent
(
id
,
name
,
data
)
}
...
...
@@ -65,9 +45,9 @@ class AMapNavigation(context: ThemedReactContext) :
sendEvent
(
"onCalculateRouteSuccess"
)
}
override
fun
onCalculateRouteFailure
(
errorC
ode
:
Int
)
{
override
fun
onCalculateRouteFailure
(
c
ode
:
Int
)
{
val
event
=
Arguments
.
createMap
()
event
.
putInt
(
"
errorCode"
,
errorC
ode
)
event
.
putInt
(
"
code"
,
c
ode
)
sendEvent
(
"onCalculateRouteFailure"
,
event
)
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapNavigationManager.kt
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.
uimanager.ThemedReactContext
import
com.facebook.react.
common.MapBuilder
import
com.facebook.react.uimanager.ViewGroupManager
class
AMapNavigationManager
:
ViewGroupManager
<
AMapNavigation
>()
{
override
fun
getName
():
String
{
return
"AMapNavigation"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMapNavigation
{
return
AMapNavigation
(
reactContext
)
}
override
fun
onDropViewInstance
(
view
:
AMapNavigation
)
{
abstract
class
AMapNavigationManager
<
T
:
AMapNavigation
>
:
ViewGroupManager
<
T
>()
{
override
fun
onDropViewInstance
(
view
:
T
)
{
super
.
onDropViewInstance
(
view
)
view
.
onDestroy
()
}
companion
object
{
val
START
=
1
val
CALCULATE_WALK_ROUTE
=
2
val
CALCULATE_RIDE_ROUTE
=
3
val
CALCULATE_DRIVE_ROUTE
=
4
val
CALCULATE_ROUTE
=
2
}
override
fun
getCommandsMap
():
Map
<
String
,
Int
>
{
return
mapOf
(
"start"
to
START
,
"calculateWalkRoute"
to
CALCULATE_WALK_ROUTE
,
"calculateRideRoute"
to
CALCULATE_RIDE_ROUTE
,
"calculateDriveRoute"
to
CALCULATE_DRIVE_ROUTE
"calculateRoute"
to
CALCULATE_ROUTE
)
}
override
fun
receiveCommand
(
view
:
AMapNavigation
,
commandId
:
Int
,
args
:
ReadableArray
?)
{
override
fun
receiveCommand
(
view
:
T
,
commandId
:
Int
,
args
:
ReadableArray
?)
{
when
(
commandId
)
{
START
->
view
.
start
()
CALCULATE_WALK_ROUTE
->
view
.
calculateWalkRoute
(
args
)
CALCULATE_RIDE_ROUTE
->
view
.
calculateRideRoute
(
args
)
CALCULATE_DRIVE_ROUTE
->
view
.
calculateDriveRoute
(
args
)
CALCULATE_ROUTE
->
view
.
calculateRoute
(
args
)
}
}
override
fun
getExportedCustomDirectEventTypeConstants
():
Map
<
String
,
Any
>
{
return
mapO
f
(
"onCalculateRouteSuccess"
to
mapOf
(
"registrationName"
to
"onCalculateRouteSuccess"
),
"onCalculateRouteFailure"
to
mapOf
(
"registrationName"
to
"onCalculateRouteFailure"
)
return
MapBuilder
.
o
f
(
"onCalculateRouteSuccess"
,
MapBuilder
.
of
(
"registrationName"
,
"onCalculateRouteSuccess"
),
"onCalculateRouteFailure"
,
MapBuilder
.
of
(
"registrationName"
,
"onCalculateRouteFailure"
)
)
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapRide.kt
0 → 100644
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
android.annotation.SuppressLint
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.ThemedReactContext
@SuppressLint
(
"ViewConstructor"
)
class
AMapRide
(
context
:
ThemedReactContext
)
:
AMapNavigation
(
context
)
{
override
fun
calculateRoute
(
args
:
ReadableArray
?)
{
navigation
.
calculateRideRoute
(
latLngFromReadableMap
(
args
?.
getMap
(
0
)
!!
),
latLngFromReadableMap
(
args
.
getMap
(
1
))
)
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/AMapRideManager.kt
0 → 100644
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
com.facebook.react.uimanager.ThemedReactContext
class
AMapRideManager
:
AMapNavigationManager
<
AMapRide
>()
{
override
fun
getName
():
String
{
return
"AMapRide"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMapRide
{
return
AMapRide
(
reactContext
)
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/AMapWalk.kt
0 → 100644
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
android.annotation.SuppressLint
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.ThemedReactContext
@SuppressLint
(
"ViewConstructor"
)
class
AMapWalk
(
context
:
ThemedReactContext
)
:
AMapNavigation
(
context
)
{
override
fun
calculateRoute
(
args
:
ReadableArray
?)
{
navigation
.
calculateWalkRoute
(
latLngFromReadableMap
(
args
?.
getMap
(
0
)
!!
),
latLngFromReadableMap
(
args
.
getMap
(
1
))
)
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/AMapWalkManager.kt
0 → 100644
View file @
c35dece1
package
cn.qiuxiang.react.amap3d
import
com.facebook.react.uimanager.ThemedReactContext
class
AMapWalkManager
:
AMapNavigationManager
<
AMapWalk
>()
{
override
fun
getName
():
String
{
return
"AMapWalk"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMapWalk
{
return
AMapWalk
(
reactContext
)
}
}
\ No newline at end of file
example/src/examples/navigation.js
View file @
c35dece1
...
...
@@ -16,11 +16,17 @@ export default class NavigationExample extends Component {
{
latitude
:
39.806901
,
longitude
:
116.397972
,
}
},
[
{
latitude
:
39.866901
,
longitude
:
116.407972
,
},
]
)
}
_start
=
()
=>
{}
_start
=
()
=>
this
.
_navigation
.
start
()
render
()
{
return
<
Drive
...
...
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