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
9a6deb84
Commit
9a6deb84
authored
Jun 09, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加地图动画移动接口
parent
5a6b4ecf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
AMapView.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
+27
-1
AMapViewManager.kt
...src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
+19
-0
MapView.js
components/MapView.js
+22
-1
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
View file @
9a6deb84
...
@@ -2,14 +2,16 @@ package cn.qiuxiang.react.amap3d
...
@@ -2,14 +2,16 @@ package cn.qiuxiang.react.amap3d
import
android.view.View
import
android.view.View
import
com.amap.api.maps.AMap
import
com.amap.api.maps.AMap
import
com.amap.api.maps.CameraUpdateFactory
import
com.amap.api.maps.MapView
import
com.amap.api.maps.MapView
import
com.amap.api.maps.model.LatLng
import
com.amap.api.maps.model.Marker
import
com.amap.api.maps.model.Marker
import
com.amap.api.maps.model.MyLocationStyle
import
com.amap.api.maps.model.MyLocationStyle
import
com.facebook.react.bridge.Arguments
import
com.facebook.react.bridge.Arguments
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.WritableMap
import
com.facebook.react.bridge.WritableMap
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.events.RCTEventEmitter
import
com.facebook.react.uimanager.events.RCTEventEmitter
import
com.facebook.react.views.view.ReactViewGroup
class
AMapView
(
context
:
ThemedReactContext
)
:
MapView
(
context
)
{
class
AMapView
(
context
:
ThemedReactContext
)
:
MapView
(
context
)
{
private
val
eventEmitter
:
RCTEventEmitter
=
context
.
getJSModule
(
RCTEventEmitter
::
class
.
java
)
private
val
eventEmitter
:
RCTEventEmitter
=
context
.
getJSModule
(
RCTEventEmitter
::
class
.
java
)
...
@@ -120,4 +122,28 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
...
@@ -120,4 +122,28 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
}
}
}
}
}
}
val
animateCallback
=
object
:
AMap
.
CancelableCallback
{
override
fun
onCancel
()
{
TODO
(
"not implemented"
)
}
override
fun
onFinish
()
{
TODO
(
"not implemented"
)
}
}
fun
animateToCoordinate
(
args
:
ReadableArray
?)
{
val
coordinate
=
args
?.
getMap
(
0
)
!!
val
duration
=
args
.
getInt
(
1
)
val
cameraUpdate
=
CameraUpdateFactory
.
newLatLng
(
LatLng
(
coordinate
.
getDouble
(
"latitude"
),
coordinate
.
getDouble
(
"longitude"
)))
map
.
animateCamera
(
cameraUpdate
,
duration
.
toLong
(),
animateCallback
)
}
fun
animateToZoomLevel
(
args
:
ReadableArray
?)
{
val
zoomLevel
=
args
?.
getDouble
(
0
)
!!
val
duration
=
args
.
getInt
(
1
)
map
.
animateCamera
(
CameraUpdateFactory
.
zoomTo
(
zoomLevel
.
toFloat
()),
duration
.
toLong
(),
animateCallback
)
}
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
View file @
9a6deb84
...
@@ -4,12 +4,18 @@ import android.view.View
...
@@ -4,12 +4,18 @@ import android.view.View
import
com.amap.api.maps.AMap
import
com.amap.api.maps.AMap
import
com.amap.api.maps.CameraUpdateFactory
import
com.amap.api.maps.CameraUpdateFactory
import
com.amap.api.maps.model.LatLng
import
com.amap.api.maps.model.LatLng
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.annotations.ReactProp
import
com.facebook.react.uimanager.annotations.ReactProp
internal
class
AMapViewManager
:
ViewGroupManager
<
AMapView
>()
{
internal
class
AMapViewManager
:
ViewGroupManager
<
AMapView
>()
{
companion
object
{
val
ANIMATE_TO_COORDINATE
=
1
val
ANIMATE_TO_ZOOM_LEVEL
=
2
}
override
fun
getName
():
String
{
override
fun
getName
():
String
{
return
"AMapView"
return
"AMapView"
}
}
...
@@ -18,6 +24,19 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
...
@@ -18,6 +24,19 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
return
AMapView
(
reactContext
)
return
AMapView
(
reactContext
)
}
}
override
fun
getCommandsMap
():
Map
<
String
,
Int
>
{
return
mapOf
(
"animateToCoordinate"
to
ANIMATE_TO_COORDINATE
,
"animateToZoomLevel"
to
ANIMATE_TO_ZOOM_LEVEL
)
}
override
fun
receiveCommand
(
overlay
:
AMapView
,
commandId
:
Int
,
args
:
ReadableArray
?)
{
when
(
commandId
)
{
ANIMATE_TO_COORDINATE
->
overlay
.
animateToCoordinate
(
args
)
ANIMATE_TO_ZOOM_LEVEL
->
overlay
.
animateToZoomLevel
(
args
)
}
}
override
fun
addView
(
mapView
:
AMapView
,
child
:
View
,
index
:
Int
)
{
override
fun
addView
(
mapView
:
AMapView
,
child
:
View
,
index
:
Int
)
{
super
.
addView
(
mapView
,
child
,
index
)
super
.
addView
(
mapView
,
child
,
index
)
when
(
child
)
{
when
(
child
)
{
...
...
components/MapView.js
View file @
9a6deb84
import
React
,
{
PropTypes
,
Component
}
from
'react'
import
React
,
{
PropTypes
,
Component
}
from
'react'
import
{
requireNativeComponent
,
View
}
from
'react-native'
import
{
requireNativeComponent
,
findNodeHandle
,
View
,
UIManager
,
}
from
'react-native'
import
Marker
from
'./Marker'
import
Marker
from
'./Marker'
import
InfoWindow
from
'./InfoWindow'
import
InfoWindow
from
'./InfoWindow'
import
Overlay
from
'./Overlay'
import
Overlay
from
'./Overlay'
...
@@ -142,6 +147,22 @@ class MapView extends Component {
...
@@ -142,6 +147,22 @@ class MapView extends Component {
onLocation
:
React
.
PropTypes
.
func
,
onLocation
:
React
.
PropTypes
.
func
,
}
}
animateToCoordinate
(
coordinate
,
duration
=
1000
)
{
this
.
_sendCommand
(
'animateToCoordinate'
,
[
coordinate
,
duration
])
}
animateToZoomLevel
(
zoomLevel
,
duration
=
1000
)
{
this
.
_sendCommand
(
'animateToZoomLevel'
,
[
zoomLevel
,
duration
])
}
_sendCommand
(
command
,
params
=
null
)
{
UIManager
.
dispatchViewManagerCommand
(
findNodeHandle
(
this
),
UIManager
.
AMapView
.
Commands
[
command
],
params
,
)
}
render
()
{
render
()
{
return
<
AMapView
{...
this
.
props
}
/
>
return
<
AMapView
{...
this
.
props
}
/
>
}
}
...
...
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