Commit 8608af77 authored by Qiu Xiang's avatar Qiu Xiang

更新 js 组件

parent 7972a42a
...@@ -7,7 +7,6 @@ import { ...@@ -7,7 +7,6 @@ import {
} from 'react-native' } from 'react-native'
import {LatLng} from './PropTypes' import {LatLng} from './PropTypes'
import Marker from './Marker' import Marker from './Marker'
import InfoWindow from './InfoWindow'
import Overlay from './Overlay' import Overlay from './Overlay'
import Polyline from './Polyline' import Polyline from './Polyline'
import Polygon from './Polygon' import Polygon from './Polygon'
...@@ -123,11 +122,6 @@ class MapView extends Component { ...@@ -123,11 +122,6 @@ class MapView extends Component {
*/ */
tiltEnabled: PropTypes.bool, tiltEnabled: PropTypes.bool,
/**
* 地图加载完毕事件
*/
onReady: React.PropTypes.func,
/** /**
* 点击事件 * 点击事件
*/ */
...@@ -176,7 +170,6 @@ class MapView extends Component { ...@@ -176,7 +170,6 @@ class MapView extends Component {
static Marker = Marker static Marker = Marker
static Overlay = Overlay static Overlay = Overlay
static InfoWindow = InfoWindow
static Polyline = Polyline static Polyline = Polyline
static Polygon = Polygon static Polygon = Polygon
static Circle = Circle static Circle = Circle
...@@ -185,4 +178,4 @@ class MapView extends Component { ...@@ -185,4 +178,4 @@ class MapView extends Component {
AMapView = requireNativeComponent('AMapView', MapView) AMapView = requireNativeComponent('AMapView', MapView)
export default MapView export default MapView
export {MapView, Marker, InfoWindow, Overlay, Polyline, Polygon, Circle} export {MapView, Marker, Overlay, Polyline, Polygon, Circle}
import React, {PropTypes, Component} from 'react' import React, {PropTypes, Component} from 'react'
import {requireNativeComponent, View, PixelRatio, Platform} from 'react-native' import {requireNativeComponent, View, Platform, StyleSheet} from 'react-native'
import {LatLng} from './PropTypes' import {LatLng} from './PropTypes'
import InfoWindow from './InfoWindow' import Overlay from './Overlay'
class Marker extends Component { export default class Marker extends Component {
static propTypes = { static propTypes = {
...View.propTypes, ...View.propTypes,
...@@ -111,15 +111,15 @@ class Marker extends Component { ...@@ -111,15 +111,15 @@ class Marker extends Component {
}) })
} }
let customInfoWindow = null let customInfoWindow = <View collapsable={false}/>
let customMarker = null let customMarker = <View collapsable={false}/>
if (props.children) { if (props.children) {
customInfoWindow = props.children customInfoWindow = <Overlay style={styles.overlay}>{props.children}</Overlay>
} }
if (typeof props.icon === 'function') { if (typeof props.icon === 'function') {
customMarker = props.icon() customMarker = <Overlay style={styles.overlay}>{props.icon()}</Overlay>
delete props.icon delete props.icon
} }
...@@ -132,4 +132,8 @@ class Marker extends Component { ...@@ -132,4 +132,8 @@ class Marker extends Component {
AMapMarker = requireNativeComponent('AMapMarker', Marker) AMapMarker = requireNativeComponent('AMapMarker', Marker)
export default Marker const styles = StyleSheet.create({
overlay: {
position: 'absolute',
},
})
import React, {PropTypes, Component} from 'react' import React, {PropTypes, Component} from 'react'
import {processColor, requireNativeComponent, View, PixelRatio} from 'react-native' import {processColor, requireNativeComponent, View, PixelRatio, Platform} from 'react-native'
import {LatLng} from './PropTypes' import {LatLng} from './PropTypes'
class Polyline extends Component { class Polyline extends Component {
...@@ -33,7 +33,7 @@ class Polyline extends Component { ...@@ -33,7 +33,7 @@ class Polyline extends Component {
/** /**
* 是否绘制虚线 * 是否绘制虚线
*/ */
dottedLine: PropTypes.bool, dashed: PropTypes.bool,
/** /**
* 点击事件 * 点击事件
...@@ -56,7 +56,11 @@ class Polyline extends Component { ...@@ -56,7 +56,11 @@ class Polyline extends Component {
render() { render() {
const props = { const props = {
...this.props, ...this.props,
width: PixelRatio.getPixelSizeForLayoutSize(this.props.width), ...Platform.select({
android: {
width: PixelRatio.getPixelSizeForLayoutSize(this.props.width),
},
}),
colors: this.props.colors.map(processColor), colors: this.props.colors.map(processColor),
onPolylineClick: this._handle('onPress'), onPolylineClick: this._handle('onPress'),
} }
......
...@@ -9,18 +9,6 @@ export default class PolylineExample extends Component { ...@@ -9,18 +9,6 @@ export default class PolylineExample extends Component {
render() { render() {
return <MapView style={StyleSheet.absoluteFill}> return <MapView style={StyleSheet.absoluteFill}>
<Polyline
width={5}
coordinates={[
{
latitude: 40.106901,
longitude: 116.097972,
},
{
latitude: 40.106901,
longitude: 116.597972,
},
]}/>
<Polyline <Polyline
width={5} width={5}
color='red' color='red'
...@@ -35,7 +23,7 @@ export default class PolylineExample extends Component { ...@@ -35,7 +23,7 @@ export default class PolylineExample extends Component {
}, },
]}/> ]}/>
<Polyline <Polyline
dottedLine dashed
width={5} width={5}
coordinates={[ coordinates={[
{ {
...@@ -50,7 +38,6 @@ export default class PolylineExample extends Component { ...@@ -50,7 +38,6 @@ export default class PolylineExample extends Component {
<Polyline <Polyline
gradient gradient
width={5} width={5}
color='blue'
colors={['#f44336', '#2196f3', '#4caf50']} colors={['#f44336', '#2196f3', '#4caf50']}
onPress={() => Alert.alert('onPress')} onPress={() => Alert.alert('onPress')}
coordinates={[ coordinates={[
......
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