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 {
AMapViewManager
(),
AMapMarkerManager
(),
AMapInfoWindowManager
(),
AMap
Overlay
Manager
(),
AMap
MarkerIcon
Manager
(),
AMapPolylineManager
(),
AMapPolygonManager
(),
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
import
com.amap.api.maps.model.CircleOptions
import
com.facebook.react.views.view.ReactViewGroup
class
AMapCircle
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
var
circle
:
Circle
?
=
null
private
set
class
AMapCircle
(
context
:
Context
)
:
ReactViewGroup
(
context
),
AMapOverlay
{
private
var
circle
:
Circle
?
=
null
var
center
:
LatLng
?
=
null
set
(
value
)
{
...
...
@@ -48,7 +47,7 @@ class AMapCircle(context: Context) : ReactViewGroup(context) {
circle
?.
zIndex
=
value
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
circle
=
map
.
addCircle
(
CircleOptions
()
.
center
(
center
)
.
radius
(
radius
)
...
...
@@ -57,4 +56,8 @@ class AMapCircle(context: Context) : ReactViewGroup(context) {
.
fillColor
(
fillColor
)
.
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
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
class
AMapHeatMap
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
var
overlay
:
TileOverlay
?
=
null
private
set
class
AMapHeatMap
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
private
var
overlay
:
TileOverlay
?
=
null
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
var
opacity
:
Double
=
0.6
var
radius
:
Int
=
12
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
.
map
{
coordinates
.
getMap
(
it
)
}
.
map
{
LatLng
(
it
.
getDouble
(
"latitude"
),
it
.
getDouble
(
"longitude"
))
})
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
overlay
=
map
.
addTileOverlay
(
TileOverlayOptions
().
tileProvider
(
HeatmapTileProvider
.
Builder
()
.
data
(
coordinates
)
...
...
@@ -32,4 +30,8 @@ class AMapHeatMap(context: Context) : ReactViewGroup(context) {
.
transparency
(
opacity
)
.
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
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
import
com.facebook.react.uimanager.annotations.ReactProp
@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
import
com.amap.api.maps.model.*
import
com.facebook.react.views.view.ReactViewGroup
class
AMapMarker
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapMarker
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
companion
object
{
private
val
COLORS
=
mapOf
(
"AZURE"
to
BitmapDescriptorFactory
.
HUE_AZURE
,
...
...
@@ -92,7 +92,7 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
}
}
var
customIcon
:
AMap
Overlay
?
=
null
var
customIcon
:
AMap
MarkerIcon
?
=
null
set
(
value
)
{
field
=
value
value
?.
addOnLayoutChangeListener
{
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
->
updateCustomIcon
()
}
...
...
@@ -100,7 +100,7 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
private
var
bitmapDescriptor
:
BitmapDescriptor
?
=
null
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
marker
=
map
.
addMarker
(
MarkerOptions
()
.
setFlat
(
flat
)
.
icon
(
bitmapDescriptor
)
...
...
@@ -121,6 +121,10 @@ class AMapMarker(context: Context) : ReactViewGroup(context) {
marker
?.
isClickable
=
this
.
clickable_
}
override
fun
remove
()
{
marker
?.
destroy
()
}
fun
setIconColor
(
icon
:
String
)
{
bitmapDescriptor
=
COLORS
[
icon
.
toUpperCase
()]
?.
let
{
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
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ViewGroupManager
class
AMap
OverlayManager
:
ViewGroupManager
<
AMapOverlay
>()
{
class
AMap
MarkerIconManager
:
ViewGroupManager
<
AMapMarkerIcon
>()
{
override
fun
getName
():
String
{
return
"AMapOverlay"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMap
Overlay
{
return
AMap
Overlay
(
reactContext
)
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMap
MarkerIcon
{
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>() {
override
fun
addView
(
marker
:
AMapMarker
,
view
:
View
,
index
:
Int
)
{
when
(
view
)
{
is
AMap
Overlay
->
marker
.
customIcon
=
view
is
AMap
MarkerIcon
->
marker
.
customIcon
=
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
import
android.content.Context
import
com.facebook.react.views.view.ReactViewGroup
import
com.amap.api.maps.AMap
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
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
class
AMapPolygon
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
var
polygon
:
Polygon
?
=
null
private
set
class
AMapPolygon
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
private
var
polygon
:
Polygon
?
=
null
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
var
strokeWidth
:
Float
=
1f
set
(
value
)
{
...
...
@@ -37,8 +37,6 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
polygon
?.
zIndex
=
value
}
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
.
map
{
coordinates
.
getMap
(
it
)
}
...
...
@@ -47,7 +45,7 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
polygon
?.
points
=
this
.
coordinates
}
fun
addToMap
(
map
:
AMap
)
{
override
fun
add
(
map
:
AMap
)
{
polygon
=
map
.
addPolygon
(
PolygonOptions
()
.
addAll
(
coordinates
)
.
strokeColor
(
strokeColor
)
...
...
@@ -55,4 +53,8 @@ class AMapPolygon(context: Context) : ReactViewGroup(context) {
.
fillColor
(
fillColor
)
.
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
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
class
AMapPolyline
(
context
:
Context
)
:
ReactViewGroup
(
context
)
{
class
AMapPolyline
(
context
:
Context
)
:
ReactViewGroup
(
context
)
,
AMapOverlay
{
var
polyline
:
Polyline
?
=
null
private
set
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
private
var
colors
:
ArrayList
<
Int
>
=
ArrayList
()
var
width
:
Float
=
1f
set
(
value
)
{
field
=
value
...
...
@@ -45,9 +48,6 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
var
gradient
:
Boolean
=
false
private
var
coordinates
:
ArrayList
<
LatLng
>
=
ArrayList
()
private
var
colors
:
ArrayList
<
Int
>
=
ArrayList
()
fun
setCoordinates
(
coordinates
:
ReadableArray
)
{
this
.
coordinates
=
ArrayList
((
0
until
coordinates
.
size
())
.
map
{
coordinates
.
getMap
(
it
)
}
...
...
@@ -57,10 +57,10 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
}
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
()
.
addAll
(
coordinates
)
.
color
(
color
)
...
...
@@ -71,4 +71,8 @@ class AMapPolyline(context: Context) : ReactViewGroup(context) {
.
setDottedLine
(
dashed
)
.
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
import
android.annotation.SuppressLint
import
android.content.Context
import
android.view.View
import
com.amap.api.maps.AMap
...
...
@@ -18,8 +17,6 @@ class AMapView(context: Context) : TextureMapView(context) {
private
val
eventEmitter
:
RCTEventEmitter
=
(
context
as
ThemedReactContext
).
getJSModule
(
RCTEventEmitter
::
class
.
java
)
private
val
markers
=
HashMap
<
String
,
AMapMarker
>()
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
val
locationStyle
by
lazy
{
val
locationStyle
=
MyLocationStyle
()
...
...
@@ -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
?)
{
emitCameraChangeEvent
(
"onStatusChangeComplete"
,
position
)
}
...
...
@@ -118,59 +115,35 @@ class AMapView(context: Context) : TextureMapView(context) {
}
}
fun
addMarker
(
marker
:
AMapMarker
)
{
marker
.
addToMap
(
map
)
markers
.
put
(
marker
.
marker
?.
id
!!
,
marker
)
}
fun
addPolyline
(
polyline
:
AMapPolyline
)
{
polyline
.
addToMap
(
map
)
polylines
.
put
(
polyline
.
polyline
?.
id
!!
,
polyline
)
fun
emit
(
id
:
Int
?,
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
id
?.
let
{
eventEmitter
.
receiveEvent
(
it
,
name
,
data
)
}
}
fun
addPolygon
(
polygon
:
AMapPolygon
)
{
polygon
.
addToMap
(
map
)
polygons
.
put
(
polygon
.
polygon
?.
id
!!
,
polygon
)
fun
add
(
child
:
View
)
{
if
(
child
is
AMapOverlay
)
{
child
.
add
(
map
)
if
(
child
is
AMapMarker
)
{
markers
.
put
(
child
.
marker
?.
id
!!
,
child
)
}
fun
addCircle
(
circle
:
AMapCircle
)
{
circle
.
addToMap
(
map
)
circles
.
put
(
circle
.
circle
?.
id
!!
,
circle
)
if
(
child
is
AMapPolyline
)
{
polylines
.
put
(
child
.
polyline
?.
id
!!
,
child
)
}
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
)
{
when
(
child
)
{
is
AMapMarker
->
{
if
(
child
is
AMapOverlay
)
{
child
.
remove
()
if
(
child
is
AMapMarker
)
{
markers
.
remove
(
child
.
marker
?.
id
)
child
.
marker
?.
destroy
()
}
i
s
AMapPolyline
->
{
i
f
(
child
is
AMapPolyline
)
{
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
()
{
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
import
com.amap.api.maps.AMap
import
com.amap.api.maps.CameraUpdateFactory
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.ReadableMap
import
com.facebook.react.common.MapBuilder
...
...
@@ -42,14 +41,8 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
}
override
fun
addView
(
mapView
:
AMapView
,
child
:
View
,
index
:
Int
)
{
mapView
.
add
(
child
)
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
)
{
...
...
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