Commit 6201ae3d authored by Qiu Xiang's avatar Qiu Xiang

优化代码以及完善注释文档

parent 6a4fcea4
import React, {PropTypes, Component} from 'react'
import {requireNativeComponent, View, PixelRatio, Platform} from 'react-native'
import {
requireNativeComponent,
ViewPropTypes,
PixelRatio,
Platform,
} from 'react-native'
import {LatLng} from './PropTypes'
class Circle extends Component {
export default class Circle extends Component {
static propTypes = {
...View.propTypes,
...ViewPropTypes,
/**
* 圆点
......@@ -16,9 +21,24 @@ class Circle extends Component {
*/
radius: PropTypes.number.isRequired,
/**
* 边线宽度
*/
strokeWidth: PropTypes.number,
/**
* 边线颜色
*/
strokeColor: PropTypes.string,
/**
* 填充颜色
*/
fillColor: PropTypes.string,
/**
* 层级
*/
zIndex: PropTypes.number,
}
......@@ -35,6 +55,4 @@ class Circle extends Component {
}
}
AMapCircle = requireNativeComponent('AMapCircle', Circle)
export default Circle
const AMapCircle = requireNativeComponent('AMapCircle', Circle)
import React, {PropTypes, Component} from 'react'
// @flow
import React, {Component, PropTypes} from 'react'
import {
View,
UIManager,
findNodeHandle,
requireNativeComponent,
UIManager,
ViewPropTypes,
} from 'react-native'
import {LatLng, Region} from './PropTypes'
type Target = {
zoomLevel?: number,
coordinate?: LatLng,
titl?: number,
rotation?: number,
}
export default class MapView extends Component {
static propTypes = {
...View.propTypes,
...ViewPropTypes,
/**
* 地图类型
......@@ -57,7 +65,7 @@ export default class MapView extends Component {
/**
* 是否显示放大缩小按钮
*
* Android only
* @platform android
*/
showsZoomControls: PropTypes.bool,
......@@ -69,7 +77,7 @@ export default class MapView extends Component {
/**
* 是否显示定位按钮
*
* Android only
* @platform android
*/
showsLocationButton: PropTypes.bool,
......@@ -154,7 +162,7 @@ export default class MapView extends Component {
onAnimateCancel: React.PropTypes.func,
/**
* 地图状态变化(包括移动、缩放、倾斜、旋转)事件
* 地图状态变化事件
*/
onStatusChange: React.PropTypes.func,
......@@ -165,16 +173,18 @@ export default class MapView extends Component {
}
/**
* 动画过渡到某个位置(坐标、缩放级别、倾斜度)
*
* @param {{zoomLevel: ?number, coordinate: ?LatLng, titl: ?number}} target
* @param duration
* 动画过渡到某个状态(坐标、缩放级别、倾斜度、旋转角度)
*/
animateTo(target, duration = 500) {
animateTo(target: Target, duration?: number = 500) {
this._sendCommand('animateTo', [target, duration])
}
_sendCommand(command, params = null) {
/**
* call native method
*
* @private
*/
_sendCommand(command: string, params?: []) {
UIManager.dispatchViewManagerCommand(
findNodeHandle(this),
UIManager.AMapView.Commands[command],
......@@ -187,4 +197,4 @@ export default class MapView extends Component {
}
}
AMapView = requireNativeComponent('AMapView', MapView)
const AMapView = requireNativeComponent('AMapView', MapView)
import React, {PropTypes, PureComponent} from 'react'
import React, {PropTypes, Component} from 'react'
import {
requireNativeComponent,
View,
......@@ -9,7 +9,7 @@ import {
import {LatLng} from './PropTypes'
import Overlay from './Overlay'
export default class Marker extends PureComponent {
export default class Marker extends Component {
static propTypes = {
...ViewPropTypes,
......@@ -30,13 +30,6 @@ export default class Marker extends PureComponent {
/**
* 自定义图标
*
* 可以是回调函数返回的自定义 View,需要注意的是,
* Root View 必须是 Overlay,且需设置 style width。
*
* 内置的颜色有限,如需真正的自定义颜色,
* 建议使用自定义 View 引用 Image,如此,
* 任何颜色都可以通过 tintColor 进行设置。
*/
icon: PropTypes.oneOfType([
Platform.select({
......
import React, {PropTypes, Component} from 'react'
import {
View,
ViewPropTypes,
UIManager,
findNodeHandle,
requireNativeComponent,
} from 'react-native'
class Overlay extends Component {
export default class Overlay extends Component {
static propTypes = {
...View.propTypes,
...ViewPropTypes,
}
_update() {
......@@ -29,6 +29,4 @@ class Overlay extends Component {
}
}
AMapOverlay = requireNativeComponent('AMapOverlay', Overlay)
export default Overlay
const AMapOverlay = requireNativeComponent('AMapOverlay', Overlay)
import React, {PropTypes, Component} from 'react'
import {requireNativeComponent, View, PixelRatio, Platform} from 'react-native'
import {
requireNativeComponent,
ViewPropTypes,
PixelRatio,
Platform,
} from 'react-native'
import {LatLng} from './PropTypes'
class Polygon extends Component {
export default class Polygon extends Component {
static propTypes = {
...View.propTypes,
...ViewPropTypes,
/**
* 节点
*/
coordinates: PropTypes.arrayOf(LatLng).isRequired,
/**
* 边线宽度
*/
strokeWidth: PropTypes.number,
/**
* 边线颜色
*/
strokeColor: PropTypes.string,
/**
* 填充颜色
*/
fillColor: PropTypes.string,
/**
* 层级
*/
zIndex: PropTypes.number,
}
......@@ -27,5 +51,3 @@ class Polygon extends Component {
}
AMapPolygon = requireNativeComponent('AMapPolygon', Polygon)
export default Polygon
import React, {PropTypes, Component} from 'react'
import {processColor, requireNativeComponent, View, PixelRatio, Platform} from 'react-native'
import {
processColor,
requireNativeComponent,
ViewPropTypes,
PixelRatio,
Platform,
} from 'react-native'
import {LatLng} from './PropTypes'
class Polyline extends Component {
export default class Polyline extends Component {
static propTypes = {
...View.propTypes,
...ViewPropTypes,
/**
* 节点
*/
coordinates: PropTypes.arrayOf(LatLng).isRequired,
/**
* 线段宽度
*/
width: PropTypes.number,
/**
* 线段颜色
*/
color: PropTypes.string,
/**
* 层级
*/
zIndex: PropTypes.number,
/**
......@@ -67,6 +88,4 @@ class Polyline extends Component {
}
}
AMapPolyline = requireNativeComponent('AMapPolyline', Polyline)
export default Polyline
const AMapPolyline = requireNativeComponent('AMapPolyline', Polyline)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment