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
3ca95954
Commit
3ca95954
authored
Sep 02, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 Android 海量点图层接口
相关:#51
parent
1908456e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
170 additions
and
2 deletions
+170
-2
AMap3DPackage.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
+1
-0
AMapMultiPoint.kt
...main/java/cn/qiuxiang/react/amap3d/maps/AMapMultiPoint.kt
+48
-0
AMapMultiPointManager.kt
...va/cn/qiuxiang/react/amap3d/maps/AMapMultiPointManager.kt
+35
-0
AMapView.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapView.kt
+8
-0
MultiPoint.js
components/maps/MultiPoint.js
+42
-0
icon.png
example/android/app/src/main/res/drawable/icon.png
+0
-0
package-lock.json
example/package-lock.json
+0
-0
package.json
example/package.json
+2
-2
app.js
example/src/app.js
+2
-0
examples.js
example/src/examples.js
+2
-0
multi-point.js
example/src/examples/multi-point.js
+27
-0
index.js
index.js
+3
-0
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMap3DPackage.kt
View file @
3ca95954
...
...
@@ -24,6 +24,7 @@ class AMap3DPackage : ReactPackage {
AMapPolygonManager
(),
AMapCircleManager
(),
AMapHeatMapManager
(),
AMapMultiPointManager
(),
AMapDriveManager
(),
AMapWalkManager
(),
AMapRideManager
()
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMultiPoint.kt
0 → 100644
View file @
3ca95954
package
cn.qiuxiang.react.amap3d.maps
import
android.content.Context
import
com.amap.api.maps.AMap
import
com.amap.api.maps.model.*
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.views.view.ReactViewGroup
class
AMapMultiPoint
(
context
:
Context
)
:
ReactViewGroup
(
context
),
AMapOverlay
{
private
var
overlay
:
MultiPointOverlay
?
=
null
private
var
items
:
ArrayList
<
MultiPointItem
>
=
ArrayList
()
private
var
icon
:
BitmapDescriptor
?
=
null
fun
setPoints
(
points
:
ReadableArray
)
{
items
=
ArrayList
((
0
until
points
.
size
())
.
map
{
val
data
=
points
.
getMap
(
it
)
val
item
=
MultiPointItem
(
LatLng
(
data
.
getDouble
(
"latitude"
),
data
.
getDouble
(
"longitude"
)))
if
(
data
.
hasKey
(
"title"
))
{
item
.
title
=
data
.
getString
(
"title"
)
}
if
(
data
.
hasKey
(
"subtitle"
))
{
item
.
snippet
=
data
.
getString
(
"subtitle"
)
}
item
.
customerId
=
id
.
toString
()
+
"_"
+
it
item
})
overlay
?.
setItems
(
items
)
}
override
fun
add
(
map
:
AMap
)
{
overlay
=
map
.
addMultiPointOverlay
(
MultiPointOverlayOptions
().
icon
(
icon
))
overlay
?.
setItems
(
items
)
overlay
?.
setEnable
(
true
)
}
override
fun
remove
()
{
overlay
?.
destroy
()
}
fun
setImage
(
image
:
String
)
{
val
drawable
=
context
.
resources
.
getIdentifier
(
image
,
"drawable"
,
context
.
packageName
)
icon
=
BitmapDescriptorFactory
.
fromResource
(
drawable
)
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMultiPointManager.kt
0 → 100644
View file @
3ca95954
package
cn.qiuxiang.react.amap3d.maps
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.common.MapBuilder
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.annotations.ReactProp
internal
class
AMapMultiPointManager
:
SimpleViewManager
<
AMapMultiPoint
>()
{
override
fun
getName
():
String
{
return
"AMapMultiPoint"
}
override
fun
createViewInstance
(
reactContext
:
ThemedReactContext
):
AMapMultiPoint
{
return
AMapMultiPoint
(
reactContext
)
}
override
fun
getExportedCustomDirectEventTypeConstants
():
Map
<
String
,
Any
>?
{
return
MapBuilder
.
of
(
"onItemPress"
,
MapBuilder
.
of
(
"registrationName"
,
"onItemPress"
)
)
}
@ReactProp
(
name
=
"points"
)
fun
setPoints
(
multiPoint
:
AMapMultiPoint
,
points
:
ReadableArray
)
{
multiPoint
.
setPoints
(
points
)
}
@ReactProp
(
name
=
"image"
)
fun
setImage
(
multiPoint
:
AMapMultiPoint
,
image
:
String
)
{
multiPoint
.
setImage
(
image
);
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapView.kt
View file @
3ca95954
...
...
@@ -94,6 +94,14 @@ class AMapView(context: Context) : TextureMapView(context) {
emit
(
polylines
[
polyline
.
id
]
?.
id
,
"onPress"
)
}
map
.
setOnMultiPointClickListener
{
item
->
val
slice
=
item
.
customerId
.
split
(
"_"
)
val
data
=
Arguments
.
createMap
()
data
.
putInt
(
"index"
,
slice
[
1
].
toInt
())
emit
(
slice
[
0
].
toInt
(),
"onItemPress"
,
data
)
false
}
map
.
setInfoWindowAdapter
(
AMapInfoWindowAdapter
(
context
,
markers
))
}
...
...
components/maps/MultiPoint.js
0 → 100644
View file @
3ca95954
import
React
,
{
PropTypes
,
PureComponent
}
from
'react'
import
{
requireNativeComponent
,
resolveAssetSource
,
ViewPropTypes
}
from
'react-native'
export
default
class
MultiPoint
extends
PureComponent
{
static
propTypes
=
{
...
ViewPropTypes
,
/**
* 节点
*/
points
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({
latitude
:
PropTypes
.
number
.
isRequired
,
longitude
:
PropTypes
.
number
.
isRequired
,
title
:
PropTypes
.
string
,
subtitle
:
PropTypes
.
string
,
})
).
isRequired
,
/**
* 图标
*/
image
:
PropTypes
.
string
,
/**
* 点击事件
*/
onItemPress
:
React
.
PropTypes
.
func
,
}
_onItemPress
=
event
=>
{
if
(
this
.
props
.
onItemPress
)
{
this
.
props
.
onItemPress
(
this
.
props
.
points
[
event
.
nativeEvent
.
index
])
}
}
render
()
{
return
<
AMapMultiPoint
{...
this
.
props
}
onItemPress
=
{
this
.
_onItemPress
}
/
>
}
}
const
AMapMultiPoint
=
requireNativeComponent
(
'AMapMultiPoint'
,
MultiPoint
)
example/android/app/src/main/res/drawable/icon.png
0 → 100644
View file @
3ca95954
4.84 KB
example/package-lock.json
View file @
3ca95954
This diff is collapsed.
Click to expand it.
example/package.json
View file @
3ca95954
...
...
@@ -9,8 +9,8 @@
"dependencies"
:
{
"react"
:
"16.0.0-alpha.12"
,
"react-native"
:
"0.47.1"
,
"react-native-amap3d"
:
"^0.3.
1
"
,
"react-navigation"
:
"^1.0.0-beta.1
1
"
"react-native-amap3d"
:
"^0.3.
3
"
,
"react-navigation"
:
"^1.0.0-beta.1
2
"
},
"devDependencies"
:
{
"babel-preset-react-native"
:
"2.1.0"
...
...
example/src/app.js
View file @
3ca95954
...
...
@@ -14,6 +14,7 @@ import Circle from './examples/circle'
import
Events
from
'./examples/events'
import
Navigation
from
'./examples/navigation'
import
HeatMap
from
'./examples/heat-map'
import
MultiPoint
from
'./examples/multi-point'
export
default
StackNavigator
({
Examples
:
{
screen
:
Examples
},
...
...
@@ -30,6 +31,7 @@ export default StackNavigator({
Events
:
{
screen
:
Events
},
Navigation
:
{
screen
:
Navigation
},
HeatMap
:
{
screen
:
HeatMap
},
MultiPoint
:
{
screen
:
MultiPoint
},
},
{
navigationOptions
:
{
headerTintColor
:
'#212121'
,
...
...
example/src/examples.js
View file @
3ca95954
...
...
@@ -56,6 +56,8 @@ export default class Examples extends Component {
{
this
.
_renderItem
(
'绘制圆形'
,
'Circle'
)}
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'热力图'
,
'HeatMap'
)}
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'海量点'
,
'MultiPoint'
)}
<
/View
>
<
View
style
=
{
styles
.
group
}
>
{
this
.
_renderItem
(
'导航'
,
'Navigation'
)}
...
...
example/src/examples/multi-point.js
0 → 100644
View file @
3ca95954
import
React
,
{
Component
}
from
'react'
import
{
StyleSheet
,
Alert
}
from
'react-native'
import
{
MapView
,
MultiPoint
,
Marker
}
from
'react-native-amap3d'
export
default
class
MultiPointExample
extends
Component
{
static
navigationOptions
=
{
title
:
'海量点'
,
}
_points
=
Array
(
1000
).
fill
(
0
).
map
(
i
=>
({
latitude
:
39.5
+
Math
.
random
(),
longitude
:
116
+
Math
.
random
(),
}))
_onItemPress
=
point
=>
Alert
.
alert
(
this
.
_points
.
indexOf
(
point
).
toString
())
render
()
{
return
<
MapView
zoomLevel
=
{
12
}
style
=
{
StyleSheet
.
absoluteFill
}
>
<
MultiPoint
image
=
{
'icon'
}
points
=
{
this
.
_points
}
onItemPress
=
{
this
.
_onItemPress
}
/
>
<
/MapView
>
}
}
index.js
View file @
3ca95954
...
...
@@ -4,6 +4,7 @@ import Polyline from './components/maps/Polyline'
import
Polygon
from
'./components/maps/Polygon'
import
Circle
from
'./components/maps/Circle'
import
HeatMap
from
'./components/maps/HeatMap'
import
MultiPoint
from
'./components/maps/MultiPoint'
import
Navigation
from
'./components/navigation'
import
MapUtils
from
'./components/Utils'
...
...
@@ -12,6 +13,7 @@ MapView.Polyline = Polyline
MapView
.
Polygon
=
Polygon
MapView
.
Circle
=
Circle
MapView
.
HeatMap
=
HeatMap
MapView
.
MultiPoint
=
MultiPoint
export
default
MapView
export
{
...
...
@@ -21,6 +23,7 @@ export {
Polygon
,
Circle
,
HeatMap
,
MultiPoint
,
Navigation
,
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