Commit 14cc31f6 authored by Qiu Xiang's avatar Qiu Xiang

优化代码

parent 6f14f762
...@@ -2,14 +2,11 @@ import React, {PropTypes, Component} from 'react' ...@@ -2,14 +2,11 @@ import React, {PropTypes, Component} from 'react'
import { import {
View, View,
UIManager, UIManager,
NativeModules,
Platform,
findNodeHandle, findNodeHandle,
requireNativeComponent, requireNativeComponent,
} from 'react-native' } from 'react-native'
import {LatLng, Region} from './PropTypes' import {LatLng, Region} from './PropTypes'
import Marker from './Marker' import Marker from './Marker'
import Overlay from './Overlay'
import Polyline from './Polyline' import Polyline from './Polyline'
import Polygon from './Polygon' import Polygon from './Polygon'
import Circle from './Circle' import Circle from './Circle'
...@@ -171,23 +168,16 @@ class MapView extends Component { ...@@ -171,23 +168,16 @@ class MapView extends Component {
* @param {{zoomLevel: ?number, coordinate: ?LatLng, titl: ?number}} target * @param {{zoomLevel: ?number, coordinate: ?LatLng, titl: ?number}} target
* @param duration * @param duration
*/ */
animateTo(target, duration = 1000) { animateTo(target, duration = 500) {
this._sendCommand('animateTo', [target, duration]) this._sendCommand('animateTo', [target, duration])
} }
_sendCommand(command, params = null) { _sendCommand(command, params = null) {
switch (Platform.OS) { UIManager.dispatchViewManagerCommand(
case 'android': findNodeHandle(this),
UIManager.dispatchViewManagerCommand( UIManager.AMapView.Commands[command],
findNodeHandle(this), params,
UIManager.AMapView.Commands[command], )
params,
)
break;
case 'ios':
NativeModules.AMapViewManager[command](findNodeHandle(this), params)
break;
}
} }
render() { render() {
...@@ -195,7 +185,6 @@ class MapView extends Component { ...@@ -195,7 +185,6 @@ class MapView extends Component {
} }
static Marker = Marker static Marker = Marker
static Overlay = Overlay
static Polyline = Polyline static Polyline = Polyline
static Polygon = Polygon static Polygon = Polygon
static Circle = Circle static Circle = Circle
...@@ -204,4 +193,4 @@ class MapView extends Component { ...@@ -204,4 +193,4 @@ class MapView extends Component {
AMapView = requireNativeComponent('AMapView', MapView) AMapView = requireNativeComponent('AMapView', MapView)
export default MapView export default MapView
export {MapView, Marker, Overlay, Polyline, Polygon, Circle} export {MapView, Marker, Polyline, Polygon, Circle}
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