diff --git a/Examples/UIExplorer/MapViewExample.js b/Examples/UIExplorer/MapViewExample.js
index 44142a4af..407e40f00 100644
--- a/Examples/UIExplorer/MapViewExample.js
+++ b/Examples/UIExplorer/MapViewExample.js
@@ -17,10 +17,12 @@
var React = require('react-native');
var {
+ Image,
MapView,
StyleSheet,
Text,
TextInput,
+ TouchableOpacity,
View,
} = React;
@@ -239,14 +241,14 @@ var MapViewExample = React.createClass({
});
-type CalloutMapViewExampleState = {
+type AnnotationExampleState = {
isFirstLoad: boolean,
annotations?: Annotations,
mapRegion?: MapRegion,
};
-var CalloutMapViewExample = React.createClass({
+var AnnotationExample = React.createClass({
- getInitialState(): CalloutMapViewExampleState {
+ getInitialState(): AnnotationExampleState {
return {
isFirstLoad: true,
};
@@ -260,11 +262,7 @@ var CalloutMapViewExample = React.createClass({
annotations: [{
longitude: region.longitude,
latitude: region.latitude,
- title: 'More Info...',
- hasRightCallout: true,
- onRightCalloutPress: () => {
- alert('You Are Here');
- },
+ ...this.props.annotation,
}],
});
};
@@ -282,141 +280,6 @@ var CalloutMapViewExample = React.createClass({
});
-type CustomPinColorMapViewExampleState = {
- isFirstLoad: boolean,
- annotations?: Annotations,
- mapRegion?: MapRegion,
-};
-var CustomPinColorMapViewExample = React.createClass({
-
- getInitialState(): CustomPinColorMapViewExampleState {
- return {
- isFirstLoad: true,
- };
- },
-
- render() {
- if (this.state.isFirstLoad) {
- var onRegionChangeComplete = (region) => {
- this.setState({
- isFirstLoad: false,
- annotations: [{
- longitude: region.longitude,
- latitude: region.latitude,
- title: 'You Are Purple',
- tintColor: MapView.PinColors.PURPLE,
- }],
- });
- };
- }
-
- return (
-
- );
- },
-
-});
-
-type CustomPinImageMapViewExampleState = {
- isFirstLoad: boolean,
- annotations?: Annotations,
- mapRegion?: MapRegion,
-};
-var CustomPinImageMapViewExample = React.createClass({
-
- getInitialState(): CustomPinImageMapViewExampleState {
- return {
- isFirstLoad: true,
- };
- },
-
- render() {
- if (this.state.isFirstLoad) {
- var onRegionChangeComplete = (region) => {
- this.setState({
- isFirstLoad: false,
- annotations: [{
- longitude: region.longitude,
- latitude: region.latitude,
- title: 'Thumbs Up!',
- image: require('image!uie_thumb_big'),
- }],
- });
- };
- }
-
- return (
-
- );
- },
-
-});
-
-type Overlays = Array<{
- coordinates?: Array<{
- latitude: number,
- longitude: number,
- }>,
- lineWidth?: number,
- strokeColor?: string,
- fillColor?: string,
- id?: string,
-}>;
-type CustomOverlayMapViewExampleState = {
- isFirstLoad: boolean,
- overlays?: Overlays,
- annotations?: Annotations,
- mapRegion?: MapRegion,
-};
-var CustomOverlayMapViewExample = React.createClass({
-
- getInitialState(): CustomOverlayMapViewExampleState {
- return {
- isFirstLoad: true,
- };
- },
-
- render() {
- if (this.state.isFirstLoad) {
- var onRegionChangeComplete = (region) => {
- this.setState({
- isFirstLoad: false,
- overlays: [{
- coordinates:[
- {latitude: 32.47, longitude: -107.85},
- {latitude: 45.13, longitude: -94.48},
- {latitude: 39.27, longitude: -83.25},
- {latitude: 32.47, longitude: -107.85},
- ],
- strokeColor: '#f007',
- lineWidth: 3,
- }],
- });
- };
- }
-
- return (
-
- );
- },
-
-});
-
var styles = StyleSheet.create({
map: {
height: 150,
@@ -451,36 +314,92 @@ exports.description = 'Base component to display maps';
exports.examples = [
{
title: 'Map',
- render(): ReactElement { return ; }
+ render() {
+ return ;
+ }
},
{
title: 'Map shows user location',
render() {
- return ;
+ return ;
}
},
{
title: 'Callout example',
render() {
- return ;
+ return {
+ alert('You Are Here');
+ }}>
+
+
+ ),
+ }}/>;
}
},
{
title: 'Custom pin color',
render() {
- return ;
+ return ;
}
},
{
title: 'Custom pin image',
render() {
- return ;
+ return ;
+ }
+ },
+ {
+ title: 'Custom pin view',
+ render() {
+ return
+
+ Thumbs Up!
+
+
+ ,
+ }}/>;
}
},
{
title: 'Custom overlay',
render() {
- return ;
+ return ;
}
},
];
diff --git a/Libraries/Components/MapView/MapView.js b/Libraries/Components/MapView/MapView.js
index 747e366fc..8fcddb77c 100644
--- a/Libraries/Components/MapView/MapView.js
+++ b/Libraries/Components/MapView/MapView.js
@@ -11,78 +11,31 @@
*/
'use strict';
-var EdgeInsetsPropType = require('EdgeInsetsPropType');
-var Image = require('Image');
-var NativeMethodsMixin = require('NativeMethodsMixin');
-var Platform = require('Platform');
-var RCTMap = require('UIManager').RCTMap;
-var RCTMapConstants = RCTMap && RCTMap.Constants;
-var React = require('React');
-var View = require('View');
+const EdgeInsetsPropType = require('EdgeInsetsPropType');
+const Image = require('Image');
+const NativeMethodsMixin = require('NativeMethodsMixin');
+const Platform = require('Platform');
+const RCTMapConfig = require('UIManager').RCTMap;
+const RCTMapConstants = RCTMapConfig && RCTMapConfig.Constants;
+const React = require('React');
+const StyleSheet = require('StyleSheet');
+const View = require('View');
-var processColor = require('processColor');
-var resolveAssetSource = require('resolveAssetSource');
-var requireNativeComponent = require('requireNativeComponent');
+const processColor = require('processColor');
+const resolveAssetSource = require('resolveAssetSource');
+const requireNativeComponent = require('requireNativeComponent');
type Event = Object;
type MapRegion = {
latitude: number;
longitude: number;
- latitudeDelta: number;
- longitudeDelta: number;
+ latitudeDelta?: ?number;
+ longitudeDelta?: ?number;
};
-var MapView = React.createClass({
+const MapView = React.createClass({
mixins: [NativeMethodsMixin],
- checkAnnotationIds: function (annotations: Array