diff --git a/Examples/UIExplorer/MapViewExample.js b/Examples/UIExplorer/MapViewExample.js index 2a7bd8b92..3df5d4ded 100644 --- a/Examples/UIExplorer/MapViewExample.js +++ b/Examples/UIExplorer/MapViewExample.js @@ -33,19 +33,30 @@ var regionText = { longitudeDelta: '0', }; +type MapRegion = { + latitude: number, + longitude: number, + latitudeDelta?: number, + longitudeDelta?: number, +}; + +type MapRegionInputState = { + region: MapRegion, +}; + var MapRegionInput = React.createClass({ propTypes: { region: React.PropTypes.shape({ latitude: React.PropTypes.number.isRequired, longitude: React.PropTypes.number.isRequired, - latitudeDelta: React.PropTypes.number.isRequired, - longitudeDelta: React.PropTypes.number.isRequired, + latitudeDelta: React.PropTypes.number, + longitudeDelta: React.PropTypes.number, }), onChange: React.PropTypes.func.isRequired, }, - getInitialState() { + getInitialState(): MapRegionInputState { return { region: { latitude: 0, @@ -93,7 +104,9 @@ var MapRegionInput = React.createClass({ {'Latitude delta'} ; +type MapViewExampleState = { + isFirstLoad: boolean, + mapRegion?: MapRegion, + mapRegionInput?: MapRegion, + annotations?: Annotations, +}; + var MapViewExample = React.createClass({ - getInitialState() { + getInitialState(): MapViewExampleState { return { isFirstLoad: true, }; @@ -175,7 +215,7 @@ var MapViewExample = React.createClass({ ); }, - _getAnnotations(region) { + _getAnnotations(region): Annotations { return [{ longitude: region.longitude, latitude: region.latitude, @@ -209,9 +249,14 @@ var MapViewExample = React.createClass({ }); +type AnnotationExampleState = { + isFirstLoad: boolean, + annotations?: Annotations, + mapRegion?: MapRegion, +}; var AnnotationExample = React.createClass({ - getInitialState() { + getInitialState(): AnnotationExampleState { return { isFirstLoad: true, }; diff --git a/Libraries/Components/MapView/MapView.js b/Libraries/Components/MapView/MapView.js index d6f0205d0..c32875369 100644 --- a/Libraries/Components/MapView/MapView.js +++ b/Libraries/Components/MapView/MapView.js @@ -26,12 +26,6 @@ const resolveAssetSource = require('resolveAssetSource'); const requireNativeComponent = require('requireNativeComponent'); type Event = Object; -type MapRegion = { - latitude: number; - longitude: number; - latitudeDelta?: number; - longitudeDelta?: number; -}; const MapView = React.createClass({ mixins: [NativeMethodsMixin], @@ -155,14 +149,14 @@ const MapView = React.createClass({ */ title: React.PropTypes.string, subtitle: React.PropTypes.string, - + /** * Callout views. */ leftCalloutView: React.PropTypes.element, rightCalloutView: React.PropTypes.element, detailCalloutView: React.PropTypes.element, - + /** * The pin color. This can be any valid color string, or you can use one * of the predefined PinColors constants. Applies to both standard pins @@ -191,7 +185,7 @@ const MapView = React.createClass({ * annotation id */ id: React.PropTypes.string, - + /** * Deprecated. Use the left/right/detailsCalloutView props instead. */ @@ -286,7 +280,7 @@ const MapView = React.createClass({ rightCalloutView, detailCalloutView, } = annotation; - + if (!view && image && tintColor) { view =