From 04b3b527268bc4038bc911a5d234240841baaba0 Mon Sep 17 00:00:00 2001 From: Adam Krell Date: Thu, 11 Jun 2015 10:46:28 -0700 Subject: [PATCH] Add map type property (standard, satellite, hybrid) to MapView. Summary: Here is an example project demonstrating this pull request: [AKMapView](https://github.com/adamkrell/AKMapView) Closes https://github.com/facebook/react-native/pull/1503 Github Author: Adam Krell Test Plan: Imported from GitHub, without a `Test Plan:` line. --- Libraries/Components/MapView/MapView.js | 13 +++++++++++++ React/Views/RCTConvert+MapKit.h | 1 + React/Views/RCTConvert+MapKit.m | 6 ++++++ React/Views/RCTMapManager.m | 1 + 4 files changed, 21 insertions(+) diff --git a/Libraries/Components/MapView/MapView.js b/Libraries/Components/MapView/MapView.js index 3e387835c..50e36954b 100644 --- a/Libraries/Components/MapView/MapView.js +++ b/Libraries/Components/MapView/MapView.js @@ -82,6 +82,19 @@ var MapView = React.createClass({ */ scrollEnabled: React.PropTypes.bool, + /** + * The map type to be displayed. + * + * - standard: standard road map (default) + * - satellite: satellite view + * - hybrid: satellite view with roads and points of interest overlayed + */ + mapType: React.PropTypes.oneOf([ + 'standard', + 'satellite', + 'hybrid', + ]), + /** * The region to be displayed by the map. * diff --git a/React/Views/RCTConvert+MapKit.h b/React/Views/RCTConvert+MapKit.h index 8ad9316a1..d4bf8d2d7 100644 --- a/React/Views/RCTConvert+MapKit.h +++ b/React/Views/RCTConvert+MapKit.h @@ -15,6 +15,7 @@ + (MKCoordinateSpan)MKCoordinateSpan:(id)json; + (MKCoordinateRegion)MKCoordinateRegion:(id)json; + (MKShape *)MKShape:(id)json; ++ (MKMapType)MKMapType:(id)json; typedef NSArray MKShapeArray; + (MKShapeArray *)MKShapeArray:(id)json; diff --git a/React/Views/RCTConvert+MapKit.m b/React/Views/RCTConvert+MapKit.m index cd6c9fb41..6dc541a46 100644 --- a/React/Views/RCTConvert+MapKit.m +++ b/React/Views/RCTConvert+MapKit.m @@ -43,4 +43,10 @@ RCT_ARRAY_CONVERTER(MKShape) +RCT_ENUM_CONVERTER(MKMapType, (@{ + @"standard": @(MKMapTypeStandard), + @"satellite": @(MKMapTypeSatellite), + @"hybrid": @(MKMapTypeHybrid), +}), MKMapTypeStandard, integerValue) + @end diff --git a/React/Views/RCTMapManager.m b/React/Views/RCTMapManager.m index 8d334f60b..7a9401fdd 100644 --- a/React/Views/RCTMapManager.m +++ b/React/Views/RCTMapManager.m @@ -41,6 +41,7 @@ RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(maxDelta, CGFloat) RCT_EXPORT_VIEW_PROPERTY(minDelta, CGFloat) RCT_EXPORT_VIEW_PROPERTY(legalLabelInsets, UIEdgeInsets) +RCT_EXPORT_VIEW_PROPERTY(mapType, MKMapType) RCT_EXPORT_VIEW_PROPERTY(annotations, MKShapeArray) RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap) {