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
3c201a52
Commit
3c201a52
authored
Aug 29, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 android 热力图接口
parent
e150ea10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
139 additions
and
0 deletions
+139
-0
AMap3DPackage.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
+1
-0
AMapHeatMap.kt
...rc/main/java/cn/qiuxiang/react/amap3d/maps/AMapHeatMap.kt
+36
-0
AMapHeatMapManager.kt
.../java/cn/qiuxiang/react/amap3d/maps/AMapHeatMapManager.kt
+34
-0
AMapView.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapView.kt
+7
-0
AMapViewManager.kt
...ain/java/cn/qiuxiang/react/amap3d/maps/AMapViewManager.kt
+1
-0
HeatMap.js
components/maps/HeatMap.js
+30
-0
app.js
example/src/app.js
+2
-0
examples.js
example/src/examples.js
+2
-0
heat-map.js
example/src/examples/heat-map.js
+23
-0
index.js
index.js
+3
-0
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
View file @
3c201a52
...
@@ -23,6 +23,7 @@ class AMap3DPackage : ReactPackage {
...
@@ -23,6 +23,7 @@ class AMap3DPackage : ReactPackage {
AMapPolylineManager
(),
AMapPolylineManager
(),
AMapPolygonManager
(),
AMapPolygonManager
(),
AMapCircleManager
(),
AMapCircleManager
(),
AMapHeatMapManager
(),
AMapDriveManager
(),
AMapDriveManager
(),
AMapWalkManager
(),
AMapWalkManager
(),
AMapRideManager
()
AMapRideManager
()
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapHeatMap.kt
0 → 100644
View file @
3c201a52
package
cn.qiuxiang.react.amap3d.maps
import
android.content.Context
import
com.amap.api.maps.AMap
import
com.amap.api.maps.model.HeatmapTileProvider
import
com.amap.api.maps.model.LatLng
import
com.amap.api.maps.model.TileOverlay
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
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
)
{
overlay
=
map
.
addTileOverlay
(
TileOverlayOptions
().
tileProvider
(
HeatmapTileProvider
.
Builder
()
.
data
(
coordinates
)
.
radius
(
radius
)
.
transparency
(
opacity
)
.
build
()))
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapHeatMapManager.kt
0 → 100644
View file @
3c201a52
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"
)
internal
class
AMapHeatMapManager
:
SimpleViewManager
<
AMapHeatMap
>()
{
override
fun
getName
():
String
{
return
"AMapHeatMap"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMapHeatMap
{
return
AMapHeatMap
(
reactContext
)
}
@ReactProp
(
name
=
"coordinates"
)
fun
setCoordinate
(
heatMap
:
AMapHeatMap
,
coordinates
:
ReadableArray
)
{
heatMap
.
setCoordinates
(
coordinates
)
}
@ReactProp
(
name
=
"radius"
)
fun
setRadius
(
heatMap
:
AMapHeatMap
,
radius
:
Int
)
{
heatMap
.
radius
=
radius
}
@ReactProp
(
name
=
"opacity"
)
fun
setOpacity
(
heatMap
:
AMapHeatMap
,
opacity
:
Double
)
{
heatMap
.
opacity
=
opacity
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapView.kt
View file @
3c201a52
...
@@ -138,6 +138,10 @@ class AMapView(context: Context) : TextureMapView(context) {
...
@@ -138,6 +138,10 @@ class AMapView(context: Context) : TextureMapView(context) {
circles
.
put
(
circle
.
circle
?.
id
!!
,
circle
)
circles
.
put
(
circle
.
circle
?.
id
!!
,
circle
)
}
}
fun
addHeatMap
(
heatMap
:
AMapHeatMap
)
{
heatMap
.
addToMap
(
map
)
}
fun
emit
(
id
:
Int
?,
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
fun
emit
(
id
:
Int
?,
name
:
String
,
data
:
WritableMap
=
Arguments
.
createMap
())
{
id
?.
let
{
eventEmitter
.
receiveEvent
(
it
,
name
,
data
)
}
id
?.
let
{
eventEmitter
.
receiveEvent
(
it
,
name
,
data
)
}
}
}
...
@@ -160,6 +164,9 @@ class AMapView(context: Context) : TextureMapView(context) {
...
@@ -160,6 +164,9 @@ class AMapView(context: Context) : TextureMapView(context) {
polygons
.
remove
(
child
.
circle
?.
id
)
polygons
.
remove
(
child
.
circle
?.
id
)
child
.
circle
?.
remove
()
child
.
circle
?.
remove
()
}
}
is
AMapHeatMap
->
{
child
.
overlay
?.
remove
()
}
}
}
}
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapViewManager.kt
View file @
3c201a52
...
@@ -48,6 +48,7 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
...
@@ -48,6 +48,7 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
is
AMapPolyline
->
mapView
.
addPolyline
(
child
)
is
AMapPolyline
->
mapView
.
addPolyline
(
child
)
is
AMapPolygon
->
mapView
.
addPolygon
(
child
)
is
AMapPolygon
->
mapView
.
addPolygon
(
child
)
is
AMapCircle
->
mapView
.
addCircle
(
child
)
is
AMapCircle
->
mapView
.
addCircle
(
child
)
is
AMapHeatMap
->
mapView
.
addHeatMap
(
child
)
}
}
}
}
...
...
components/maps/HeatMap.js
0 → 100644
View file @
3c201a52
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
PixelRatio
,
Platform
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
LatLng
}
from
'../PropTypes'
export
default
class
HeatMap
extends
PureComponent
{
static
propTypes
=
{
...
ViewPropTypes
,
/**
* 节点
*/
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
/**
* 半径
*/
radius
:
PropTypes
.
number
,
/**
* 透明度
*/
opacity
:
PropTypes
.
number
,
}
render
()
{
return
<
AMapHeatMap
{...
this
.
props
}
/
>
}
}
const
AMapHeatMap
=
requireNativeComponent
(
'AMapHeatMap'
,
HeatMap
)
example/src/app.js
View file @
3c201a52
...
@@ -13,6 +13,7 @@ import Polygon from './examples/polygon'
...
@@ -13,6 +13,7 @@ import Polygon from './examples/polygon'
import
Circle
from
'./examples/circle'
import
Circle
from
'./examples/circle'
import
Events
from
'./examples/events'
import
Events
from
'./examples/events'
import
Navigation
from
'./examples/navigation'
import
Navigation
from
'./examples/navigation'
import
HeatMap
from
'./examples/heat-map'
export
default
StackNavigator
({
export
default
StackNavigator
({
Examples
:
{
screen
:
Examples
},
Examples
:
{
screen
:
Examples
},
...
@@ -28,6 +29,7 @@ export default StackNavigator({
...
@@ -28,6 +29,7 @@ export default StackNavigator({
Circle
:
{
screen
:
Circle
},
Circle
:
{
screen
:
Circle
},
Events
:
{
screen
:
Events
},
Events
:
{
screen
:
Events
},
Navigation
:
{
screen
:
Navigation
},
Navigation
:
{
screen
:
Navigation
},
HeatMap
:
{
screen
:
HeatMap
},
},
{
},
{
navigationOptions
:
{
navigationOptions
:
{
headerTintColor
:
'#212121'
,
headerTintColor
:
'#212121'
,
...
...
example/src/examples.js
View file @
3c201a52
...
@@ -54,6 +54,8 @@ export default class Examples extends Component {
...
@@ -54,6 +54,8 @@ export default class Examples extends Component {
{
this
.
_renderItem
(
'绘制多边形'
,
'Polygon'
)}
{
this
.
_renderItem
(
'绘制多边形'
,
'Polygon'
)}
<
View
style
=
{
styles
.
separator
}
/
>
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'绘制圆形'
,
'Circle'
)}
{
this
.
_renderItem
(
'绘制圆形'
,
'Circle'
)}
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'热力图'
,
'HeatMap'
)}
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
group
}
>
<
View
style
=
{
styles
.
group
}
>
{
this
.
_renderItem
(
'导航'
,
'Navigation'
)}
{
this
.
_renderItem
(
'导航'
,
'Navigation'
)}
...
...
example/src/examples/heat-map.js
0 → 100644
View file @
3c201a52
import
React
,
{
Component
}
from
'react'
import
{
StyleSheet
}
from
'react-native'
import
{
MapView
,
HeatMap
}
from
'react-native-amap3d'
export
default
class
HeatMapExample
extends
Component
{
static
navigationOptions
=
{
title
:
'热力图'
,
}
_coordinates
=
(
new
Array
(
200
)).
fill
(
0
).
map
(
i
=>
({
latitude
:
39.5
+
Math
.
random
(),
longitude
:
116
+
Math
.
random
(),
}))
render
()
{
return
<
MapView
zoomLevel
=
{
9
}
style
=
{
StyleSheet
.
absoluteFill
}
>
<
HeatMap
opacity
=
{
0.8
}
radius
=
{
20
}
coordinates
=
{
this
.
_coordinates
}
/
>
<
/MapView
>
}
}
index.js
View file @
3c201a52
...
@@ -3,6 +3,7 @@ import Marker from './components/maps/Marker'
...
@@ -3,6 +3,7 @@ import Marker from './components/maps/Marker'
import
Polyline
from
'./components/maps/Polyline'
import
Polyline
from
'./components/maps/Polyline'
import
Polygon
from
'./components/maps/Polygon'
import
Polygon
from
'./components/maps/Polygon'
import
Circle
from
'./components/maps/Circle'
import
Circle
from
'./components/maps/Circle'
import
HeatMap
from
'./components/maps/HeatMap'
import
Navigation
from
'./components/navigation'
import
Navigation
from
'./components/navigation'
import
MapUtils
from
'./components/Utils'
import
MapUtils
from
'./components/Utils'
...
@@ -10,6 +11,7 @@ MapView.Marker = Marker
...
@@ -10,6 +11,7 @@ MapView.Marker = Marker
MapView
.
Polyline
=
Polyline
MapView
.
Polyline
=
Polyline
MapView
.
Polygon
=
Polygon
MapView
.
Polygon
=
Polygon
MapView
.
Circle
=
Circle
MapView
.
Circle
=
Circle
MapView
.
HeatMap
=
HeatMap
export
default
MapView
export
default
MapView
export
{
export
{
...
@@ -18,6 +20,7 @@ export {
...
@@ -18,6 +20,7 @@ export {
Polyline
,
Polyline
,
Polygon
,
Polygon
,
Circle
,
Circle
,
HeatMap
,
Navigation
,
Navigation
,
MapUtils
,
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