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

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

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