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
b64dd204
Commit
b64dd204
authored
Jan 05, 2018
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加更多类型标注
parent
6cc75801
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
108 additions
and
40 deletions
+108
-40
README.md
README.md
+11
-12
react-native.js
flow-typed/react-native.js
+4
-0
Offline.js
src/Offline.js
+25
-5
Utils.js
src/Utils.js
+1
-1
Circle.js
src/maps/Circle.js
+1
-1
HeatMap.js
src/maps/HeatMap.js
+2
-2
MapView.js
src/maps/MapView.js
+39
-2
Marker.js
src/maps/Marker.js
+7
-5
MultiPoint.js
src/maps/MultiPoint.js
+14
-9
Polygon.js
src/maps/Polygon.js
+1
-1
Polyline.js
src/maps/Polyline.js
+3
-2
No files found.
README.md
View file @
b64dd204
...
@@ -132,13 +132,12 @@ import MapView from 'react-native-amap3d'
...
@@ -132,13 +132,12 @@ import MapView from 'react-native-amap3d'
### 自定义标记图片及信息窗体
### 自定义标记图片及信息窗体
```
jsx
```
jsx
<Marker
const coordinate = {
image='flag'
coordinate={{
latitude: 39.706901,
latitude: 39.706901,
longitude: 116.397972,
longitude: 116.397972,
}}
}
>
<Marker
image=
'flag'
coordinate=
{coordinate}
>
<View
style=
{styles.customInfoWindow}
>
<View
style=
{styles.customInfoWindow}
>
<Text>
自定义信息窗体
</Text>
<Text>
自定义信息窗体
</Text>
</View>
</View>
...
@@ -151,13 +150,13 @@ import MapView from 'react-native-amap3d'
...
@@ -151,13 +150,13 @@ import MapView from 'react-native-amap3d'
## 接口
## 接口
请参考注释文档:
请参考注释文档:
-
[
MapView
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/MapView.js#L15
)
-
[
MapView
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/MapView.js#L15
)
-
[
Marker
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/Marker.js#L8
)
-
[
Marker
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/Marker.js#L8
)
-
[
Polyline
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/Polyline.js#L6
)
-
[
Polyline
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/Polyline.js#L6
)
-
[
Polygon
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/Polygon.js#L6
)
-
[
Polygon
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/Polygon.js#L6
)
-
[
Circle
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/Circle.js#L6
)
-
[
Circle
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/Circle.js#L6
)
-
[
HeatMap
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/HeatMap.js#L6
)
-
[
HeatMap
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/HeatMap.js#L6
)
-
[
MultiPoint
](
https://github.com/qiuxiang/react-native-amap3d/tree/
v0.7.3
/components/maps/MultiPoint.js#L5
)
-
[
MultiPoint
](
https://github.com/qiuxiang/react-native-amap3d/tree/
master
/components/maps/MultiPoint.js#L5
)
## 关于问题反馈
## 关于问题反馈
...
...
flow-typed/react-native.js
View file @
b64dd204
declare
module
'react-native'
{
declare
module
'react-native'
{
declare
module
.
exports
:
any
declare
module
.
exports
:
any
}
}
declare
module
'react-native/Libraries/vendor/emitter/EmitterSubscription'
{
declare
module
.
exports
:
any
}
src/Offline.js
View file @
b64dd204
// @flow
import
{
NativeModules
,
NativeEventEmitter
}
from
'react-native'
import
{
NativeModules
,
NativeEventEmitter
}
from
'react-native'
import
type
EmitterSubscription
from
'react-native/Libraries/vendor/emitter/EmitterSubscription'
const
{
AMapOffline
}
=
NativeModules
const
{
AMapOffline
}
=
NativeModules
const
eventEmitter
=
new
NativeEventEmitter
(
AMapOffline
)
const
eventEmitter
=
new
NativeEventEmitter
(
AMapOffline
)
export
type
State
=
'waiting'
|
'downloading'
|
'unzip'
|
'downloaded'
|
'expired'
|
''
export
type
City
=
{
name
:
string
,
size
:
number
,
state
:
State
,
}
export
type
Province
=
{
cities
:
City
[],
}
|
City
export
type
Callback
=
(
state
:
{
name
:
string
,
progress
:
number
,
state
:
State
,
})
=>
void
export
default
{
export
default
{
getProvinces
:
()
=>
AMapOffline
.
getProvinces
(),
getProvinces
:
()
:
Promise
<
Province
[]
>
=>
AMapOffline
.
getProvinces
(),
getCities
:
()
=>
AMapOffline
.
getCities
(),
getCities
:
()
:
Promise
<
City
[]
>
=>
AMapOffline
.
getCities
(),
download
:
name
=>
AMapOffline
.
download
(
name
),
download
:
(
name
:
string
)
=>
AMapOffline
.
download
(
name
),
remove
:
name
=>
AMapOffline
.
remove
(
name
),
remove
:
(
name
:
string
)
=>
AMapOffline
.
remove
(
name
),
addDownloadListener
:
callback
=>
eventEmitter
.
addListener
(
'download'
,
callback
),
addDownloadListener
:
(
callback
:
Callback
):
EmitterSubscription
=>
eventEmitter
.
addListener
(
'download'
,
callback
),
}
}
src/Utils.js
View file @
b64dd204
...
@@ -12,5 +12,5 @@ export default {
...
@@ -12,5 +12,5 @@ export default {
lng1
:
number
,
lng1
:
number
,
lat2
:
number
,
lat2
:
number
,
lng2
:
number
,
lng2
:
number
,
)
=>
AMapUtils
.
distance
(
lat1
,
lng1
,
lat2
,
lng2
),
)
:
Promise
<
number
>
=>
AMapUtils
.
distance
(
lat1
,
lng1
,
lat2
,
lng2
),
}
}
src/maps/Circle.js
View file @
b64dd204
...
@@ -7,7 +7,7 @@ export default requireNativeComponent('AMapCircle', {
...
@@ -7,7 +7,7 @@ export default requireNativeComponent('AMapCircle', {
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
* 圆点
* 圆点
坐标
*/
*/
coordinate
:
LatLng
.
isRequired
,
coordinate
:
LatLng
.
isRequired
,
...
...
src/maps/HeatMap.js
View file @
b64dd204
...
@@ -10,12 +10,12 @@ export default requireNativeComponent('AMapHeatMap', {
...
@@ -10,12 +10,12 @@ export default requireNativeComponent('AMapHeatMap', {
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
* 节点
* 节点
坐标
*/
*/
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
/**
/**
* 半径
* 半径
(米)
*/
*/
radius
:
PropTypes
.
number
,
radius
:
PropTypes
.
number
,
...
...
src/maps/MapView.js
View file @
b64dd204
...
@@ -5,7 +5,7 @@ import { requireNativeComponent, ViewPropTypes } from 'react-native'
...
@@ -5,7 +5,7 @@ import { requireNativeComponent, ViewPropTypes } from 'react-native'
import
{
LatLng
,
Region
}
from
'../PropTypes'
import
{
LatLng
,
Region
}
from
'../PropTypes'
import
Component
from
'../Component'
import
Component
from
'../Component'
type
Target
=
{
export
type
MapStatus
=
{
zoomLevel
?:
number
,
zoomLevel
?:
number
,
coordinate
?:
LatLng
,
coordinate
?:
LatLng
,
titl
?:
number
,
titl
?:
number
,
...
@@ -159,16 +159,31 @@ export default class MapView extends Component<any> {
...
@@ -159,16 +159,31 @@ export default class MapView extends Component<any> {
/**
/**
* 点击事件
* 点击事件
*
* @param {{ nativeEvent: LatLng }}
*/
*/
onPress
:
PropTypes
.
func
,
onPress
:
PropTypes
.
func
,
/**
/**
* 长按事件
* 长按事件
*
* @param {{ nativeEvent: LatLng }}
*/
*/
onLongPress
:
PropTypes
.
func
,
onLongPress
:
PropTypes
.
func
,
/**
/**
* 定位事件
* 定位事件
*
* @param {{
* nativeEvent: {
* timestamp: number,
* speed: number,
* accuracy: number,
* altitude: number,
* longitude: number,
* latitude: number,
* }
* }}
*/
*/
onLocation
:
PropTypes
.
func
,
onLocation
:
PropTypes
.
func
,
...
@@ -184,11 +199,33 @@ export default class MapView extends Component<any> {
...
@@ -184,11 +199,33 @@ export default class MapView extends Component<any> {
/**
/**
* 地图状态变化事件
* 地图状态变化事件
*
* @param {{
* nativeEvent: {
* longitude: number,
* latitude: number,
* rotation: number,
* zoomLevel: number,
* tilt: number,
* }
* }}
*/
*/
onStatusChange
:
PropTypes
.
func
,
onStatusChange
:
PropTypes
.
func
,
/**
/**
* 地图状态变化完成事件
* 地图状态变化完成事件
*
* @param {{
* nativeEvent: {
* longitude: number,
* latitude: number,
* longitudeDelta: number,
* latitudeDelta: number,
* rotation: number,
* zoomLevel: number,
* tilt: number,
* }
* }}
*/
*/
onStatusChangeComplete
:
PropTypes
.
func
,
onStatusChangeComplete
:
PropTypes
.
func
,
}
}
...
@@ -198,7 +235,7 @@ export default class MapView extends Component<any> {
...
@@ -198,7 +235,7 @@ export default class MapView extends Component<any> {
/**
/**
* 动画过渡到某个状态(坐标、缩放级别、倾斜度、旋转角度)
* 动画过渡到某个状态(坐标、缩放级别、倾斜度、旋转角度)
*/
*/
animateTo
(
target
:
Target
,
duration
?:
number
=
500
)
{
animateTo
(
target
:
MapStatus
,
duration
?:
number
=
500
)
{
this
.
sendCommand
(
'animateTo'
,
[
target
,
duration
])
this
.
sendCommand
(
'animateTo'
,
[
target
,
duration
])
}
}
...
...
src/maps/Marker.js
View file @
b64dd204
/
* eslint-disable class-methods-use-this */
/
/ @flow
import
React
from
'react'
import
React
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
Platform
,
requireNativeComponent
,
StyleSheet
,
ViewPropTypes
,
View
}
from
'react-native'
import
{
Platform
,
requireNativeComponent
,
StyleSheet
,
ViewPropTypes
,
View
}
from
'react-native'
...
@@ -11,7 +11,7 @@ const style = StyleSheet.create({
...
@@ -11,7 +11,7 @@ const style = StyleSheet.create({
},
},
})
})
export
default
class
Marker
extends
Component
{
export
default
class
Marker
extends
Component
<
any
>
{
static
propTypes
=
{
static
propTypes
=
{
...
ViewPropTypes
,
...
ViewPropTypes
,
...
@@ -149,16 +149,17 @@ export default class Marker extends Component {
...
@@ -149,16 +149,17 @@ export default class Marker extends Component {
}
}
name
=
'AMapMarker'
name
=
'AMapMarker'
icon
:
View
=
null
active
()
{
active
()
{
this
.
sendCommand
(
'active'
)
this
.
sendCommand
(
'active'
)
}
}
lockToScreen
(
x
,
y
)
{
lockToScreen
(
x
:
number
,
y
:
number
)
{
this
.
sendCommand
(
'lockToScreen'
,
[
x
,
y
])
this
.
sendCommand
(
'lockToScreen'
,
[
x
,
y
])
}
}
renderCustomMarker
(
icon
)
{
renderCustomMarker
(
icon
:
()
=>
View
)
{
if
(
icon
)
{
if
(
icon
)
{
this
.
icon
=
<
View
style
=
{
style
.
overlay
}
>
{
icon
()}
<
/View
>
this
.
icon
=
<
View
style
=
{
style
.
overlay
}
>
{
icon
()}
<
/View
>
return
this
.
icon
return
this
.
icon
...
@@ -166,7 +167,8 @@ export default class Marker extends Component {
...
@@ -166,7 +167,8 @@ export default class Marker extends Component {
return
null
return
null
}
}
renderInfoWindow
(
view
)
{
/* eslint-disable class-methods-use-this */
renderInfoWindow
(
view
:
View
)
{
if
(
view
)
{
if
(
view
)
{
return
<
InfoWindow
style
=
{
style
.
overlay
}
>
{
view
}
<
/InfoWindow
>
return
<
InfoWindow
style
=
{
style
.
overlay
}
>
{
view
}
<
/InfoWindow
>
}
}
...
...
src/maps/MultiPoint.js
View file @
b64dd204
// @flow
import
React
,
{
PureComponent
}
from
'react'
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
export
default
class
MultiPoint
extends
PureComponent
{
export
const
Point
=
PropTypes
.
shape
({
latitude
:
PropTypes
.
number
.
isRequired
,
longitude
:
PropTypes
.
number
.
isRequired
,
title
:
PropTypes
.
string
,
subtitle
:
PropTypes
.
string
,
})
export
default
class
MultiPoint
extends
PureComponent
<
any
>
{
static
propTypes
=
{
static
propTypes
=
{
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
* 节点
* 节点
*/
*/
points
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({
points
:
PropTypes
.
arrayOf
(
Point
).
isRequired
,
latitude
:
PropTypes
.
number
.
isRequired
,
longitude
:
PropTypes
.
number
.
isRequired
,
title
:
PropTypes
.
string
,
subtitle
:
PropTypes
.
string
,
})).
isRequired
,
/**
/**
* 图标
* 图标
,只接受原生图片名字
*/
*/
image
:
PropTypes
.
string
,
image
:
PropTypes
.
string
,
/**
/**
* 点击事件
* 点击事件
*
* @param {Point}
*/
*/
onItemPress
:
PropTypes
.
func
,
onItemPress
:
PropTypes
.
func
,
}
}
onItemPress
=
({
nativeEvent
})
=>
{
onItemPress
=
({
nativeEvent
}
:
{
nativeEvent
:
{
index
:
number
}
}
)
=>
{
if
(
this
.
props
.
onItemPress
)
{
if
(
this
.
props
.
onItemPress
)
{
this
.
props
.
onItemPress
(
this
.
props
.
points
[
nativeEvent
.
index
])
this
.
props
.
onItemPress
(
this
.
props
.
points
[
nativeEvent
.
index
])
}
}
...
...
src/maps/Polygon.js
View file @
b64dd204
...
@@ -7,7 +7,7 @@ export default requireNativeComponent('AMapPolygon', {
...
@@ -7,7 +7,7 @@ export default requireNativeComponent('AMapPolygon', {
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
* 节点
* 节点
坐标
*/
*/
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
...
...
src/maps/Polyline.js
View file @
b64dd204
// @flow
import
React
,
{
PureComponent
}
from
'react'
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
ColorPropType
,
Platform
,
processColor
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
ColorPropType
,
Platform
,
processColor
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
LatLng
}
from
'../PropTypes'
import
{
LatLng
}
from
'../PropTypes'
export
default
class
Polyline
extends
PureComponent
{
export
default
class
Polyline
extends
PureComponent
<
any
>
{
static
propTypes
=
{
static
propTypes
=
{
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
* 节点
* 节点
坐标
*/
*/
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
coordinates
:
PropTypes
.
arrayOf
(
LatLng
).
isRequired
,
...
...
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