react-native-maps 2.0.0-beta.5 → 2.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/rnmaps/maps/MapCalloutManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapCircleManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapGradientPolyline.java +4 -4
- package/android/src/main/java/com/rnmaps/maps/MapGradientPolylineManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapHeatmapManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapLiteManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapLocalTile.java +4 -4
- package/android/src/main/java/com/rnmaps/maps/MapLocalTileManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +9 -26
- package/android/src/main/java/com/rnmaps/maps/MapOverlayManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapPolygonManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapPolylineManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapTileProvider.java +4 -4
- package/android/src/main/java/com/rnmaps/maps/MapUrlTileManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapView.java +9 -9
- package/android/src/main/java/com/rnmaps/maps/{MapModule.java → MapViewModule.java} +18 -18
- package/android/src/main/java/com/rnmaps/maps/MapWMSTile.java +6 -6
- package/android/src/main/java/com/rnmaps/maps/MapWMSTileManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapsPackage.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/SizeReportingShadowNode.java +1 -1
- package/ios/{AirGoogleMaps/AIRDummyView.h → GoogleMaps/RNMDummyView.h} +3 -3
- package/ios/{AirGoogleMaps/AIRDummyView.m → GoogleMaps/RNMDummyView.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSMarker.h → GoogleMaps/RNMGMSMarker.h} +6 -6
- package/ios/{AirGoogleMaps/AIRGMSMarker.m → GoogleMaps/RNMGMSMarker.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolygon.h → GoogleMaps/RNMGMSPolygon.h} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolygon.m → GoogleMaps/RNMGMSPolygon.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolyline.h → GoogleMaps/RNMGMSPolyline.h} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolyline.m → GoogleMaps/RNMGMSPolyline.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMap.h → GoogleMaps/RNMGoogleMap.h} +5 -5
- package/ios/{AirGoogleMaps/AIRGoogleMap.m → GoogleMaps/RNMGoogleMap.m} +77 -77
- package/ios/{AirGoogleMaps/AIRGoogleMapCallout.h → GoogleMaps/RNMGoogleMapCallout.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCallout.m → GoogleMaps/RNMGoogleMapCallout.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutManager.h → GoogleMaps/RNMGoogleMapCalloutManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutManager.m → GoogleMaps/RNMGoogleMapCalloutManager.m} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutSubview.h → GoogleMaps/RNMGoogleMapCalloutSubview.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutSubview.m → GoogleMaps/RNMGoogleMapCalloutSubview.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutSubviewManager.h → GoogleMaps/RNMGoogleMapCalloutSubviewManager.h} +3 -3
- package/ios/GoogleMaps/RNMGoogleMapCalloutSubviewManager.m +28 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapCircle.h → GoogleMaps/RNMGoogleMapCircle.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCircle.m → GoogleMaps/RNMGoogleMapCircle.m} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCircleManager.h → GoogleMaps/RNMGoogleMapCircleManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapCircleManager.m → GoogleMaps/RNMGoogleMapCircleManager.m} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapHeatmap.h → GoogleMaps/RNMGoogleMapHeatmap.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapHeatmap.m → GoogleMaps/RNMGoogleMapHeatmap.m} +4 -4
- package/ios/GoogleMaps/RNMGoogleMapHeatmapManager.h +11 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapHeatmapManager.m → GoogleMaps/RNMGoogleMapHeatmapManager.m} +9 -9
- package/ios/{AirGoogleMaps/AIRGoogleMapManager.h → GoogleMaps/RNMGoogleMapManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapManager.m → GoogleMaps/RNMGoogleMapManager.m} +63 -229
- package/ios/{AirGoogleMaps/AIRGoogleMapMarker.h → GoogleMaps/RNMGoogleMapMarker.h} +15 -15
- package/ios/{AirGoogleMaps/AIRGoogleMapMarker.m → GoogleMaps/RNMGoogleMapMarker.m} +22 -22
- package/ios/{AirGoogleMaps/AIRGoogleMapMarkerManager.h → GoogleMaps/RNMGoogleMapMarkerManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapMarkerManager.m → GoogleMaps/RNMGoogleMapMarkerManager.m} +20 -20
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlay.h → GoogleMaps/RNMGoogleMapOverlay.h} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlay.m → GoogleMaps/RNMGoogleMapOverlay.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlayManager.h → GoogleMaps/RNMGoogleMapOverlayManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlayManager.m → GoogleMaps/RNMGoogleMapOverlayManager.m} +6 -6
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygon.h → GoogleMaps/RNMGoogleMapPolygon.h} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygon.m → GoogleMaps/RNMGoogleMapPolygon.m} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapPolylineManager.h → GoogleMaps/RNMGoogleMapPolygonManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygonManager.m → GoogleMaps/RNMGoogleMapPolygonManager.m} +10 -10
- package/ios/{AirGoogleMaps/AIRGoogleMapPolyline.h → GoogleMaps/RNMGoogleMapPolyline.h} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapPolyline.m → GoogleMaps/RNMGoogleMapPolyline.m} +9 -9
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygonManager.h → GoogleMaps/RNMGoogleMapPolylineManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapPolylineManager.m → GoogleMaps/RNMGoogleMapPolylineManager.m} +9 -9
- package/ios/{AirGoogleMaps/AIRGoogleMapUrlTile.h → GoogleMaps/RNMGoogleMapUrlTile.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapUrlTile.m → GoogleMaps/RNMGoogleMapUrlTile.m} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapUrlTileManager.h → GoogleMaps/RNMGoogleMapUrlTileManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapURLTileManager.m → GoogleMaps/RNMGoogleMapUrlTileManager.m} +7 -7
- package/ios/GoogleMaps/RNMGoogleMapViewModule.h +5 -0
- package/ios/GoogleMaps/RNMGoogleMapViewModule.m +183 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTile.h → GoogleMaps/RNMGoogleMapWMSTile.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTile.m → GoogleMaps/RNMGoogleMapWMSTile.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTileManager.h → GoogleMaps/RNMGoogleMapWMSTileManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTileManager.m → GoogleMaps/RNMGoogleMapWMSTileManager.m} +8 -8
- package/ios/{AirMaps → Maps}/Callout/SMCalloutView.h +4 -4
- package/ios/{AirMaps/RCTConvert+AirMap.h → Maps/RCTConvert+RNMMap.h} +1 -1
- package/ios/{AirMaps/RCTConvert+AirMap.m → Maps/RCTConvert+RNMMap.m} +8 -8
- package/ios/{AirMaps/AIRMap.h → Maps/RNMMap.h} +8 -8
- package/ios/{AirMaps/AIRMap.m → Maps/RNMMap.m} +56 -56
- package/ios/{AirMaps/AIRMapCallout.h → Maps/RNMMapCallout.h} +1 -1
- package/ios/{AirMaps/AIRMapCallout.m → Maps/RNMMapCallout.m} +2 -2
- package/ios/{AirMaps/AIRMapCircleManager.h → Maps/RNMMapCalloutManager.h} +2 -2
- package/ios/{AirMaps/AIRMapCalloutManager.m → Maps/RNMMapCalloutManager.m} +7 -7
- package/ios/{AirMaps/AIRMapCalloutSubview.h → Maps/RNMMapCalloutSubview.h} +3 -3
- package/ios/{AirMaps/AIRMapCalloutSubview.m → Maps/RNMMapCalloutSubview.m} +4 -4
- package/ios/Maps/RNMMapCalloutSubviewManager.h +14 -0
- package/ios/Maps/RNMMapCalloutSubviewManager.m +24 -0
- package/ios/{AirMaps/AIRMapCircle.h → Maps/RNMMapCircle.h} +5 -5
- package/ios/{AirMaps/AIRMapCircle.m → Maps/RNMMapCircle.m} +3 -3
- package/ios/{AirMaps/AIRMapCalloutManager.h → Maps/RNMMapCircleManager.h} +2 -2
- package/ios/{AirMaps/AIRMapCircleManager.m → Maps/RNMMapCircleManager.m} +7 -7
- package/ios/{AirMaps/AIRMapCoordinate.h → Maps/RNMMapCoordinate.h} +2 -2
- package/ios/{AirMaps/AIRMapCoordinate.m → Maps/RNMMapCoordinate.m} +3 -3
- package/ios/{AirMaps/AIRMapLocalTile.h → Maps/RNMMapLocalTile.h} +7 -7
- package/ios/{AirMaps/AIRMapLocalTile.m → Maps/RNMMapLocalTile.m} +6 -6
- package/ios/{AirMaps/AIRMapLocalTileManager.h → Maps/RNMMapLocalTileManager.h} +3 -3
- package/ios/{AirMaps/AIRMapLocalTileManager.m → Maps/RNMMapLocalTileManager.m} +9 -9
- package/ios/{AirMaps/AIRMapLocalTileOverlay.h → Maps/RNMMapLocalTileOverlay.h} +2 -2
- package/ios/{AirMaps/AIRMapLocalTileOverlay.m → Maps/RNMMapLocalTileOverlay.m} +5 -5
- package/ios/{AirMaps/AIRMapManager.h → Maps/RNMMapManager.h} +6 -6
- package/ios/{AirMaps/AIRMapManager.m → Maps/RNMMapManager.m} +168 -445
- package/ios/{AirMaps/AIRMapMarker.h → Maps/RNMMapMarker.h} +8 -8
- package/ios/{AirMaps/AIRMapMarker.m → Maps/RNMMapMarker.m} +13 -13
- package/ios/{AirMaps/AIRMapMarkerManager.h → Maps/RNMMapMarkerManager.h} +1 -1
- package/ios/{AirMaps/AIRMapMarkerManager.m → Maps/RNMMapMarkerManager.m} +14 -14
- package/ios/{AirMaps/AIRMapOverlay.h → Maps/RNMMapOverlay.h} +7 -7
- package/ios/{AirMaps/AIRMapOverlay.m → Maps/RNMMapOverlay.m} +4 -4
- package/ios/Maps/RNMMapOverlayManager.h +5 -0
- package/ios/{AirMaps/AIRMapOverlayManager.m → Maps/RNMMapOverlayManager.m} +6 -6
- package/ios/{AirMaps/AIRMapOverlayRenderer.h → Maps/RNMMapOverlayRenderer.h} +1 -1
- package/ios/{AirMaps/AIRMapOverlayRenderer.m → Maps/RNMMapOverlayRenderer.m} +5 -5
- package/ios/{AirMaps/AIRMapPolygon.h → Maps/RNMMapPolygon.h} +7 -7
- package/ios/{AirMaps/AIRMapPolygon.m → Maps/RNMMapPolygon.m} +4 -4
- package/ios/{AirMaps/AIRMapPolygonManager.h → Maps/RNMMapPolygonManager.h} +2 -2
- package/ios/{AirMaps/AIRMapPolygonManager.m → Maps/RNMMapPolygonManager.m} +10 -10
- package/ios/{AirMaps/AIRMapPolyline.h → Maps/RNMMapPolyline.h} +6 -6
- package/ios/{AirMaps/AIRMapPolyline.m → Maps/RNMMapPolyline.m} +11 -11
- package/ios/{AirMaps/AIRMapPolylineManager.h → Maps/RNMMapPolylineManager.h} +2 -2
- package/ios/{AirMaps/AIRMapPolylineManager.m → Maps/RNMMapPolylineManager.m} +9 -9
- package/ios/{AirMaps/AIRMapPolylineRenderer.h → Maps/RNMMapPolylineRenderer.h} +2 -2
- package/ios/{AirMaps/AIRMapPolylineRenderer.m → Maps/RNMMapPolylineRenderer.m} +10 -10
- package/ios/{AirMaps/AIRMapSnapshot.h → Maps/RNMMapSnapshot.h} +6 -6
- package/ios/{AirMaps/AIRMapUrlTile.h → Maps/RNMMapUrlTile.h} +18 -18
- package/ios/{AirMaps/AIRMapUrlTile.m → Maps/RNMMapUrlTile.m} +7 -7
- package/ios/{AirMaps/AIRMapUrlTileCachedOverlay.h → Maps/RNMMapUrlTileCachedOverlay.h} +3 -3
- package/ios/{AirMaps/AIRMapUrlTileCachedOverlay.m → Maps/RNMMapUrlTileCachedOverlay.m} +10 -10
- package/ios/{AirMaps/AIRMapUrlTileManager.h → Maps/RNMMapUrlTileManager.h} +3 -3
- package/ios/{AirMaps/AIRMapUrlTileManager.m → Maps/RNMMapUrlTileManager.m} +9 -9
- package/ios/Maps/RNMMapViewModule.h +5 -0
- package/ios/Maps/RNMMapViewModule.m +297 -0
- package/ios/{AirMaps/AIRMapWMSTile.h → Maps/RNMMapWMSTile.h} +11 -11
- package/ios/{AirMaps/AIRMapWMSTile.m → Maps/RNMMapWMSTile.m} +15 -15
- package/ios/{AirMaps/AIRMapWMSTileManager.h → Maps/RNMMapWMSTileManager.h} +3 -3
- package/ios/{AirMaps/AIRMapWMSTileManager.m → Maps/RNMMapWMSTileManager.m} +9 -9
- package/ios/RNMaps.xcodeproj/project.pbxproj +647 -0
- package/lib/MapCallout.js +2 -2
- package/lib/MapCalloutSubview.js +2 -2
- package/lib/MapCircle.js +2 -2
- package/lib/MapHeatmap.js +2 -2
- package/lib/MapLocalTile.js +2 -2
- package/lib/MapMarker.js +2 -2
- package/lib/MapOverlay.js +2 -2
- package/lib/MapPolygon.js +2 -2
- package/lib/MapPolyline.js +2 -2
- package/lib/MapUrlTile.js +2 -2
- package/lib/MapView.d.ts +2 -3
- package/lib/MapView.js +71 -84
- package/lib/MapView.types.d.ts +7 -1
- package/lib/MapWMSTile.js +2 -2
- package/lib/NativeGoogleMapViewModule.d.ts +20 -0
- package/lib/NativeGoogleMapViewModule.js +4 -0
- package/lib/NativeMapViewModule.d.ts +24 -0
- package/lib/NativeMapViewModule.js +4 -0
- package/lib/decorateMapComponent.d.ts +1 -1
- package/lib/decorateMapComponent.js +3 -3
- package/package.json +1 -1
- package/react-native-google-maps.podspec +1 -1
- package/react-native-maps.podspec +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapCalloutSubviewManager.m +0 -28
- package/ios/AirGoogleMaps/AIRGoogleMapHeatmapManager.h +0 -11
- package/ios/AirMaps/AIRMapCalloutSubviewManager.h +0 -14
- package/ios/AirMaps/AIRMapCalloutSubviewManager.m +0 -24
- package/ios/AirMaps/AIRMapOverlayManager.h +0 -5
- package/ios/AirMaps/AIRWeakMapReference.h +0 -24
- package/ios/AirMaps/AIRWeakMapReference.m +0 -23
- package/ios/AirMaps/AIRWeakTimerReference.h +0 -21
- package/ios/AirMaps/AIRWeakTimerReference.m +0 -42
- package/ios/AirMaps.xcodeproj/project.pbxproj +0 -587
- /package/ios/{AirGoogleMaps → GoogleMaps}/RCTConvert+GMSMapViewType.h +0 -0
- /package/ios/{AirGoogleMaps → GoogleMaps}/RCTConvert+GMSMapViewType.m +0 -0
- /package/ios/{AirMaps → Maps}/Callout/SMCalloutView.m +0 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
#import "
|
|
10
|
+
#import "RNMMapManager.h"
|
|
11
11
|
|
|
12
12
|
#import <React/RCTBridge.h>
|
|
13
13
|
#import <React/RCTUIManager.h>
|
|
@@ -16,38 +16,38 @@
|
|
|
16
16
|
#import <React/RCTEventDispatcher.h>
|
|
17
17
|
#import <React/RCTViewManager.h>
|
|
18
18
|
#import <React/UIView+React.h>
|
|
19
|
-
#import "
|
|
20
|
-
#import "
|
|
21
|
-
#import "
|
|
22
|
-
#import "
|
|
23
|
-
#import "
|
|
19
|
+
#import "RNMMap.h"
|
|
20
|
+
#import "RNMMapMarker.h"
|
|
21
|
+
#import "RNMMapPolyline.h"
|
|
22
|
+
#import "RNMMapPolygon.h"
|
|
23
|
+
#import "RNMMapCircle.h"
|
|
24
24
|
#import "SMCalloutView.h"
|
|
25
|
-
#import "
|
|
26
|
-
#import "
|
|
27
|
-
#import "
|
|
28
|
-
#import "
|
|
29
|
-
#import "RCTConvert+
|
|
30
|
-
#import "
|
|
25
|
+
#import "RNMMapUrlTile.h"
|
|
26
|
+
#import "RNMMapWMSTile.h"
|
|
27
|
+
#import "RNMMapLocalTile.h"
|
|
28
|
+
#import "RNMMapSnapshot.h"
|
|
29
|
+
#import "RCTConvert+RNMMap.h"
|
|
30
|
+
#import "RNMMapOverlay.h"
|
|
31
31
|
#import <MapKit/MapKit.h>
|
|
32
32
|
|
|
33
33
|
static NSString *const RCTMapViewKey = @"MapView";
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
@interface
|
|
36
|
+
@interface RNMMapManager() <MKMapViewDelegate, UIGestureRecognizerDelegate>
|
|
37
37
|
|
|
38
38
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
|
|
39
39
|
|
|
40
40
|
@end
|
|
41
41
|
|
|
42
|
-
@implementation
|
|
42
|
+
@implementation RNMMapManager{
|
|
43
43
|
BOOL _hasObserver;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
RCT_EXPORT_MODULE()
|
|
46
|
+
RCT_EXPORT_MODULE(RNMMap)
|
|
47
47
|
|
|
48
48
|
- (UIView *)view
|
|
49
49
|
{
|
|
50
|
-
|
|
50
|
+
RNMMap *map = [RNMMap new];
|
|
51
51
|
map.delegate = self;
|
|
52
52
|
|
|
53
53
|
map.isAccessibilityElement = NO;
|
|
@@ -124,7 +124,7 @@ RCT_EXPORT_VIEW_PROPERTY(onMarkerDrag, RCTDirectEventBlock)
|
|
|
124
124
|
RCT_EXPORT_VIEW_PROPERTY(onMarkerDragEnd, RCTDirectEventBlock)
|
|
125
125
|
RCT_EXPORT_VIEW_PROPERTY(onCalloutPress, RCTDirectEventBlock)
|
|
126
126
|
RCT_EXPORT_VIEW_PROPERTY(onUserLocationChange, RCTBubblingEventBlock)
|
|
127
|
-
RCT_CUSTOM_VIEW_PROPERTY(initialRegion, MKCoordinateRegion,
|
|
127
|
+
RCT_CUSTOM_VIEW_PROPERTY(initialRegion, MKCoordinateRegion, RNMMap)
|
|
128
128
|
{
|
|
129
129
|
if (json == nil) return;
|
|
130
130
|
|
|
@@ -134,7 +134,7 @@ RCT_CUSTOM_VIEW_PROPERTY(initialRegion, MKCoordinateRegion, AIRMap)
|
|
|
134
134
|
[view setInitialRegion:[RCTConvert MKCoordinateRegion:json]];
|
|
135
135
|
view.ignoreRegionChanges = originalIgnore;
|
|
136
136
|
}
|
|
137
|
-
RCT_CUSTOM_VIEW_PROPERTY(initialCamera, MKMapCamera,
|
|
137
|
+
RCT_CUSTOM_VIEW_PROPERTY(initialCamera, MKMapCamera, RNMMap)
|
|
138
138
|
{
|
|
139
139
|
if (json == nil) return;
|
|
140
140
|
|
|
@@ -150,7 +150,7 @@ RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, CGFloat)
|
|
|
150
150
|
RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, CGFloat)
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion,
|
|
153
|
+
RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RNMMap)
|
|
154
154
|
{
|
|
155
155
|
if (json == nil) return;
|
|
156
156
|
|
|
@@ -161,7 +161,7 @@ RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, AIRMap)
|
|
|
161
161
|
view.ignoreRegionChanges = originalIgnore;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
RCT_CUSTOM_VIEW_PROPERTY(camera, MKMapCamera*,
|
|
164
|
+
RCT_CUSTOM_VIEW_PROPERTY(camera, MKMapCamera*, RNMMap)
|
|
165
165
|
{
|
|
166
166
|
if (json == nil) return;
|
|
167
167
|
|
|
@@ -175,67 +175,15 @@ RCT_CUSTOM_VIEW_PROPERTY(camera, MKMapCamera*, AIRMap)
|
|
|
175
175
|
|
|
176
176
|
#pragma mark exported MapView methods
|
|
177
177
|
|
|
178
|
-
RCT_EXPORT_METHOD(getMapBoundaries:(nonnull NSNumber *)reactTag
|
|
179
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
180
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
181
|
-
{
|
|
182
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
183
|
-
id view = viewRegistry[reactTag];
|
|
184
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
185
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
186
|
-
} else {
|
|
187
|
-
NSArray *boundingBox = [view getMapBoundaries];
|
|
188
|
-
|
|
189
|
-
resolve(@{
|
|
190
|
-
@"northEast" : @{
|
|
191
|
-
@"longitude" : boundingBox[0][0],
|
|
192
|
-
@"latitude" : boundingBox[0][1]
|
|
193
|
-
},
|
|
194
|
-
@"southWest" : @{
|
|
195
|
-
@"longitude" : boundingBox[1][0],
|
|
196
|
-
@"latitude" : boundingBox[1][1]
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
RCT_EXPORT_METHOD(getCamera:(nonnull NSNumber *)reactTag
|
|
206
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
207
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
208
|
-
{
|
|
209
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
210
|
-
id view = viewRegistry[reactTag];
|
|
211
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
212
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
213
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting AIRMap, got: %@", view], NULL);
|
|
214
|
-
} else {
|
|
215
|
-
MKMapCamera *camera = [mapView camera];
|
|
216
|
-
resolve(@{
|
|
217
|
-
@"center": @{
|
|
218
|
-
@"latitude": @(camera.centerCoordinate.latitude),
|
|
219
|
-
@"longitude": @(camera.centerCoordinate.longitude),
|
|
220
|
-
},
|
|
221
|
-
@"pitch": @(camera.pitch),
|
|
222
|
-
@"heading": @(camera.heading),
|
|
223
|
-
@"altitude": @(camera.altitude),
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
178
|
RCT_EXPORT_METHOD(setCamera:(nonnull NSNumber *)reactTag
|
|
231
179
|
camera:(id)json)
|
|
232
180
|
{
|
|
233
181
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
234
182
|
id view = viewRegistry[reactTag];
|
|
235
|
-
if (![view isKindOfClass:[
|
|
236
|
-
RCTLogError(@"Invalid view returned from registry, expecting
|
|
183
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
184
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
237
185
|
} else {
|
|
238
|
-
|
|
186
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
239
187
|
|
|
240
188
|
// Merge the changes given with the current camera
|
|
241
189
|
MKMapCamera *camera = [RCTConvert MKMapCameraWithDefaults:json existingCamera:[mapView camera]];
|
|
@@ -249,17 +197,16 @@ RCT_EXPORT_METHOD(setCamera:(nonnull NSNumber *)reactTag
|
|
|
249
197
|
}];
|
|
250
198
|
}
|
|
251
199
|
|
|
252
|
-
|
|
253
200
|
RCT_EXPORT_METHOD(animateCamera:(nonnull NSNumber *)reactTag
|
|
254
201
|
withCamera:(id)json
|
|
255
202
|
withDuration:(CGFloat)duration)
|
|
256
203
|
{
|
|
257
204
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
258
205
|
id view = viewRegistry[reactTag];
|
|
259
|
-
if (![view isKindOfClass:[
|
|
260
|
-
RCTLogError(@"Invalid view returned from registry, expecting
|
|
206
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
207
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
261
208
|
} else {
|
|
262
|
-
|
|
209
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
263
210
|
|
|
264
211
|
// Merge the changes given with the current camera
|
|
265
212
|
MKMapCamera *camera = [RCTConvert MKMapCameraWithDefaults:json existingCamera:[mapView camera]];
|
|
@@ -267,7 +214,7 @@ RCT_EXPORT_METHOD(animateCamera:(nonnull NSNumber *)reactTag
|
|
|
267
214
|
// don't emit region change events when we are setting the camera
|
|
268
215
|
BOOL originalIgnore = mapView.ignoreRegionChanges;
|
|
269
216
|
mapView.ignoreRegionChanges = YES;
|
|
270
|
-
[
|
|
217
|
+
[RNMMap animateWithDuration:duration/1000 animations:^{
|
|
271
218
|
[mapView setCamera:camera animated:YES];
|
|
272
219
|
} completion:^(BOOL finished){
|
|
273
220
|
mapView.ignoreRegionChanges = originalIgnore;
|
|
@@ -282,11 +229,11 @@ RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
|
|
|
282
229
|
{
|
|
283
230
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
284
231
|
id view = viewRegistry[reactTag];
|
|
285
|
-
if (![view isKindOfClass:[
|
|
286
|
-
RCTLogError(@"Invalid view returned from registry, expecting
|
|
232
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
233
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
287
234
|
} else {
|
|
288
|
-
[
|
|
289
|
-
[(
|
|
235
|
+
[RNMMap animateWithDuration:duration/1000 animations:^{
|
|
236
|
+
[(RNMMap *)view setRegion:region animated:YES];
|
|
290
237
|
}];
|
|
291
238
|
}
|
|
292
239
|
}];
|
|
@@ -298,10 +245,10 @@ RCT_EXPORT_METHOD(fitToElements:(nonnull NSNumber *)reactTag
|
|
|
298
245
|
{
|
|
299
246
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
300
247
|
id view = viewRegistry[reactTag];
|
|
301
|
-
if (![view isKindOfClass:[
|
|
302
|
-
RCTLogError(@"Invalid view returned from registry, expecting
|
|
248
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
249
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
303
250
|
} else {
|
|
304
|
-
|
|
251
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
305
252
|
// TODO(lmr): we potentially want to include overlays here... and could concat the two arrays together.
|
|
306
253
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
307
254
|
[mapView showAnnotations:mapView.annotations animated:animated];
|
|
@@ -317,16 +264,16 @@ RCT_EXPORT_METHOD(fitToSuppliedMarkers:(nonnull NSNumber *)reactTag
|
|
|
317
264
|
{
|
|
318
265
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
319
266
|
id view = viewRegistry[reactTag];
|
|
320
|
-
if (![view isKindOfClass:[
|
|
321
|
-
RCTLogError(@"Invalid view returned from registry, expecting
|
|
267
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
268
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
322
269
|
} else {
|
|
323
|
-
|
|
270
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
324
271
|
// TODO(lmr): we potentially want to include overlays here... and could concat the two arrays together.
|
|
325
272
|
// id annotations = mapView.annotations;
|
|
326
273
|
|
|
327
274
|
NSPredicate *filterMarkers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
|
|
328
|
-
|
|
329
|
-
return [marker isKindOfClass:[
|
|
275
|
+
RNMMapMarker *marker = (RNMMapMarker *)evaluatedObject;
|
|
276
|
+
return [marker isKindOfClass:[RNMMapMarker class]] && [markers containsObject:marker.identifier];
|
|
330
277
|
}];
|
|
331
278
|
|
|
332
279
|
NSArray *filteredMarkers = [mapView.annotations filteredArrayUsingPredicate:filterMarkers];
|
|
@@ -338,16 +285,16 @@ RCT_EXPORT_METHOD(fitToSuppliedMarkers:(nonnull NSNumber *)reactTag
|
|
|
338
285
|
}
|
|
339
286
|
|
|
340
287
|
RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
|
|
341
|
-
coordinates:(nonnull NSArray<
|
|
288
|
+
coordinates:(nonnull NSArray<RNMMapCoordinate *> *)coordinates
|
|
342
289
|
edgePadding:(nonnull NSDictionary *)edgePadding
|
|
343
290
|
animated:(BOOL)animated)
|
|
344
291
|
{
|
|
345
292
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
346
293
|
id view = viewRegistry[reactTag];
|
|
347
|
-
if (![view isKindOfClass:[
|
|
348
|
-
RCTLogError(@"Invalid view returned from registry, expecting
|
|
294
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
295
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
349
296
|
} else {
|
|
350
|
-
|
|
297
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
351
298
|
|
|
352
299
|
// Create Polyline with coordinates
|
|
353
300
|
CLLocationCoordinate2D coords[coordinates.count];
|
|
@@ -369,235 +316,11 @@ RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
|
|
|
369
316
|
}];
|
|
370
317
|
}
|
|
371
318
|
|
|
372
|
-
RCT_EXPORT_METHOD(takeSnapshot:(nonnull NSNumber *)reactTag
|
|
373
|
-
width:(nonnull NSNumber *)width
|
|
374
|
-
height:(nonnull NSNumber *)height
|
|
375
|
-
region:(MKCoordinateRegion)region
|
|
376
|
-
format:(nonnull NSString *)format
|
|
377
|
-
quality:(nonnull NSNumber *)quality
|
|
378
|
-
result:(nonnull NSString *)result
|
|
379
|
-
callback:(RCTResponseSenderBlock)callback)
|
|
380
|
-
{
|
|
381
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
382
|
-
id view = viewRegistry[reactTag];
|
|
383
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
384
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
385
|
-
} else {
|
|
386
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
387
|
-
MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
|
|
388
|
-
|
|
389
|
-
options.mapType = mapView.mapType;
|
|
390
|
-
options.region = (region.center.latitude && region.center.longitude) ? region : mapView.region;
|
|
391
|
-
options.size = CGSizeMake(
|
|
392
|
-
([width floatValue] == 0) ? mapView.bounds.size.width : [width floatValue],
|
|
393
|
-
([height floatValue] == 0) ? mapView.bounds.size.height : [height floatValue]
|
|
394
|
-
);
|
|
395
|
-
options.scale = [[UIScreen mainScreen] scale];
|
|
396
|
-
|
|
397
|
-
MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
|
|
398
|
-
|
|
399
|
-
[self takeMapSnapshot:mapView
|
|
400
|
-
snapshotter:snapshotter
|
|
401
|
-
format:format
|
|
402
|
-
quality:quality.floatValue
|
|
403
|
-
result:result
|
|
404
|
-
callback:callback];
|
|
405
|
-
}
|
|
406
|
-
}];
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
RCT_EXPORT_METHOD(pointForCoordinate:(nonnull NSNumber *)reactTag
|
|
410
|
-
coordinate: (NSDictionary *)coordinate
|
|
411
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
412
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
413
|
-
{
|
|
414
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
415
|
-
id view = viewRegistry[reactTag];
|
|
416
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
417
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
418
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting AIRMap, got: %@", view], NULL);
|
|
419
|
-
} else {
|
|
420
|
-
CGPoint touchPoint = [mapView convertCoordinate:
|
|
421
|
-
CLLocationCoordinate2DMake(
|
|
422
|
-
[coordinate[@"latitude"] doubleValue],
|
|
423
|
-
[coordinate[@"longitude"] doubleValue]
|
|
424
|
-
)
|
|
425
|
-
toPointToView:mapView];
|
|
426
|
-
|
|
427
|
-
resolve(@{
|
|
428
|
-
@"x": @(touchPoint.x),
|
|
429
|
-
@"y": @(touchPoint.y),
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
}];
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
RCT_EXPORT_METHOD(getMarkersFrames:(nonnull NSNumber *)reactTag
|
|
436
|
-
onlyVisible:(BOOL)onlyVisible
|
|
437
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
438
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
439
|
-
{
|
|
440
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
441
|
-
id view = viewRegistry[reactTag];
|
|
442
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
443
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
444
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting AIRMap, got: %@", view], NULL);
|
|
445
|
-
} else {
|
|
446
|
-
resolve([mapView getMarkersFramesWithOnlyVisible:onlyVisible]);
|
|
447
|
-
}
|
|
448
|
-
}];
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
RCT_EXPORT_METHOD(coordinateForPoint:(nonnull NSNumber *)reactTag
|
|
454
|
-
point:(NSDictionary *)point
|
|
455
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
456
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
457
|
-
{
|
|
458
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
459
|
-
id view = viewRegistry[reactTag];
|
|
460
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
461
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
462
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting AIRMap, got: %@", view], NULL);
|
|
463
|
-
} else {
|
|
464
|
-
CLLocationCoordinate2D coordinate = [mapView convertPoint:
|
|
465
|
-
CGPointMake(
|
|
466
|
-
[point[@"x"] doubleValue],
|
|
467
|
-
[point[@"y"] doubleValue]
|
|
468
|
-
)
|
|
469
|
-
toCoordinateFromView:mapView];
|
|
470
|
-
|
|
471
|
-
resolve(@{
|
|
472
|
-
@"latitude": @(coordinate.latitude),
|
|
473
|
-
@"longitude": @(coordinate.longitude),
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
}];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
480
|
-
coordinate: (NSDictionary *)coordinate
|
|
481
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
482
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
483
|
-
{
|
|
484
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
485
|
-
id view = viewRegistry[reactTag];
|
|
486
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
487
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting AIRMap, got: %@", view], NULL);
|
|
488
|
-
} else {
|
|
489
|
-
if (coordinate == nil ||
|
|
490
|
-
![[coordinate allKeys] containsObject:@"latitude"] ||
|
|
491
|
-
![[coordinate allKeys] containsObject:@"longitude"]) {
|
|
492
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid coordinate format"], NULL);
|
|
493
|
-
}
|
|
494
|
-
CLLocation *location = [[CLLocation alloc] initWithLatitude:[coordinate[@"latitude"] doubleValue]
|
|
495
|
-
longitude:[coordinate[@"longitude"] doubleValue]];
|
|
496
|
-
CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
|
|
497
|
-
[geoCoder reverseGeocodeLocation:location
|
|
498
|
-
completionHandler:^(NSArray *placemarks, NSError *error) {
|
|
499
|
-
if (error == nil && [placemarks count] > 0){
|
|
500
|
-
CLPlacemark *placemark = placemarks[0];
|
|
501
|
-
resolve(@{
|
|
502
|
-
@"name" : [NSString stringWithFormat:@"%@", placemark.name],
|
|
503
|
-
@"thoroughfare" : [NSString stringWithFormat:@"%@", placemark.thoroughfare],
|
|
504
|
-
@"subThoroughfare" : [NSString stringWithFormat:@"%@", placemark.subThoroughfare],
|
|
505
|
-
@"locality" : [NSString stringWithFormat:@"%@", placemark.locality],
|
|
506
|
-
@"subLocality" : [NSString stringWithFormat:@"%@", placemark.subLocality],
|
|
507
|
-
@"administrativeArea" : [NSString stringWithFormat:@"%@", placemark.administrativeArea],
|
|
508
|
-
@"subAdministrativeArea" : [NSString stringWithFormat:@"%@", placemark.subAdministrativeArea],
|
|
509
|
-
@"postalCode" : [NSString stringWithFormat:@"%@", placemark.postalCode],
|
|
510
|
-
@"countryCode" : [NSString stringWithFormat:@"%@", placemark.ISOcountryCode],
|
|
511
|
-
@"country" : [NSString stringWithFormat:@"%@", placemark.country],
|
|
512
|
-
});
|
|
513
|
-
} else {
|
|
514
|
-
reject(@"Invalid argument", [NSString stringWithFormat:@"Can not get address location"], NULL);
|
|
515
|
-
}
|
|
516
|
-
}];
|
|
517
|
-
}
|
|
518
|
-
}];
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
#pragma mark Take Snapshot
|
|
522
|
-
- (void)takeMapSnapshot:(AIRMap *)mapView
|
|
523
|
-
snapshotter:(MKMapSnapshotter *) snapshotter
|
|
524
|
-
format:(NSString *)format
|
|
525
|
-
quality:(CGFloat) quality
|
|
526
|
-
result:(NSString *)result
|
|
527
|
-
callback:(RCTResponseSenderBlock) callback {
|
|
528
|
-
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
|
|
529
|
-
NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
|
|
530
|
-
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
|
|
531
|
-
|
|
532
|
-
[snapshotter startWithQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
|
|
533
|
-
completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
|
|
534
|
-
if (error) {
|
|
535
|
-
callback(@[error]);
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
MKAnnotationView *pin = [[MKMarkerAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
|
|
539
|
-
|
|
540
|
-
UIImage *image = snapshot.image;
|
|
541
|
-
UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale);
|
|
542
|
-
{
|
|
543
|
-
[image drawAtPoint:CGPointMake(0.0f, 0.0f)];
|
|
544
|
-
|
|
545
|
-
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
|
|
546
|
-
|
|
547
|
-
for (id <AIRMapSnapshot> overlay in mapView.overlays) {
|
|
548
|
-
if ([overlay respondsToSelector:@selector(drawToSnapshot:context:)]) {
|
|
549
|
-
[overlay drawToSnapshot:snapshot context:UIGraphicsGetCurrentContext()];
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
for (id <MKAnnotation> annotation in mapView.annotations) {
|
|
554
|
-
CGPoint point = [snapshot pointForCoordinate:annotation.coordinate];
|
|
555
|
-
|
|
556
|
-
MKAnnotationView* anView = [mapView viewForAnnotation: annotation];
|
|
557
|
-
|
|
558
|
-
if (anView){
|
|
559
|
-
pin = anView;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
if (CGRectContainsPoint(rect, point)) {
|
|
563
|
-
point.x = point.x + pin.centerOffset.x - (pin.bounds.size.width / 2.0f);
|
|
564
|
-
point.y = point.y + pin.centerOffset.y - (pin.bounds.size.height / 2.0f);
|
|
565
|
-
if (pin.image) {
|
|
566
|
-
[pin.image drawAtPoint:point];
|
|
567
|
-
} else {
|
|
568
|
-
CGRect pinRect = CGRectMake(point.x, point.y, pin.bounds.size.width, pin.bounds.size.height);
|
|
569
|
-
[pin drawViewHierarchyInRect:pinRect afterScreenUpdates:NO];
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
UIImage *compositeImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
575
|
-
|
|
576
|
-
NSData *data;
|
|
577
|
-
if ([format isEqualToString:@"png"]) {
|
|
578
|
-
data = UIImagePNGRepresentation(compositeImage);
|
|
579
|
-
}
|
|
580
|
-
else if([format isEqualToString:@"jpg"]) {
|
|
581
|
-
data = UIImageJPEGRepresentation(compositeImage, quality);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
if ([result isEqualToString:@"file"]) {
|
|
585
|
-
[data writeToFile:filePath atomically:YES];
|
|
586
|
-
callback(@[[NSNull null], filePath]);
|
|
587
|
-
}
|
|
588
|
-
else if ([result isEqualToString:@"base64"]) {
|
|
589
|
-
callback(@[[NSNull null], [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]]);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
UIGraphicsEndImageContext();
|
|
593
|
-
}];
|
|
594
|
-
}
|
|
595
|
-
|
|
596
319
|
#pragma mark Gesture Recognizer Handlers
|
|
597
320
|
|
|
598
321
|
#define MAX_DISTANCE_PX 10.0f
|
|
599
322
|
- (void)handleMapTap:(UITapGestureRecognizer *)recognizer {
|
|
600
|
-
|
|
323
|
+
RNMMap *map = (RNMMap *)recognizer.view;
|
|
601
324
|
|
|
602
325
|
CGPoint tapPoint = [recognizer locationInView:map];
|
|
603
326
|
CLLocationCoordinate2D tapCoordinate = [map convertPoint:tapPoint toCoordinateFromView:map];
|
|
@@ -606,16 +329,16 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
606
329
|
|
|
607
330
|
double maxMeters = [self metersFromPixel:MAX_DISTANCE_PX atPoint:tapPoint forMap:map];
|
|
608
331
|
float nearestDistance = MAXFLOAT;
|
|
609
|
-
|
|
332
|
+
RNMMapPolyline *nearestPolyline = nil;
|
|
610
333
|
|
|
611
334
|
for (id<MKOverlay> overlay in map.overlays) {
|
|
612
|
-
if([overlay isKindOfClass:[
|
|
613
|
-
|
|
335
|
+
if([overlay isKindOfClass:[RNMMapPolygon class]]){
|
|
336
|
+
RNMMapPolygon *polygon = (RNMMapPolygon*) overlay;
|
|
614
337
|
if (polygon.onPress) {
|
|
615
338
|
CGMutablePathRef mpr = CGPathCreateMutable();
|
|
616
339
|
|
|
617
340
|
for(int i = 0; i < polygon.coordinates.count; i++) {
|
|
618
|
-
|
|
341
|
+
RNMMapCoordinate *c = polygon.coordinates[i];
|
|
619
342
|
MKMapPoint mp = MKMapPointForCoordinate(c.coordinate);
|
|
620
343
|
if (i == 0) {
|
|
621
344
|
CGPathMoveToPoint(mpr, NULL, mp.x, mp.y);
|
|
@@ -639,8 +362,8 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
639
362
|
}
|
|
640
363
|
}
|
|
641
364
|
|
|
642
|
-
if([overlay isKindOfClass:[
|
|
643
|
-
|
|
365
|
+
if([overlay isKindOfClass:[RNMMapPolyline class]]){
|
|
366
|
+
RNMMapPolyline *polyline = (RNMMapPolyline*) overlay;
|
|
644
367
|
if (polyline.onPress) {
|
|
645
368
|
float distance = [self distanceOfPoint:MKMapPointForCoordinate(tapCoordinate)
|
|
646
369
|
toPoly:polyline];
|
|
@@ -651,8 +374,8 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
651
374
|
}
|
|
652
375
|
}
|
|
653
376
|
|
|
654
|
-
if ([overlay isKindOfClass:[
|
|
655
|
-
|
|
377
|
+
if ([overlay isKindOfClass:[RNMMapOverlay class]]) {
|
|
378
|
+
RNMMapOverlay *imageOverlay = (RNMMapOverlay*) overlay;
|
|
656
379
|
if (MKMapRectContainsPoint(imageOverlay.boundingMapRect, mapPoint)) {
|
|
657
380
|
if (imageOverlay.onPress) {
|
|
658
381
|
id event = @{
|
|
@@ -696,7 +419,7 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
696
419
|
}
|
|
697
420
|
|
|
698
421
|
- (void)handleMapDrag:(UIPanGestureRecognizer*)recognizer {
|
|
699
|
-
|
|
422
|
+
RNMMap *map = (RNMMap *)recognizer.view;
|
|
700
423
|
if (!map.onPanDrag) return;
|
|
701
424
|
|
|
702
425
|
CGPoint touchPoint = [recognizer locationInView:map];
|
|
@@ -715,7 +438,7 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
715
438
|
}
|
|
716
439
|
|
|
717
440
|
- (void)handleMapDoubleTap:(UIPanGestureRecognizer*)recognizer {
|
|
718
|
-
|
|
441
|
+
RNMMap *map = (RNMMap *)recognizer.view;
|
|
719
442
|
if (!map.onDoublePress) return;
|
|
720
443
|
|
|
721
444
|
CGPoint touchPoint = [recognizer locationInView:map];
|
|
@@ -739,7 +462,7 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
739
462
|
// NOTE: android only does the equivalent of "began", so we only send in this case
|
|
740
463
|
if (recognizer.state != UIGestureRecognizerStateBegan) return;
|
|
741
464
|
|
|
742
|
-
|
|
465
|
+
RNMMap *map = (RNMMap *)recognizer.view;
|
|
743
466
|
if (!map.onLongPress) return;
|
|
744
467
|
|
|
745
468
|
CGPoint touchPoint = [recognizer locationInView:map];
|
|
@@ -762,20 +485,20 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
762
485
|
#pragma mark Polyline stuff
|
|
763
486
|
|
|
764
487
|
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay{
|
|
765
|
-
if ([overlay isKindOfClass:[
|
|
766
|
-
return ((
|
|
767
|
-
} else if ([overlay isKindOfClass:[
|
|
768
|
-
return ((
|
|
769
|
-
} else if ([overlay isKindOfClass:[
|
|
770
|
-
return ((
|
|
771
|
-
} else if ([overlay isKindOfClass:[
|
|
772
|
-
return ((
|
|
773
|
-
} else if ([overlay isKindOfClass:[
|
|
774
|
-
return ((
|
|
775
|
-
} else if ([overlay isKindOfClass:[
|
|
776
|
-
return ((
|
|
777
|
-
} else if ([overlay isKindOfClass:[
|
|
778
|
-
return ((
|
|
488
|
+
if ([overlay isKindOfClass:[RNMMapPolyline class]]) {
|
|
489
|
+
return ((RNMMapPolyline *)overlay).renderer;
|
|
490
|
+
} else if ([overlay isKindOfClass:[RNMMapPolygon class]]) {
|
|
491
|
+
return ((RNMMapPolygon *)overlay).renderer;
|
|
492
|
+
} else if ([overlay isKindOfClass:[RNMMapCircle class]]) {
|
|
493
|
+
return ((RNMMapCircle *)overlay).renderer;
|
|
494
|
+
} else if ([overlay isKindOfClass:[RNMMapUrlTile class]]) {
|
|
495
|
+
return ((RNMMapUrlTile *)overlay).renderer;
|
|
496
|
+
} else if ([overlay isKindOfClass:[RNMMapWMSTile class]]) {
|
|
497
|
+
return ((RNMMapWMSTile *)overlay).renderer;
|
|
498
|
+
} else if ([overlay isKindOfClass:[RNMMapLocalTile class]]) {
|
|
499
|
+
return ((RNMMapLocalTile *)overlay).renderer;
|
|
500
|
+
} else if ([overlay isKindOfClass:[RNMMapOverlay class]]) {
|
|
501
|
+
return ((RNMMapOverlay *)overlay).renderer;
|
|
779
502
|
} else if([overlay isKindOfClass:[MKTileOverlay class]]) {
|
|
780
503
|
return [[MKTileOverlayRenderer alloc] initWithTileOverlay:overlay];
|
|
781
504
|
} else {
|
|
@@ -786,7 +509,7 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
786
509
|
|
|
787
510
|
#pragma mark Annotation Stuff
|
|
788
511
|
|
|
789
|
-
- (void)mapView:(
|
|
512
|
+
- (void)mapView:(RNMMap *)mapView didAddAnnotationViews:(NSArray<MKAnnotationView *> *)views
|
|
790
513
|
{
|
|
791
514
|
if(!mapView.userLocationCalloutEnabled){
|
|
792
515
|
for(MKAnnotationView* view in views){
|
|
@@ -800,25 +523,25 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
800
523
|
}
|
|
801
524
|
|
|
802
525
|
|
|
803
|
-
- (void)mapView:(
|
|
526
|
+
- (void)mapView:(RNMMap *)mapView didSelectAnnotationView:(MKAnnotationView *)view
|
|
804
527
|
{
|
|
805
|
-
if ([view.annotation isKindOfClass:[
|
|
806
|
-
[(
|
|
528
|
+
if ([view.annotation isKindOfClass:[RNMMapMarker class]]) {
|
|
529
|
+
[(RNMMapMarker *)view.annotation showCalloutView];
|
|
807
530
|
} else if ([view.annotation isKindOfClass:[MKUserLocation class]] && mapView.userLocationAnnotationTitle != nil && view.annotation.title != mapView.userLocationAnnotationTitle) {
|
|
808
531
|
[(MKUserLocation*)view.annotation setTitle: mapView.userLocationAnnotationTitle];
|
|
809
532
|
}
|
|
810
533
|
|
|
811
534
|
}
|
|
812
535
|
|
|
813
|
-
- (void)mapView:(
|
|
814
|
-
if ([view.annotation isKindOfClass:[
|
|
815
|
-
[(
|
|
536
|
+
- (void)mapView:(RNMMap *)mapView didDeselectAnnotationView:(MKAnnotationView *)view {
|
|
537
|
+
if ([view.annotation isKindOfClass:[RNMMapMarker class]]) {
|
|
538
|
+
[(RNMMapMarker *)view.annotation hideCalloutView];
|
|
816
539
|
}
|
|
817
540
|
}
|
|
818
541
|
|
|
819
|
-
- (MKAnnotationView *)mapView:(__unused
|
|
542
|
+
- (MKAnnotationView *)mapView:(__unused RNMMap *)mapView viewForAnnotation:(RNMMapMarker *)marker
|
|
820
543
|
{
|
|
821
|
-
if (![marker isKindOfClass:[
|
|
544
|
+
if (![marker isKindOfClass:[RNMMapMarker class]]) {
|
|
822
545
|
if ([marker isKindOfClass:[MKUserLocation class]] && mapView.userLocationAnnotationTitle != nil) {
|
|
823
546
|
[(MKUserLocation*)marker setTitle: mapView.userLocationAnnotationTitle];
|
|
824
547
|
return nil;
|
|
@@ -832,13 +555,13 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
832
555
|
|
|
833
556
|
static int kDragCenterContext;
|
|
834
557
|
|
|
835
|
-
- (void)mapView:(
|
|
558
|
+
- (void)mapView:(RNMMap *)mapView
|
|
836
559
|
annotationView:(MKAnnotationView *)view
|
|
837
560
|
didChangeDragState:(MKAnnotationViewDragState)newState
|
|
838
561
|
fromOldState:(MKAnnotationViewDragState)oldState
|
|
839
562
|
{
|
|
840
|
-
if (![view.annotation isKindOfClass:[
|
|
841
|
-
|
|
563
|
+
if (![view.annotation isKindOfClass:[RNMMapMarker class]]) return;
|
|
564
|
+
RNMMapMarker *marker = (RNMMapMarker *)view.annotation;
|
|
842
565
|
|
|
843
566
|
BOOL isPinView = [view isKindOfClass:[MKMarkerAnnotationView class]];
|
|
844
567
|
|
|
@@ -875,12 +598,12 @@ static int kDragCenterContext;
|
|
|
875
598
|
{
|
|
876
599
|
if ([keyPath isEqualToString:@"center"] && [object isKindOfClass:[MKAnnotationView class]]) {
|
|
877
600
|
MKAnnotationView *view = (MKAnnotationView *)object;
|
|
878
|
-
|
|
601
|
+
RNMMapMarker *marker = (RNMMapMarker *)view.annotation;
|
|
879
602
|
|
|
880
603
|
// a marker we don't control might be getting dragged. Check just in case.
|
|
881
604
|
if (!marker) return;
|
|
882
605
|
|
|
883
|
-
|
|
606
|
+
RNMMap *map = marker.map;
|
|
884
607
|
|
|
885
608
|
// don't waste time calculating if there are no events to listen to it
|
|
886
609
|
if (!map.onMarkerDrag && !marker.onDrag) return;
|
|
@@ -909,7 +632,7 @@ static int kDragCenterContext;
|
|
|
909
632
|
}
|
|
910
633
|
}
|
|
911
634
|
|
|
912
|
-
- (void)mapView:(
|
|
635
|
+
- (void)mapView:(RNMMap *)mapView didUpdateUserLocation:(MKUserLocation *)location
|
|
913
636
|
{
|
|
914
637
|
id event = @{@"coordinate": @{
|
|
915
638
|
@"latitude": @(location.coordinate.latitude),
|
|
@@ -933,12 +656,12 @@ static int kDragCenterContext;
|
|
|
933
656
|
|
|
934
657
|
}
|
|
935
658
|
|
|
936
|
-
- (void)mapViewDidChangeVisibleRegion:(
|
|
659
|
+
- (void)mapViewDidChangeVisibleRegion:(RNMMap *)mapView
|
|
937
660
|
{
|
|
938
661
|
[self _regionChanged:mapView];
|
|
939
662
|
}
|
|
940
663
|
|
|
941
|
-
- (void)mapView:(
|
|
664
|
+
- (void)mapView:(RNMMap *)mapView regionDidChangeAnimated:(__unused BOOL)animated
|
|
942
665
|
{
|
|
943
666
|
CGFloat zoomLevel = [self zoomLevel:mapView];
|
|
944
667
|
|
|
@@ -965,7 +688,7 @@ static int kDragCenterContext;
|
|
|
965
688
|
mapView.pendingSpan = mapView.region.span;
|
|
966
689
|
}
|
|
967
690
|
|
|
968
|
-
- (void)mapViewWillStartRenderingMap:(
|
|
691
|
+
- (void)mapViewWillStartRenderingMap:(RNMMap *)mapView
|
|
969
692
|
{
|
|
970
693
|
if (!mapView.hasStartedRendering) {
|
|
971
694
|
mapView.onMapReady(@{});
|
|
@@ -974,14 +697,14 @@ static int kDragCenterContext;
|
|
|
974
697
|
[mapView beginLoading];
|
|
975
698
|
}
|
|
976
699
|
|
|
977
|
-
- (void)mapViewDidFinishRenderingMap:(
|
|
700
|
+
- (void)mapViewDidFinishRenderingMap:(RNMMap *)mapView fullyRendered:(BOOL)fullyRendered
|
|
978
701
|
{
|
|
979
702
|
[mapView finishLoading];
|
|
980
703
|
}
|
|
981
704
|
|
|
982
705
|
#pragma mark Private
|
|
983
706
|
|
|
984
|
-
- (void)_regionChanged:(
|
|
707
|
+
- (void)_regionChanged:(RNMMap *)mapView
|
|
985
708
|
{
|
|
986
709
|
BOOL needZoom = NO;
|
|
987
710
|
CGFloat newLongitudeDelta = 0.0f;
|
|
@@ -995,10 +718,10 @@ static int kDragCenterContext;
|
|
|
995
718
|
// So let's try to make map zoom back to 99% max or 101% min so that there are some buffer that moving the map won't constantly hitting the max/min bound.
|
|
996
719
|
if (mapView.maxDelta > FLT_EPSILON && region.span.longitudeDelta > mapView.maxDelta) {
|
|
997
720
|
needZoom = YES;
|
|
998
|
-
newLongitudeDelta = mapView.maxDelta * (1 -
|
|
721
|
+
newLongitudeDelta = mapView.maxDelta * (1 - RNMMapZoomBoundBuffer);
|
|
999
722
|
} else if (mapView.minDelta > FLT_EPSILON && region.span.longitudeDelta < mapView.minDelta) {
|
|
1000
723
|
needZoom = YES;
|
|
1001
|
-
newLongitudeDelta = mapView.minDelta * (1 +
|
|
724
|
+
newLongitudeDelta = mapView.minDelta * (1 + RNMMapZoomBoundBuffer);
|
|
1002
725
|
}
|
|
1003
726
|
if (needZoom) {
|
|
1004
727
|
region.span.latitudeDelta = region.span.latitudeDelta / region.span.longitudeDelta * newLongitudeDelta;
|
|
@@ -1010,7 +733,7 @@ static int kDragCenterContext;
|
|
|
1010
733
|
[self _emitRegionChangeEvent:mapView continuous:YES];
|
|
1011
734
|
}
|
|
1012
735
|
|
|
1013
|
-
- (void)_emitRegionChangeEvent:(
|
|
736
|
+
- (void)_emitRegionChangeEvent:(RNMMap *)mapView continuous:(BOOL)continuous
|
|
1014
737
|
{
|
|
1015
738
|
if (!mapView.ignoreRegionChanges && mapView.onChange) {
|
|
1016
739
|
MKCoordinateRegion region = mapView.region;
|
|
@@ -1035,7 +758,7 @@ static int kDragCenterContext;
|
|
|
1035
758
|
*
|
|
1036
759
|
*
|
|
1037
760
|
*/
|
|
1038
|
-
- (double)distanceOfPoint:(MKMapPoint)pt toPoly:(
|
|
761
|
+
- (double)distanceOfPoint:(MKMapPoint)pt toPoly:(RNMMapPolyline *)poly
|
|
1039
762
|
{
|
|
1040
763
|
double distance = MAXFLOAT;
|
|
1041
764
|
for (int n = 0; n < poly.coordinates.count - 1; n++) {
|
|
@@ -1070,7 +793,7 @@ static int kDragCenterContext;
|
|
|
1070
793
|
|
|
1071
794
|
|
|
1072
795
|
/** Converts |px| to meters at location |pt| */
|
|
1073
|
-
- (double)metersFromPixel:(NSUInteger)px atPoint:(CGPoint)pt forMap:(
|
|
796
|
+
- (double)metersFromPixel:(NSUInteger)px atPoint:(CGPoint)pt forMap:(RNMMap *)mapView
|
|
1074
797
|
{
|
|
1075
798
|
CGPoint ptB = CGPointMake(pt.x + px, pt.y);
|
|
1076
799
|
|
|
@@ -1087,13 +810,13 @@ static int kDragCenterContext;
|
|
|
1087
810
|
|
|
1088
811
|
+ (double)latitudeToPixelSpaceY:(double)latitude
|
|
1089
812
|
{
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
813
|
+
if (latitude == 90.0) {
|
|
814
|
+
return 0;
|
|
815
|
+
} else if (latitude == -90.0) {
|
|
816
|
+
return MERCATOR_OFFSET * 2;
|
|
817
|
+
} else {
|
|
818
|
+
return round(MERCATOR_OFFSET - MERCATOR_RADIUS * logf((1 + sinf(latitude * M_PI / 180.0)) / (1 - sinf(latitude * M_PI / 180.0))) / 2.0);
|
|
819
|
+
}
|
|
1097
820
|
}
|
|
1098
821
|
|
|
1099
822
|
+ (double)pixelSpaceXToLongitude:(double)pixelX
|
|
@@ -1109,16 +832,16 @@ static int kDragCenterContext;
|
|
|
1109
832
|
#pragma mark -
|
|
1110
833
|
#pragma mark Helper methods
|
|
1111
834
|
|
|
1112
|
-
- (MKCoordinateSpan)coordinateSpanWithMapView:(
|
|
835
|
+
- (MKCoordinateSpan)coordinateSpanWithMapView:(RNMMap *)mapView
|
|
1113
836
|
centerCoordinate:(CLLocationCoordinate2D)centerCoordinate
|
|
1114
837
|
andZoomLevel:(double)zoomLevel
|
|
1115
838
|
{
|
|
1116
839
|
// convert center coordiate to pixel space
|
|
1117
|
-
double centerPixelX = [
|
|
1118
|
-
double centerPixelY = [
|
|
840
|
+
double centerPixelX = [RNMMapManager longitudeToPixelSpaceX:centerCoordinate.longitude];
|
|
841
|
+
double centerPixelY = [RNMMapManager latitudeToPixelSpaceY:centerCoordinate.latitude];
|
|
1119
842
|
|
|
1120
843
|
// determine the scale value from the zoom level
|
|
1121
|
-
double zoomExponent =
|
|
844
|
+
double zoomExponent = RNMMapMaxZoomLevel - zoomLevel;
|
|
1122
845
|
double zoomScale = pow(2, zoomExponent);
|
|
1123
846
|
|
|
1124
847
|
// scale the map’s size in pixel space
|
|
@@ -1131,13 +854,13 @@ static int kDragCenterContext;
|
|
|
1131
854
|
double topLeftPixelY = centerPixelY - (scaledMapHeight / 2);
|
|
1132
855
|
|
|
1133
856
|
// find delta between left and right longitudes
|
|
1134
|
-
CLLocationDegrees minLng = [
|
|
1135
|
-
CLLocationDegrees maxLng = [
|
|
857
|
+
CLLocationDegrees minLng = [RNMMapManager pixelSpaceXToLongitude:topLeftPixelX];
|
|
858
|
+
CLLocationDegrees maxLng = [RNMMapManager pixelSpaceXToLongitude:topLeftPixelX + scaledMapWidth];
|
|
1136
859
|
CLLocationDegrees longitudeDelta = maxLng - minLng;
|
|
1137
860
|
|
|
1138
861
|
// find delta between top and bottom latitudes
|
|
1139
|
-
CLLocationDegrees minLat = [
|
|
1140
|
-
CLLocationDegrees maxLat = [
|
|
862
|
+
CLLocationDegrees minLat = [RNMMapManager pixelSpaceYToLatitude:topLeftPixelY];
|
|
863
|
+
CLLocationDegrees maxLat = [RNMMapManager pixelSpaceYToLatitude:topLeftPixelY + scaledMapHeight];
|
|
1141
864
|
CLLocationDegrees latitudeDelta = -1 * (maxLat - minLat);
|
|
1142
865
|
|
|
1143
866
|
// create and return the lat/lng span
|
|
@@ -1151,10 +874,10 @@ static int kDragCenterContext;
|
|
|
1151
874
|
- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
|
|
1152
875
|
zoomLevel:(double)zoomLevel
|
|
1153
876
|
animated:(BOOL)animated
|
|
1154
|
-
mapView:(
|
|
877
|
+
mapView:(RNMMap *)mapView
|
|
1155
878
|
{
|
|
1156
879
|
// clamp large numbers to 28
|
|
1157
|
-
zoomLevel = MIN(zoomLevel,
|
|
880
|
+
zoomLevel = MIN(zoomLevel, RNMMapMaxZoomLevel);
|
|
1158
881
|
|
|
1159
882
|
// use the zoom level to compute the region
|
|
1160
883
|
MKCoordinateSpan span = [self coordinateSpanWithMapView:mapView centerCoordinate:centerCoordinate andZoomLevel:zoomLevel];
|
|
@@ -1165,81 +888,81 @@ static int kDragCenterContext;
|
|
|
1165
888
|
}
|
|
1166
889
|
|
|
1167
890
|
//KMapView cannot display tiles that cross the pole (as these would involve wrapping the map from top to bottom, something that a Mercator projection just cannot do).
|
|
1168
|
-
-(MKCoordinateRegion)coordinateRegionWithMapView:(
|
|
891
|
+
-(MKCoordinateRegion)coordinateRegionWithMapView:(RNMMap *)mapView
|
|
1169
892
|
centerCoordinate:(CLLocationCoordinate2D)centerCoordinate
|
|
1170
893
|
andZoomLevel:(double)zoomLevel
|
|
1171
894
|
{
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
895
|
+
// clamp lat/long values to appropriate ranges
|
|
896
|
+
centerCoordinate.latitude = MIN(MAX(-90.0, centerCoordinate.latitude), 90.0);
|
|
897
|
+
centerCoordinate.longitude = fmod(centerCoordinate.longitude, 180.0);
|
|
898
|
+
|
|
899
|
+
// convert center coordiate to pixel space
|
|
900
|
+
double centerPixelX = [RNMMapManager longitudeToPixelSpaceX:centerCoordinate.longitude];
|
|
901
|
+
double centerPixelY = [RNMMapManager latitudeToPixelSpaceY:centerCoordinate.latitude];
|
|
902
|
+
|
|
903
|
+
// determine the scale value from the zoom level
|
|
904
|
+
double zoomExponent = RNMMapMaxZoomLevel - zoomLevel;
|
|
905
|
+
double zoomScale = pow(2, zoomExponent);
|
|
906
|
+
|
|
907
|
+
// scale the map’s size in pixel space
|
|
908
|
+
CGSize mapSizeInPixels = mapView.bounds.size;
|
|
909
|
+
double scaledMapWidth = mapSizeInPixels.width * zoomScale;
|
|
910
|
+
double scaledMapHeight = mapSizeInPixels.height * zoomScale;
|
|
911
|
+
|
|
912
|
+
// figure out the position of the left pixel
|
|
913
|
+
double topLeftPixelX = centerPixelX - (scaledMapWidth / 2);
|
|
914
|
+
|
|
915
|
+
// find delta between left and right longitudes
|
|
916
|
+
CLLocationDegrees minLng = [RNMMapManager pixelSpaceXToLongitude:topLeftPixelX];
|
|
917
|
+
CLLocationDegrees maxLng = [RNMMapManager pixelSpaceXToLongitude:topLeftPixelX + scaledMapWidth];
|
|
918
|
+
CLLocationDegrees longitudeDelta = maxLng - minLng;
|
|
919
|
+
|
|
920
|
+
// if we’re at a pole then calculate the distance from the pole towards the equator
|
|
921
|
+
// as MKMapView doesn’t like drawing boxes over the poles
|
|
922
|
+
double topPixelY = centerPixelY - (scaledMapHeight / 2);
|
|
923
|
+
double bottomPixelY = centerPixelY + (scaledMapHeight / 2);
|
|
924
|
+
BOOL adjustedCenterPoint = NO;
|
|
925
|
+
if (topPixelY > MERCATOR_OFFSET * 2) {
|
|
926
|
+
topPixelY = centerPixelY - scaledMapHeight;
|
|
927
|
+
bottomPixelY = MERCATOR_OFFSET * 2;
|
|
928
|
+
adjustedCenterPoint = YES;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// find delta between top and bottom latitudes
|
|
932
|
+
CLLocationDegrees minLat = [RNMMapManager pixelSpaceYToLatitude:topPixelY];
|
|
933
|
+
CLLocationDegrees maxLat = [RNMMapManager pixelSpaceYToLatitude:bottomPixelY];
|
|
934
|
+
CLLocationDegrees latitudeDelta = -1 * (maxLat - minLat);
|
|
935
|
+
|
|
936
|
+
// create and return the lat/lng span
|
|
937
|
+
MKCoordinateSpan span = MKCoordinateSpanMake(latitudeDelta, longitudeDelta);
|
|
938
|
+
MKCoordinateRegion region = MKCoordinateRegionMake(centerCoordinate, span);
|
|
939
|
+
// once again, MKMapView doesn’t like drawing boxes over the poles
|
|
940
|
+
// so adjust the center coordinate to the center of the resulting region
|
|
941
|
+
if (adjustedCenterPoint) {
|
|
942
|
+
region.center.latitude = [RNMMapManager pixelSpaceYToLatitude:((bottomPixelY + topPixelY) / 2.0)];
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
return region;
|
|
1223
946
|
}
|
|
1224
947
|
|
|
1225
|
-
- (double) zoomLevel:(
|
|
948
|
+
- (double) zoomLevel:(RNMMap *)mapView {
|
|
1226
949
|
MKCoordinateRegion region = mapView.region;
|
|
1227
950
|
|
|
1228
|
-
double centerPixelX = [
|
|
1229
|
-
double topLeftPixelX = [
|
|
951
|
+
double centerPixelX = [RNMMapManager longitudeToPixelSpaceX: region.center.longitude];
|
|
952
|
+
double topLeftPixelX = [RNMMapManager longitudeToPixelSpaceX: region.center.longitude - region.span.longitudeDelta / 2];
|
|
1230
953
|
|
|
1231
954
|
double scaledMapWidth = (centerPixelX - topLeftPixelX) * 2;
|
|
1232
955
|
CGSize mapSizeInPixels = mapView.bounds.size;
|
|
1233
956
|
double zoomScale = scaledMapWidth / mapSizeInPixels.width;
|
|
1234
957
|
double zoomExponent = log(zoomScale) / log(2);
|
|
1235
|
-
double zoomLevel =
|
|
958
|
+
double zoomLevel = RNMMapMaxZoomLevel - zoomExponent;
|
|
1236
959
|
|
|
1237
960
|
return zoomLevel;
|
|
1238
961
|
}
|
|
1239
962
|
|
|
1240
963
|
#pragma mark MKMapViewDelegate - Tracking the User Location
|
|
1241
964
|
|
|
1242
|
-
- (void)mapView:(
|
|
965
|
+
- (void)mapView:(RNMMap *)mapView didFailToLocateUserWithError:(NSError *)error {
|
|
1243
966
|
id event = @{@"error": @{ @"message": error.localizedDescription }};
|
|
1244
967
|
if (mapView.onUserLocationChange) {
|
|
1245
968
|
mapView.onUserLocationChange(event);
|