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
a1ccfbfa
Commit
a1ccfbfa
authored
Aug 29, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构 Overlay 关系及管理
parent
3c201a52
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
73 additions
and
84 deletions
+73
-84
AMap3DPackage.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
+1
-1
AMapCircle.kt
...src/main/java/cn/qiuxiang/react/amap3d/maps/AMapCircle.kt
+7
-4
AMapHeatMap.kt
...rc/main/java/cn/qiuxiang/react/amap3d/maps/AMapHeatMap.kt
+9
-6
AMapHeatMapManager.kt
.../java/cn/qiuxiang/react/amap3d/maps/AMapHeatMapManager.kt
+0
-1
AMapMarker.kt
...src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMarker.kt
+7
-3
AMapMarkerIcon.kt
...main/java/cn/qiuxiang/react/amap3d/maps/AMapMarkerIcon.kt
+6
-0
AMapMarkerIconManager.kt
...va/cn/qiuxiang/react/amap3d/maps/AMapMarkerIconManager.kt
+3
-3
AMapMarkerManager.kt
...n/java/cn/qiuxiang/react/amap3d/maps/AMapMarkerManager.kt
+1
-1
AMapOverlay.kt
...rc/main/java/cn/qiuxiang/react/amap3d/maps/AMapOverlay.kt
+5
-3
AMapPolygon.kt
...rc/main/java/cn/qiuxiang/react/amap3d/maps/AMapPolygon.kt
+8
-6
AMapPolyline.kt
...c/main/java/cn/qiuxiang/react/amap3d/maps/AMapPolyline.kt
+10
-6
AMapView.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapView.kt
+15
-42
AMapViewManager.kt
...ain/java/cn/qiuxiang/react/amap3d/maps/AMapViewManager.kt
+1
-8
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
View file @
a1ccfbfa
...
@@ -19,7 +19,7 @@ class AMap3DPackage : ReactPackage {
...
@@ -19,7 +19,7 @@ class AMap3DPackage : ReactPackage {
AMapViewManager
(),
AMapViewManager
(),
AMapMarkerManager
(),
AMapMarkerManager
(),
AMapInfoWindowManager
(),
AMapInfoWindowManager
(),
AMap
Overlay
Manager
(),
AMap
MarkerIcon
Manager
(),
AMapPolylineManager
(),
AMapPolylineManager
(),
AMapPolygonManager
(),
AMapPolygonManager
(),
AMapCircleManager
(),
AMapCircleManager
(),
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapCircle.kt
View file @
a1ccfbfa
...
@@ -8,9 +8,8 @@ import com.amap.api.maps.model.Circle
...
@@ -8,9 +8,8 @@ import com.amap.api.maps.model.Circle
import
com.amap.api.maps.model.CircleOptions
import
com.amap.api.maps.model.CircleOptions
import
com.facebook.react.views.view.ReactViewGroup
import
com.facebook.react.views.view.ReactViewGroup
class
AMapCircle
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapCircle
(
context
:
Context
)
:
ReactViewGroup
(
context
),
AMapOverlay
{
var
circle
:
Circle
?
=
null
private
var
circle
:
Circle
?
=
null
private
set
var
center
:
LatLng
?
=
null
var
center
:
LatLng
?
=
null
set
(
value
)
{
set
(
value
)
{
...
@@ -48,7 +47,7 @@ class AMapCircle(context: Context) : ReactViewGroup(context) {
...
@@ -48,7 +47,7 @@ class AMapCircle(context: Context) : ReactViewGroup(context) {
circle
?.
zIndex
=
value
circle
?.
zIndex
=
value
}
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
circle
=
map
.
addCircle
(
CircleOptions
()
circle
=
map
.
addCircle
(
CircleOptions
()
.
center
(
center
)
.
center
(
center
)
.
radius
(
radius
)
.
radius
(
radius
)
...
@@ -57,4 +56,8 @@ class AMapCircle(context: Context) : ReactViewGroup(context) {
...
@@ -57,4 +56,8 @@ class AMapCircle(context: Context) : ReactViewGroup(context) {
.
fillColor
(
fillColor
)
.
fillColor
(
fillColor
)
.
zIndex
(
zIndex
))
.
zIndex
(
zIndex
))
}
}
override
fun
remove
()
{
circle
?.
remove
()
}
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapHeatMap.kt
View file @
a1ccfbfa
...
@@ -9,22 +9,20 @@ import com.amap.api.maps.model.TileOverlayOptions
...
@@ -9,22 +9,20 @@ import com.amap.api.maps.model.TileOverlayOptions
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
import
com.facebook.react.views.view.ReactViewGroup
class
AMapHeatMap
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapHeatMap
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
var
overlay
:
TileOverlay
?
=
null
private
var
overlay
:
TileOverlay
?
=
null
private
set
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
var
opacity
:
Double
=
0.6
var
opacity
:
Double
=
0.6
var
radius
:
Int
=
12
var
radius
:
Int
=
12
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
.
map
{
coordinates
.
getMap
(
it
)
}
.
map
{
coordinates
.
getMap
(
it
)
}
.
map
{
LatLng
(
it
.
getDouble
(
"latitude"
),
it
.
getDouble
(
"longitude"
))
})
.
map
{
LatLng
(
it
.
getDouble
(
"latitude"
),
it
.
getDouble
(
"longitude"
))
})
}
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
overlay
=
map
.
addTileOverlay
(
TileOverlayOptions
().
tileProvider
(
overlay
=
map
.
addTileOverlay
(
TileOverlayOptions
().
tileProvider
(
HeatmapTileProvider
.
Builder
()
HeatmapTileProvider
.
Builder
()
.
data
(
coordinates
)
.
data
(
coordinates
)
...
@@ -32,4 +30,8 @@ class AMapHeatMap(context: Context) : ReactViewGroup(context) {
...
@@ -32,4 +30,8 @@ class AMapHeatMap(context: Context) : ReactViewGroup(context) {
.
transparency
(
opacity
)
.
transparency
(
opacity
)
.
build
()))
.
build
()))
}
}
override
fun
remove
()
{
overlay
?.
remove
()
}
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapHeatMapManager.kt
View file @
a1ccfbfa
...
@@ -3,7 +3,6 @@ package cn.qiuxiang.react.amap3d.maps
...
@@ -3,7 +3,6 @@ package cn.qiuxiang.react.amap3d.maps
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.annotations.ReactProp
import
com.facebook.react.uimanager.annotations.ReactProp
@Suppress
(
"unused"
)
@Suppress
(
"unused"
)
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMarker.kt
View file @
a1ccfbfa
...
@@ -7,7 +7,7 @@ import com.amap.api.maps.AMap
...
@@ -7,7 +7,7 @@ import com.amap.api.maps.AMap
import
com.amap.api.maps.model.*
import
com.amap.api.maps.model.*
import
com.facebook.react.views.view.ReactViewGroup
import
com.facebook.react.views.view.ReactViewGroup
class
AMapMarker
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapMarker
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
companion
object
{
companion
object
{
private
val
COLORS
=
mapOf
(
private
val
COLORS
=
mapOf
(
"AZURE"
to
BitmapDescriptorFactory
.
HUE_AZURE
,
"AZURE"
to
BitmapDescriptorFactory
.
HUE_AZURE
,
...
@@ -92,7 +92,7 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
...
@@ -92,7 +92,7 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
}
}
}
}
var
customIcon
:
AMap
Overlay
?
=
null
var
customIcon
:
AMap
MarkerIcon
?
=
null
set
(
value
)
{
set
(
value
)
{
field
=
value
field
=
value
value
?.
addOnLayoutChangeListener
{
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
->
updateCustomIcon
()
}
value
?.
addOnLayoutChangeListener
{
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
->
updateCustomIcon
()
}
...
@@ -100,7 +100,7 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
...
@@ -100,7 +100,7 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
private
var
bitmapDescriptor
:
BitmapDescriptor
?
=
null
private
var
bitmapDescriptor
:
BitmapDescriptor
?
=
null
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
marker
=
map
.
addMarker
(
MarkerOptions
()
marker
=
map
.
addMarker
(
MarkerOptions
()
.
setFlat
(
flat
)
.
setFlat
(
flat
)
.
icon
(
bitmapDescriptor
)
.
icon
(
bitmapDescriptor
)
...
@@ -121,6 +121,10 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
...
@@ -121,6 +121,10 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
marker
?.
isClickable
=
this
.
clickable_
marker
?.
isClickable
=
this
.
clickable_
}
}
override
fun
remove
()
{
marker
?.
destroy
()
}
fun
setIconColor
(
icon
:
String
)
{
fun
setIconColor
(
icon
:
String
)
{
bitmapDescriptor
=
COLORS
[
icon
.
toUpperCase
()]
?.
let
{
bitmapDescriptor
=
COLORS
[
icon
.
toUpperCase
()]
?.
let
{
BitmapDescriptorFactory
.
defaultMarker
(
it
)
BitmapDescriptorFactory
.
defaultMarker
(
it
)
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMarkerIcon.kt
0 → 100644
View file @
a1ccfbfa
package
cn.qiuxiang.react.amap3d.maps
import
android.content.Context
import
com.facebook.react.views.view.ReactViewGroup
class
AMapMarkerIcon
(
context
:
Context
)
:
ReactViewGroup
(
context
)
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMap
Overlay
Manager.kt
→
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMap
MarkerIcon
Manager.kt
View file @
a1ccfbfa
...
@@ -3,12 +3,12 @@ package cn.qiuxiang.react.amap3d.maps
...
@@ -3,12 +3,12 @@ package cn.qiuxiang.react.amap3d.maps
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.ViewGroupManager
class
AMap
OverlayManager
:
ViewGroupManager
<
AMapOverlay
>()
{
class
AMap
MarkerIconManager
:
ViewGroupManager
<
AMapMarkerIcon
>()
{
override
fun
getName
():
String
{
override
fun
getName
():
String
{
return
"AMapOverlay"
return
"AMapOverlay"
}
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMap
Overlay
{
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMap
MarkerIcon
{
return
AMap
Overlay
(
reactContext
)
return
AMap
MarkerIcon
(
reactContext
)
}
}
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMarkerManager.kt
View file @
a1ccfbfa
...
@@ -21,7 +21,7 @@ internal class AMapMarkerManager : ViewGroupManager<AMapMarker>() {
...
@@ -21,7 +21,7 @@ internal class AMapMarkerManager : ViewGroupManager<AMapMarker>() {
override
fun
addView
(
marker
:
AMapMarker
,
view
:
View
,
index
:
Int
)
{
override
fun
addView
(
marker
:
AMapMarker
,
view
:
View
,
index
:
Int
)
{
when
(
view
)
{
when
(
view
)
{
is
AMap
Overlay
->
marker
.
customIcon
=
view
is
AMap
MarkerIcon
->
marker
.
customIcon
=
view
is
AMapInfoWindow
->
marker
.
infoWindow
=
view
is
AMapInfoWindow
->
marker
.
infoWindow
=
view
}
}
}
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapOverlay.kt
View file @
a1ccfbfa
package
cn.qiuxiang.react.amap3d.maps
package
cn.qiuxiang.react.amap3d.maps
import
android.content.Context
import
com.amap.api.maps.AMap
import
com.facebook.react.views.view.ReactViewGroup
class
AMapOverlay
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
interface
AMapOverlay
{
fun
add
(
map
:
AMap
)
fun
remove
()
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapPolygon.kt
View file @
a1ccfbfa
...
@@ -9,9 +9,9 @@ import com.amap.api.maps.model.PolygonOptions
...
@@ -9,9 +9,9 @@ import com.amap.api.maps.model.PolygonOptions
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
import
com.facebook.react.views.view.ReactViewGroup
class
AMapPolygon
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapPolygon
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
var
polygon
:
Polygon
?
=
null
private
var
polygon
:
Polygon
?
=
null
private
set
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
var
strokeWidth
:
Float
=
1f
var
strokeWidth
:
Float
=
1f
set
(
value
)
{
set
(
value
)
{
...
@@ -37,8 +37,6 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
...
@@ -37,8 +37,6 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
polygon
?.
zIndex
=
value
polygon
?.
zIndex
=
value
}
}
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
.
map
{
coordinates
.
getMap
(
it
)
}
.
map
{
coordinates
.
getMap
(
it
)
}
...
@@ -47,7 +45,7 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
...
@@ -47,7 +45,7 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
polygon
?.
points
=
this
.
coordinates
polygon
?.
points
=
this
.
coordinates
}
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
polygon
=
map
.
addPolygon
(
PolygonOptions
()
polygon
=
map
.
addPolygon
(
PolygonOptions
()
.
addAll
(
coordinates
)
.
addAll
(
coordinates
)
.
strokeColor
(
strokeColor
)
.
strokeColor
(
strokeColor
)
...
@@ -55,4 +53,8 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
...
@@ -55,4 +53,8 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
.
fillColor
(
fillColor
)
.
fillColor
(
fillColor
)
.
zIndex
(
zIndex
))
.
zIndex
(
zIndex
))
}
}
override
fun
remove
()
{
polygon
?.
remove
()
}
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapPolyline.kt
View file @
a1ccfbfa
...
@@ -9,10 +9,13 @@ import com.amap.api.maps.model.PolylineOptions
...
@@ -9,10 +9,13 @@ import com.amap.api.maps.model.PolylineOptions
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
import
com.facebook.react.views.view.ReactViewGroup
class
AMapPolyline
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapPolyline
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
var
polyline
:
Polyline
?
=
null
var
polyline
:
Polyline
?
=
null
private
set
private
set
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
private
var
colors
:
ArrayList
<
Int
>
=
ArrayList
()
var
width
:
Float
=
1f
var
width
:
Float
=
1f
set
(
value
)
{
set
(
value
)
{
field
=
value
field
=
value
...
@@ -45,9 +48,6 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
...
@@ -45,9 +48,6 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
var
gradient
:
Boolean
=
false
var
gradient
:
Boolean
=
false
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
private
var
colors
:
ArrayList
<
Int
>
=
ArrayList
()
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
.
map
{
coordinates
.
getMap
(
it
)
}
.
map
{
coordinates
.
getMap
(
it
)
}
...
@@ -57,10 +57,10 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
...
@@ -57,10 +57,10 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
}
}
fun
setColors
(
colors
:
ReadableArray
)
{
fun
setColors
(
colors
:
ReadableArray
)
{
this
.
colors
=
ArrayList
((
0
..
colors
.
size
()
-
1
).
map
{
colors
.
getInt
(
it
)
})
this
.
colors
=
ArrayList
((
0
until
colors
.
size
()
).
map
{
colors
.
getInt
(
it
)
})
}
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
polyline
=
map
.
addPolyline
(
PolylineOptions
()
polyline
=
map
.
addPolyline
(
PolylineOptions
()
.
addAll
(
coordinates
)
.
addAll
(
coordinates
)
.
color
(
color
)
.
color
(
color
)
...
@@ -71,4 +71,8 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
...
@@ -71,4 +71,8 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
.
setDottedLine
(
dashed
)
.
setDottedLine
(
dashed
)
.
zIndex
(
zIndex
))
.
zIndex
(
zIndex
))
}
}
override
fun
remove
()
{
polyline
?.
remove
()
}
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapView.kt
View file @
a1ccfbfa
package
cn.qiuxiang.react.amap3d.maps
package
cn.qiuxiang.react.amap3d.maps
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context
import
android.view.View
import
android.view.View
import
com.amap.api.maps.AMap
import
com.amap.api.maps.AMap
...
@@ -18,8 +17,6 @@ class AMapView(context: Context) : TextureMapView(context) {
...
@@ -18,8 +17,6 @@ class AMapView(context: Context) : TextureMapView(context) {
private
val
eventEmitter
:
RCTEventEmitter
=
(
context
as
ThemedReactContext
).
getJSModule
(
RCTEventEmitter
::
class
.
java
)
private
val
eventEmitter
:
RCTEventEmitter
=
(
context
as
ThemedReactContext
).
getJSModule
(
RCTEventEmitter
::
class
.
java
)
private
val
markers
=
HashMap
<
String
,
AMapMarker
>()
private
val
markers
=
HashMap
<
String
,
AMapMarker
>()
private
val
polylines
=
HashMap
<
String
,
AMapPolyline
>()
private
val
polylines
=
HashMap
<
String
,
AMapPolyline
>()
private
val
polygons
=
HashMap
<
String
,
AMapPolygon
>()
private
val
circles
=
HashMap
<
String
,
AMapCircle
>()
private
var
locationType
=
MyLocationStyle
.
LOCATION_TYPE_FOLLOW_NO_CENTER
private
var
locationType
=
MyLocationStyle
.
LOCATION_TYPE_FOLLOW_NO_CENTER
private
val
locationStyle
by
lazy
{
private
val
locationStyle
by
lazy
{
val
locationStyle
=
MyLocationStyle
()
val
locationStyle
=
MyLocationStyle
()
...
@@ -79,7 +76,7 @@ class AMapView(context: Context) : TextureMapView(context) {
...
@@ -79,7 +76,7 @@ class AMapView(context: Context) : TextureMapView(context) {
}
}
})
})
map
.
setOnCameraChangeListener
(
object
:
AMap
.
OnCameraChangeListener
{
map
.
setOnCameraChangeListener
(
object
:
AMap
.
OnCameraChangeListener
{
override
fun
onCameraChangeFinish
(
position
:
CameraPosition
?)
{
override
fun
onCameraChangeFinish
(
position
:
CameraPosition
?)
{
emitCameraChangeEvent
(
"onStatusChangeComplete"
,
position
)
emitCameraChangeEvent
(
"onStatusChangeComplete"
,
position
)
}
}
...
@@ -118,59 +115,35 @@ class AMapView(context: Context) : TextureMapView(context) {
...
@@ -118,59 +115,35 @@ class AMapView(context: Context) : TextureMapView(context) {
}
}
}
}
fun
addMarker
(
marker
:
AMapMarker
)
{
fun
emit
(
id
:
Int
?,
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
marker
.
addToMap
(
map
)
id
?.
let
{
eventEmitter
.
receiveEvent
(
it
,
name
,
data
)
}
markers
.
put
(
marker
.
marker
?.
id
!!
,
marker
)
}
fun
addPolyline
(
polyline
:
AMapPolyline
)
{
polyline
.
addToMap
(
map
)
polylines
.
put
(
polyline
.
polyline
?.
id
!!
,
polyline
)
}
}
fun
addPolygon
(
polygon
:
AMapPolygon
)
{
fun
add
(
child
:
View
)
{
polygon
.
addToMap
(
map
)
if
(
child
is
AMapOverlay
)
{
polygons
.
put
(
polygon
.
polygon
?.
id
!!
,
polygon
)
child
.
add
(
map
)
if
(
child
is
AMapMarker
)
{
markers
.
put
(
child
.
marker
?.
id
!!
,
child
)
}
}
if
(
child
is
AMapPolyline
)
{
fun
addCircle
(
circle
:
AMapCircle
)
{
polylines
.
put
(
child
.
polyline
?.
id
!!
,
child
)
circle
.
addToMap
(
map
)
circles
.
put
(
circle
.
circle
?.
id
!!
,
circle
)
}
}
fun
addHeatMap
(
heatMap
:
AMapHeatMap
)
{
heatMap
.
addToMap
(
map
)
}
}
fun
emit
(
id
:
Int
?,
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
id
?.
let
{
eventEmitter
.
receiveEvent
(
it
,
name
,
data
)
}
}
}
fun
remove
(
child
:
View
)
{
fun
remove
(
child
:
View
)
{
when
(
child
)
{
if
(
child
is
AMapOverlay
)
{
is
AMapMarker
->
{
child
.
remove
()
if
(
child
is
AMapMarker
)
{
markers
.
remove
(
child
.
marker
?.
id
)
markers
.
remove
(
child
.
marker
?.
id
)
child
.
marker
?.
destroy
()
}
}
i
s
AMapPolyline
->
{
i
f
(
child
is
AMapPolyline
)
{
polylines
.
remove
(
child
.
polyline
?.
id
)
polylines
.
remove
(
child
.
polyline
?.
id
)
child
.
polyline
?.
remove
()
}
is
AMapPolygon
->
{
polygons
.
remove
(
child
.
polygon
?.
id
)
child
.
polygon
?.
remove
()
}
is
AMapCircle
->
{
polygons
.
remove
(
child
.
circle
?.
id
)
child
.
circle
?.
remove
()
}
is
AMapHeatMap
->
{
child
.
overlay
?.
remove
()
}
}
}
}
}
}
private
val
animateCallback
=
object
:
AMap
.
CancelableCallback
{
private
val
animateCallback
=
object
:
AMap
.
CancelableCallback
{
override
fun
onCancel
()
{
override
fun
onCancel
()
{
emit
(
id
,
"onAnimateCancel"
)
emit
(
id
,
"onAnimateCancel"
)
}
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapViewManager.kt
View file @
a1ccfbfa
...
@@ -4,7 +4,6 @@ import android.view.View
...
@@ -4,7 +4,6 @@ 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.amap.api.maps.model.MyLocationStyle
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.common.MapBuilder
import
com.facebook.react.common.MapBuilder
...
@@ -42,14 +41,8 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
...
@@ -42,14 +41,8 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
}
}
override
fun
addView
(
mapView
:
AMapView
,
child
:
View
,
index
:
Int
)
{
override
fun
addView
(
mapView
:
AMapView
,
child
:
View
,
index
:
Int
)
{
mapView
.
add
(
child
)
super
.
addView
(
mapView
,
child
,
index
)
super
.
addView
(
mapView
,
child
,
index
)
when
(
child
)
{
is
AMapMarker
->
mapView
.
addMarker
(
child
)
is
AMapPolyline
->
mapView
.
addPolyline
(
child
)
is
AMapPolygon
->
mapView
.
addPolygon
(
child
)
is
AMapCircle
->
mapView
.
addCircle
(
child
)
is
AMapHeatMap
->
mapView
.
addHeatMap
(
child
)
}
}
}
override
fun
removeViewAt
(
parent
:
AMapView
,
index
:
Int
)
{
override
fun
removeViewAt
(
parent
:
AMapView
,
index
:
Int
)
{
...
...
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