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
4f47386b
Commit
4f47386b
authored
Aug 22, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化事件传递
parent
c35dece1
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
224 additions
and
46 deletions
+224
-46
AMapMarkerManager.kt
...c/main/java/cn/qiuxiang/react/amap3d/AMapMarkerManager.kt
+8
-6
AMapPolylineManager.kt
...main/java/cn/qiuxiang/react/amap3d/AMapPolylineManager.kt
+1
-1
AMapView.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
+12
-12
AMapViewManager.kt
...src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
+10
-8
Drive.js
components/Drive.js
+58
-0
Marker.js
components/Marker.js
+3
-12
Polyline.js
components/Polyline.js
+2
-5
Ride.js
components/Ride.js
+58
-0
Walk.js
components/Walk.js
+58
-0
index.js
index.js
+14
-2
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapMarkerManager.kt
View file @
4f47386b
...
...
@@ -3,6 +3,7 @@ package cn.qiuxiang.react.amap3d
import
android.view.View
import
com.amap.api.maps.model.LatLng
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.common.MapBuilder
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.annotations.ReactProp
...
...
@@ -27,12 +28,13 @@ internal class AMapMarkerManager : ViewGroupManager<AMapMarker>() {
}
override
fun
getExportedCustomDirectEventTypeConstants
():
Map
<
String
,
Any
>?
{
return
mapOf
(
"onMarkerClick"
to
mapOf
(
"registrationName"
to
"onMarkerClick"
),
"onMarkerDragStart"
to
mapOf
(
"registrationName"
to
"onDragStart"
),
"onMarkerDrag"
to
mapOf
(
"registrationName"
to
"onDrag"
),
"onMarkerDragEnd"
to
mapOf
(
"registrationName"
to
"onDragEnd"
),
"onInfoWindowClick"
to
mapOf
(
"registrationName"
to
"onInfoWindowPress"
))
return
MapBuilder
.
of
(
"onPress"
,
MapBuilder
.
of
(
"registrationName"
,
"onPress"
),
"onDragStart"
,
MapBuilder
.
of
(
"registrationName"
,
"onDragStart"
),
"onDrag"
,
MapBuilder
.
of
(
"registrationName"
,
"onDrag"
),
"onDragEnd"
,
MapBuilder
.
of
(
"registrationName"
,
"onDragEnd"
),
"onInfoWindowPress"
,
MapBuilder
.
of
(
"registrationName"
,
"onInfoWindowPress"
)
)
}
@ReactProp
(
name
=
"title"
)
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapPolylineManager.kt
View file @
4f47386b
...
...
@@ -16,7 +16,7 @@ internal class AMapPolylineManager : ViewGroupManager<AMapPolyline>() {
}
override
fun
getExportedCustomDirectEventTypeConstants
():
Map
<
String
,
Any
>
{
return
mapOf
(
"onP
olylineClick"
to
mapOf
(
"registrationName"
to
"onPolylineClick
"
))
return
mapOf
(
"onP
ress"
to
mapOf
(
"registrationName"
to
"onPress
"
))
}
@ReactProp
(
name
=
"coordinates"
)
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
View file @
4f47386b
...
...
@@ -37,14 +37,14 @@ class AMapView(context: Context) : TextureMapView(context) {
val
event
=
Arguments
.
createMap
()
event
.
putDouble
(
"latitude"
,
latLng
.
latitude
)
event
.
putDouble
(
"longitude"
,
latLng
.
longitude
)
emit
(
id
,
"on
MapClick
"
,
event
)
emit
(
id
,
"on
Press
"
,
event
)
}
map
.
setOnMapLongClickListener
{
latLng
->
val
event
=
Arguments
.
createMap
()
event
.
putDouble
(
"latitude"
,
latLng
.
latitude
)
event
.
putDouble
(
"longitude"
,
latLng
.
longitude
)
emit
(
id
,
"on
MapLongClick
"
,
event
)
emit
(
id
,
"on
LongPress
"
,
event
)
}
map
.
setOnMyLocationChangeListener
{
location
->
...
...
@@ -52,21 +52,21 @@ class AMapView(context: Context) : TextureMapView(context) {
event
.
putDouble
(
"latitude"
,
location
.
latitude
)
event
.
putDouble
(
"longitude"
,
location
.
longitude
)
event
.
putDouble
(
"accuracy"
,
location
.
accuracy
.
toDouble
())
emit
(
id
,
"onLocation
Change
"
,
event
)
emit
(
id
,
"onLocation"
,
event
)
}
map
.
setOnMarkerClickListener
{
marker
->
emit
(
markers
[
marker
.
id
]
?.
id
,
"on
MarkerClick
"
)
emit
(
markers
[
marker
.
id
]
?.
id
,
"on
Press
"
)
false
}
map
.
setOnMarkerDragListener
(
object
:
AMap
.
OnMarkerDragListener
{
override
fun
onMarkerDragStart
(
marker
:
Marker
)
{
emit
(
markers
[
marker
.
id
]
?.
id
,
"on
Marker
DragStart"
)
emit
(
markers
[
marker
.
id
]
?.
id
,
"onDragStart"
)
}
override
fun
onMarkerDrag
(
marker
:
Marker
)
{
emit
(
markers
[
marker
.
id
]
?.
id
,
"on
Marker
Drag"
)
emit
(
markers
[
marker
.
id
]
?.
id
,
"onDrag"
)
}
override
fun
onMarkerDragEnd
(
marker
:
Marker
)
{
...
...
@@ -74,26 +74,26 @@ class AMapView(context: Context) : TextureMapView(context) {
val
data
=
Arguments
.
createMap
()
data
.
putDouble
(
"latitude"
,
position
.
latitude
)
data
.
putDouble
(
"longitude"
,
position
.
longitude
)
emit
(
markers
[
marker
.
id
]
?.
id
,
"on
Marker
DragEnd"
,
data
)
emit
(
markers
[
marker
.
id
]
?.
id
,
"onDragEnd"
,
data
)
}
})
map
.
setOnCameraChangeListener
(
object
:
AMap
.
OnCameraChangeListener
{
override
fun
onCameraChangeFinish
(
position
:
CameraPosition
?)
{
emitCameraChangeEvent
(
"on
CameraChangeFinish
"
,
position
)
emitCameraChangeEvent
(
"on
StatusChangeComplete
"
,
position
)
}
override
fun
onCameraChange
(
position
:
CameraPosition
?)
{
emitCameraChangeEvent
(
"on
Camera
Change"
,
position
)
emitCameraChangeEvent
(
"on
Status
Change"
,
position
)
}
})
map
.
setOnInfoWindowClickListener
{
marker
->
emit
(
markers
[
marker
.
id
]
?.
id
,
"onInfoWindow
Click
"
)
emit
(
markers
[
marker
.
id
]
?.
id
,
"onInfoWindow
Press
"
)
}
map
.
setOnPolylineClickListener
{
polyline
->
emit
(
polylines
[
polyline
.
id
]
?.
id
,
"onP
olylineClick
"
)
emit
(
polylines
[
polyline
.
id
]
?.
id
,
"onP
ress
"
)
}
map
.
setInfoWindowAdapter
(
AMapInfoWindowAdapter
(
context
,
markers
))
...
...
@@ -113,7 +113,7 @@ class AMapView(context: Context) : TextureMapView(context) {
data
.
putDouble
(
"rotation"
,
it
.
bearing
.
toDouble
())
data
.
putDouble
(
"latitude"
,
it
.
target
.
latitude
)
data
.
putDouble
(
"longitude"
,
it
.
target
.
longitude
)
if
(
event
==
"on
CameraChangeFinish
"
)
{
if
(
event
==
"on
StatusChangeComplete
"
)
{
val
southwest
=
map
.
projection
.
visibleRegion
.
latLngBounds
.
southwest
val
northeast
=
map
.
projection
.
visibleRegion
.
latLngBounds
.
northeast
data
.
putDouble
(
"latitudeDelta"
,
Math
.
abs
(
southwest
.
latitude
-
northeast
.
latitude
))
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
View file @
4f47386b
...
...
@@ -6,6 +6,7 @@ import com.amap.api.maps.CameraUpdateFactory
import
com.amap.api.maps.model.LatLng
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.common.MapBuilder
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.annotations.ReactProp
...
...
@@ -50,14 +51,15 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
}
override
fun
getExportedCustomDirectEventTypeConstants
():
Map
<
String
,
Any
>
{
return
mapOf
(
"onMapClick"
to
mapOf
(
"registrationName"
to
"onPress"
),
"onMapLongClick"
to
mapOf
(
"registrationName"
to
"onLongPress"
),
"onAnimateCancel"
to
mapOf
(
"registrationName"
to
"onAnimateCancel"
),
"onAnimateFinish"
to
mapOf
(
"registrationName"
to
"onAnimateFinish"
),
"onCameraChange"
to
mapOf
(
"registrationName"
to
"onStatusChange"
),
"onCameraChangeFinish"
to
mapOf
(
"registrationName"
to
"onStatusChangeComplete"
),
"onLocationChange"
to
mapOf
(
"registrationName"
to
"onLocation"
))
return
MapBuilder
.
of
(
"onPress"
,
MapBuilder
.
of
(
"registrationName"
,
"onPress"
),
"onLongPress"
,
MapBuilder
.
of
(
"registrationName"
,
"onLongPress"
),
"onAnimateCancel"
,
MapBuilder
.
of
(
"registrationName"
,
"onAnimateCancel"
),
"onAnimateFinish"
,
MapBuilder
.
of
(
"registrationName"
,
"onAnimateFinish"
),
"onStatusChange"
,
MapBuilder
.
of
(
"registrationName"
,
"onStatusChange"
),
"onStatusChangeComplete"
,
MapBuilder
.
of
(
"registrationName"
,
"onStatusChangeComplete"
),
"onLocation"
,
MapBuilder
.
of
(
"registrationName"
,
"onLocation"
)
)
}
@ReactProp
(
name
=
"locationEnabled"
)
...
...
components/Drive.js
0 → 100644
View file @
4f47386b
// @flow
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
ViewPropTypes
,
UIManager
,
requireNativeComponent
,
findNodeHandle
,
}
from
'react-native'
import
{
LatLng
}
from
'./PropTypes'
export
default
class
Drive
extends
PureComponent
{
static
propTypes
=
{
...
ViewPropTypes
,
/**
* 路径规划成功事件
*/
onCalculateRouteSuccess
:
React
.
PropTypes
.
func
,
/**
* 路径规划失败事件
*/
onCalculateRouteFailure
:
React
.
PropTypes
.
func
,
}
/**
* 路线规划
*/
calculateRoute
(
start
,
end
,
way
=
[])
{
this
.
_sendCommand
(
'calculateRoute'
,
[
start
,
end
,
way
])
}
/**
* 开始导航
*/
start
()
{
this
.
_sendCommand
(
'start'
)
}
/**
* call native method
*
* @private
*/
_sendCommand
(
command
:
string
,
params
?:
[])
{
UIManager
.
dispatchViewManagerCommand
(
findNodeHandle
(
this
),
UIManager
.
AMapDrive
.
Commands
[
command
],
params
,
)
}
render
()
{
return
<
AMapDrive
{...
this
.
props
}
/
>
}
}
const
AMapDrive
=
requireNativeComponent
(
'AMapDrive'
,
Drive
)
components/Marker.js
View file @
4f47386b
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
Platform
,
requireNativeComponent
,
StyleSheet
,
View
,
ViewPropTypes
,
Platform
,
StyleSheet
,
}
from
'react-native'
import
{
LatLng
}
from
'./PropTypes'
import
Overlay
from
'./Overlay'
...
...
@@ -116,17 +116,8 @@ export default class Marker extends PureComponent {
onInfoWindowPress
:
React
.
PropTypes
.
func
,
}
_onPress
=
event
=>
this
.
props
.
onPress
&&
this
.
props
.
onPress
(
event
)
render
()
{
const
props
=
{
...
this
.
props
,
...
Platform
.
select
({
android
:
{
onMarkerClick
:
this
.
_onPress
,
},
})
}
const
props
=
{...
this
.
props
}
let
customInfoWindow
=
<
View
collapsable
=
{
false
}
/
>
let
customMarker
=
<
View
collapsable
=
{
false
}
/
>
...
...
components/Polyline.js
View file @
4f47386b
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
PixelRatio
,
Platform
,
processColor
,
requireNativeComponent
,
ViewPropTypes
,
PixelRatio
,
Platform
,
}
from
'react-native'
import
{
LatLng
}
from
'./PropTypes'
...
...
@@ -65,8 +65,6 @@ export default class Polyline extends PureComponent {
colors
:
[],
}
_onPress
=
event
=>
this
.
props
.
onPress
&&
this
.
props
.
onPress
(
event
)
render
()
{
const
props
=
{
...
this
.
props
,
...
...
@@ -76,7 +74,6 @@ export default class Polyline extends PureComponent {
colors
:
this
.
props
.
colors
.
map
(
processColor
),
},
}),
onPolylineClick
:
this
.
_onPress
,
}
return
<
AMapPolyline
{...
props
}
/
>
}
...
...
components/Ride.js
0 → 100644
View file @
4f47386b
// @flow
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
ViewPropTypes
,
UIManager
,
requireNativeComponent
,
findNodeHandle
,
}
from
'react-native'
import
{
LatLng
}
from
'./PropTypes'
export
default
class
Ride
extends
PureComponent
{
static
propTypes
=
{
...
ViewPropTypes
,
/**
* 路径规划成功事件
*/
onCalculateRouteSuccess
:
React
.
PropTypes
.
func
,
/**
* 路径规划失败事件
*/
onCalculateRouteFailure
:
React
.
PropTypes
.
func
,
}
/**
* 路线规划
*/
calculateRoute
(
start
,
end
)
{
this
.
_sendCommand
(
'calculateRoute'
,
[
start
,
end
])
}
/**
* 开始导航
*/
start
()
{
this
.
_sendCommand
(
'start'
)
}
/**
* call native method
*
* @private
*/
_sendCommand
(
command
:
string
,
params
?:
[])
{
UIManager
.
dispatchViewManagerCommand
(
findNodeHandle
(
this
),
UIManager
.
AMapRide
.
Commands
[
command
],
params
,
)
}
render
()
{
return
<
AMapRide
{...
this
.
props
}
/
>
}
}
const
AMapRide
=
requireNativeComponent
(
'AMapRide'
,
Ride
)
components/Walk.js
0 → 100644
View file @
4f47386b
// @flow
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
ViewPropTypes
,
UIManager
,
requireNativeComponent
,
findNodeHandle
,
}
from
'react-native'
import
{
LatLng
}
from
'./PropTypes'
export
default
class
Walk
extends
PureComponent
{
static
propTypes
=
{
...
ViewPropTypes
,
/**
* 路径规划成功事件
*/
onCalculateRouteSuccess
:
React
.
PropTypes
.
func
,
/**
* 路径规划失败事件
*/
onCalculateRouteFailure
:
React
.
PropTypes
.
func
,
}
/**
* 路线规划
*/
calculateRoute
(
start
,
end
)
{
this
.
_sendCommand
(
'calculateRoute'
,
[
start
,
end
])
}
/**
* 开始导航
*/
start
()
{
this
.
_sendCommand
(
'start'
)
}
/**
* call native method
*
* @private
*/
_sendCommand
(
command
:
string
,
params
?:
[])
{
UIManager
.
dispatchViewManagerCommand
(
findNodeHandle
(
this
),
UIManager
.
AMapWalk
.
Commands
[
command
],
params
,
)
}
render
()
{
return
<
AMapWalk
{...
this
.
props
}
/
>
}
}
const
AMapWalk
=
requireNativeComponent
(
'AMapWalk'
,
Walk
)
index.js
View file @
4f47386b
...
...
@@ -3,6 +3,9 @@ import Marker from './components/Marker'
import
Polyline
from
'./components/Polyline'
import
Polygon
from
'./components/Polygon'
import
Circle
from
'./components/Circle'
import
Drive
from
'./components/Drive'
import
Walk
from
'./components/Walk'
import
Ride
from
'./components/Ride'
import
MapUtils
from
'./components/Utils'
MapView
.
Marker
=
Marker
...
...
@@ -11,5 +14,14 @@ MapView.Polygon = Polygon
MapView
.
Circle
=
Circle
export
default
MapView
export
{
MapView
,
Marker
,
Polyline
,
Polygon
,
Circle
,
MapUtils
}
export
{
MapView
,
Marker
,
Polyline
,
Polygon
,
Circle
,
Drive
,
Walk
,
Ride
,
MapUtils
,
}
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