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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// RNMMapPolylineRenderer.h
|
|
3
3
|
// mapDemo
|
|
4
4
|
//
|
|
5
5
|
// Created by IjzerenHein on 13-11-21.
|
|
6
6
|
// Copyright (c) 2017 IjzerenHein. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#import "
|
|
9
|
+
#import "RNMMapPolylineRenderer.h"
|
|
10
10
|
|
|
11
|
-
@interface
|
|
11
|
+
@interface RNMMapPolylineRendererSegment : NSObject
|
|
12
12
|
- (id)initWithPoint:(CGPoint)point color:(UIColor*)color;
|
|
13
13
|
- (void) addPoint:(CGPoint)point color:(UIColor*)color;
|
|
14
14
|
@property CGMutablePathRef path;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
@property CGPoint startPoint;
|
|
18
18
|
@property CGPoint endPoint;
|
|
19
19
|
@end
|
|
20
|
-
@implementation
|
|
20
|
+
@implementation RNMMapPolylineRendererSegment
|
|
21
21
|
- (id)initWithPoint:(CGPoint)point color:(UIColor*)color
|
|
22
22
|
{
|
|
23
23
|
self = [super init];
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
@end
|
|
40
40
|
|
|
41
|
-
@implementation
|
|
41
|
+
@implementation RNMMapPolylineRenderer {
|
|
42
42
|
MKPolyline* _polyline;
|
|
43
43
|
NSArray<UIColor *> *_strokeColors;
|
|
44
44
|
MKMapSnapshot* _snapshot;
|
|
@@ -114,14 +114,14 @@
|
|
|
114
114
|
{
|
|
115
115
|
NSMutableArray* segments = [NSMutableArray new];
|
|
116
116
|
if (_polyline.pointCount <= 1) return segments;
|
|
117
|
-
|
|
117
|
+
RNMMapPolylineRendererSegment* segment = nil;
|
|
118
118
|
for (NSUInteger i = 0, n = _polyline.pointCount; i < n; i++){
|
|
119
119
|
CGPoint point = [self pointForIndex:i];
|
|
120
120
|
UIColor* color = [self colorForIndex:i];
|
|
121
121
|
if (segment == nil) {
|
|
122
122
|
|
|
123
123
|
// Start new segment
|
|
124
|
-
segment = [[
|
|
124
|
+
segment = [[RNMMapPolylineRendererSegment alloc] initWithPoint:point color:color];
|
|
125
125
|
[segments addObject:segment];
|
|
126
126
|
}
|
|
127
127
|
else if (((color == nil) && (segment.endColor == nil)) ||
|
|
@@ -139,14 +139,14 @@
|
|
|
139
139
|
else {
|
|
140
140
|
|
|
141
141
|
// Add transition gradient
|
|
142
|
-
segment = [[
|
|
142
|
+
segment = [[RNMMapPolylineRendererSegment alloc] initWithPoint:segment.endPoint color:segment.endColor];
|
|
143
143
|
[segment addPoint:point color:color];
|
|
144
144
|
[segments addObject:segment];
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// Start new segment
|
|
148
148
|
if (i < (n - 1)) {
|
|
149
|
-
segment = [[
|
|
149
|
+
segment = [[RNMMapPolylineRendererSegment alloc] initWithPoint:point color:color];
|
|
150
150
|
[segments addObject:segment];
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
|
|
200
200
|
NSArray* segments = [self createSegments];
|
|
201
201
|
for (NSUInteger i = 0, n = segments.count; i < n; i++) {
|
|
202
|
-
|
|
202
|
+
RNMMapPolylineRendererSegment* segment = segments[i];
|
|
203
203
|
|
|
204
204
|
CGContextBeginPath(context);
|
|
205
205
|
CGContextAddPath(context, segment.path);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMMapSnapshot.h
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by Hein Rutjes on 26/09/16.
|
|
6
6
|
// Copyright © 2016 Christopher. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#ifndef
|
|
10
|
-
#define
|
|
9
|
+
#ifndef RNMMapSnapshot_h
|
|
10
|
+
#define RNMMapSnapshot_h
|
|
11
11
|
|
|
12
|
-
@protocol
|
|
12
|
+
@protocol RNMMapSnapshot <NSObject>
|
|
13
13
|
@optional
|
|
14
14
|
- (void) drawToSnapshot:(MKMapSnapshot *) snapshot context:(CGContextRef) context;
|
|
15
15
|
@end
|
|
16
16
|
|
|
17
|
-
#endif /*
|
|
17
|
+
#endif /* RNMMapSnapshot_h */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMUrlTileOverlay.h
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by cascadian on 3/19/16.
|
|
6
6
|
// Copyright © 2016. All rights reserved.
|
|
@@ -12,25 +12,25 @@
|
|
|
12
12
|
|
|
13
13
|
#import <React/RCTComponent.h>
|
|
14
14
|
#import <React/RCTView.h>
|
|
15
|
-
#import "
|
|
16
|
-
#import "
|
|
17
|
-
#import "RCTConvert+
|
|
18
|
-
#import "
|
|
19
|
-
|
|
20
|
-
@interface
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
#import "RNMMapCoordinate.h"
|
|
16
|
+
#import "RNMMap.h"
|
|
17
|
+
#import "RCTConvert+RNMMap.h"
|
|
18
|
+
#import "RNMMapUrlTileCachedOverlay.h"
|
|
19
|
+
|
|
20
|
+
@interface RNMMapUrlTile : MKAnnotationView <MKOverlay> {
|
|
21
|
+
BOOL _urlTemplateSet;
|
|
22
|
+
BOOL _tileSizeSet;
|
|
23
|
+
BOOL _flipYSet;
|
|
24
|
+
BOOL _tileCachePathSet;
|
|
25
|
+
BOOL _tileCacheMaxAgeSet;
|
|
26
|
+
BOOL _maximumNativeZSet;
|
|
27
|
+
BOOL _cachedOverlayCreated;
|
|
28
|
+
BOOL _opacitySet;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
@property (nonatomic, weak)
|
|
31
|
+
@property (nonatomic, weak) RNMMap *map;
|
|
32
32
|
|
|
33
|
-
@property (nonatomic, strong)
|
|
33
|
+
@property (nonatomic, strong) RNMMapUrlTileCachedOverlay *tileOverlay;
|
|
34
34
|
@property (nonatomic, strong) MKTileOverlayRenderer *renderer;
|
|
35
35
|
@property (nonatomic, copy) NSString *urlTemplate;
|
|
36
36
|
@property NSInteger maximumZ;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMUrlTileOverlay.m
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by cascadian on 3/19/16.
|
|
6
6
|
// Copyright © 2016. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#import "
|
|
9
|
+
#import "RNMMapUrlTile.h"
|
|
10
10
|
#import <React/UIView+React.h>
|
|
11
|
-
#import "
|
|
11
|
+
#import "RNMMapUrlTileCachedOverlay.h"
|
|
12
12
|
|
|
13
|
-
@implementation
|
|
13
|
+
@implementation RNMMapUrlTile
|
|
14
14
|
|
|
15
15
|
- (void)setShouldReplaceMapContent:(BOOL)shouldReplaceMapContent
|
|
16
16
|
{
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
if (!_urlTemplateSet) return;
|
|
123
123
|
if (_tileCachePathSet || _maximumNativeZSet) {
|
|
124
124
|
NSLog(@"tileCache dir %@", _tileCachePath);
|
|
125
|
-
self.tileOverlay = [[
|
|
125
|
+
self.tileOverlay = [[RNMMapUrlTileCachedOverlay alloc] initWithURLTemplate:self.urlTemplate];
|
|
126
126
|
_cachedOverlayCreated = YES;
|
|
127
127
|
if (_tileCachePathSet) {
|
|
128
128
|
NSURL *urlPath = [NSURL URLWithString:[self.tileCachePath stringByAppendingString:@"/"]];
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
[_map removeOverlay:self];
|
|
184
184
|
[_map addOverlay:self level:MKOverlayLevelAboveLabels];
|
|
185
185
|
for (id<MKOverlay> overlay in _map.overlays) {
|
|
186
|
-
if ([overlay isKindOfClass:[
|
|
186
|
+
if ([overlay isKindOfClass:[RNMMapUrlTile class]]) {
|
|
187
187
|
continue;
|
|
188
188
|
}
|
|
189
189
|
[_map removeOverlay:overlay];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMMapUrlTileCachedOverlay.h
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by Markus Suomi on 10/04/2021.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
#import <MapKit/MapKit.h>
|
|
9
9
|
|
|
10
|
-
@interface
|
|
10
|
+
@interface RNMMapUrlTileCachedOverlay : MKTileOverlay
|
|
11
11
|
|
|
12
12
|
@property NSInteger maximumNativeZ;
|
|
13
13
|
@property (nonatomic, copy) NSURL *tileCachePath;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMMapUrlTileCachedOverlay.m
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by Markus Suomi on 10/04/2021.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
#import "
|
|
8
|
+
#import "RNMMapUrlTileCachedOverlay.h"
|
|
9
9
|
|
|
10
|
-
@interface
|
|
10
|
+
@interface RNMMapUrlTileCachedOverlay ()
|
|
11
11
|
|
|
12
12
|
@end
|
|
13
13
|
|
|
14
|
-
@implementation
|
|
14
|
+
@implementation RNMMapUrlTileCachedOverlay {
|
|
15
15
|
CIContext *_ciContext;
|
|
16
16
|
CGColorSpaceRef _colorspace;
|
|
17
17
|
NSURLSession *_urlSession;
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
NSInteger maximumZ = self.maximumNativeZ ? self.maximumNativeZ : path.z;
|
|
25
25
|
[self scaleIfNeededLowerZoomTile:path maximumZ:maximumZ result:^(NSData *image, NSError *error) {
|
|
26
26
|
if (!image && self.offlineMode && self.tileCachePath) {
|
|
27
|
-
NSInteger zoomLevelToStart = (path.z > maximumZ) ? maximumZ - 1 : path.z - 1;
|
|
27
|
+
NSInteger zoomLevelToStart = (path.z > maximumZ) ? maximumZ - 1 : path.z - 1;
|
|
28
28
|
NSInteger minimumZoomToSearch = self.minimumZ >= zoomLevelToStart - 3 ? self.minimumZ : zoomLevelToStart - 3;
|
|
29
29
|
[self findLowerZoomTileAndScale:path tryZ:zoomLevelToStart minZ:minimumZoomToSearch result:result];
|
|
30
30
|
} else {
|
|
31
31
|
result(image, error);
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
}];
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
|
|
80
80
|
NSData *finalImage = [_ciContext PNGRepresentationOfImage:scaledCIImage format:kCIFormatABGR8 colorSpace:_colorspace options:nil];
|
|
81
81
|
result(finalImage, nil);
|
|
82
|
-
}];
|
|
82
|
+
}];
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
- (void)findLowerZoomTileAndScale:(MKTileOverlayPath)path tryZ:(NSInteger)tryZ minZ:(NSInteger)minZ result:(void (^)(NSData *, NSError *))result
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
[[NSFileManager defaultManager] createFileAtPath:[tileCacheFilePath path] contents:data attributes:nil];
|
|
210
210
|
NSLog(@"tileCache File refreshed at %@", [tileCacheFilePath path]);
|
|
211
211
|
}
|
|
212
|
-
}] resume];
|
|
212
|
+
}] resume];
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
}
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
- (BOOL)doesFileNeedRefresh:(MKTileOverlayPath)path fromFilePath:(NSURL *)tileCacheFilePath withMaxAge:(NSInteger)tileCacheMaxAge
|
|
219
219
|
{
|
|
220
220
|
NSError *error;
|
|
221
|
-
NSDictionary<NSFileAttributeKey, id> *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[tileCacheFilePath path] error:&error];
|
|
221
|
+
NSDictionary<NSFileAttributeKey, id> *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[tileCacheFilePath path] error:&error];
|
|
222
222
|
|
|
223
223
|
if (fileAttributes) {
|
|
224
224
|
NSDate *modificationDate = fileAttributes[@"NSFileModificationDate"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMMapUrlTileManager.h
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by cascadian on 3/19/16.
|
|
6
6
|
// Copyright © 2016. All rights reserved.
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
#import <React/RCTViewManager.h>
|
|
11
11
|
|
|
12
|
-
@interface
|
|
12
|
+
@interface RNMMapUrlTileManager : RCTViewManager
|
|
13
13
|
|
|
14
14
|
@end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMMapUrlTileManager.m
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by cascadian on 3/19/16.
|
|
6
6
|
// Copyright © 2016. All rights reserved.
|
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
#import <React/RCTEventDispatcher.h>
|
|
13
13
|
#import <React/RCTViewManager.h>
|
|
14
14
|
#import <React/UIView+React.h>
|
|
15
|
-
#import "
|
|
16
|
-
#import "
|
|
15
|
+
#import "RNMMapMarker.h"
|
|
16
|
+
#import "RNMMapUrlTile.h"
|
|
17
17
|
|
|
18
|
-
#import "
|
|
18
|
+
#import "RNMMapUrlTileManager.h"
|
|
19
19
|
|
|
20
|
-
@interface
|
|
20
|
+
@interface RNMMapUrlTileManager()
|
|
21
21
|
|
|
22
22
|
@end
|
|
23
23
|
|
|
24
|
-
@implementation
|
|
24
|
+
@implementation RNMMapUrlTileManager
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
RCT_EXPORT_MODULE()
|
|
27
|
+
RCT_EXPORT_MODULE(RNMMapUrlTile)
|
|
28
28
|
|
|
29
29
|
- (UIView *)view
|
|
30
30
|
{
|
|
31
|
-
|
|
31
|
+
RNMMapUrlTile *tile = [RNMMapUrlTile new];
|
|
32
32
|
return tile;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
#import "RNMMapViewModule.h"
|
|
2
|
+
#import "RNMMap.h"
|
|
3
|
+
#import "RNMMapSnapshot.h"
|
|
4
|
+
#import <React/RCTUIManager.h>
|
|
5
|
+
#import <React/RCTUIManagerUtils.h>
|
|
6
|
+
|
|
7
|
+
@implementation RNMMapViewModule
|
|
8
|
+
|
|
9
|
+
@synthesize bridge = _bridge;
|
|
10
|
+
|
|
11
|
+
- (dispatch_queue_t)methodQueue
|
|
12
|
+
{
|
|
13
|
+
return RCTGetUIManagerQueue();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
RCT_EXPORT_MODULE();
|
|
17
|
+
|
|
18
|
+
RCT_EXPORT_METHOD(getMapBoundaries:(nonnull NSNumber *)reactTag
|
|
19
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
20
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
21
|
+
{
|
|
22
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
23
|
+
id view = viewRegistry[reactTag];
|
|
24
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
25
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
26
|
+
} else {
|
|
27
|
+
NSArray *boundingBox = [view getMapBoundaries];
|
|
28
|
+
|
|
29
|
+
resolve(@{
|
|
30
|
+
@"northEast" : @{
|
|
31
|
+
@"longitude" : boundingBox[0][0],
|
|
32
|
+
@"latitude" : boundingBox[0][1]
|
|
33
|
+
},
|
|
34
|
+
@"southWest" : @{
|
|
35
|
+
@"longitude" : boundingBox[1][0],
|
|
36
|
+
@"latitude" : boundingBox[1][1]
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
RCT_EXPORT_METHOD(getCamera:(nonnull NSNumber *)reactTag
|
|
44
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
45
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
46
|
+
{
|
|
47
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
48
|
+
id view = viewRegistry[reactTag];
|
|
49
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
50
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
51
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMMap, got: %@", view], NULL);
|
|
52
|
+
} else {
|
|
53
|
+
MKMapCamera *camera = [mapView camera];
|
|
54
|
+
resolve(@{
|
|
55
|
+
@"center": @{
|
|
56
|
+
@"latitude": @(camera.centerCoordinate.latitude),
|
|
57
|
+
@"longitude": @(camera.centerCoordinate.longitude),
|
|
58
|
+
},
|
|
59
|
+
@"pitch": @(camera.pitch),
|
|
60
|
+
@"heading": @(camera.heading),
|
|
61
|
+
@"altitude": @(camera.altitude),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
RCT_EXPORT_METHOD(takeSnapshot:(nonnull NSNumber *)reactTag
|
|
68
|
+
config:(NSDictionary *)config
|
|
69
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
70
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
71
|
+
{
|
|
72
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
73
|
+
id view = viewRegistry[reactTag];
|
|
74
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
75
|
+
RCTLogError(@"Invalid view returned from registry, expecting RNMMap, got: %@", view);
|
|
76
|
+
} else {
|
|
77
|
+
NSNumber *width = config[@"width"];
|
|
78
|
+
NSNumber *height = config[@"height"];
|
|
79
|
+
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:config[@"region"]];
|
|
80
|
+
NSString *format = config[@"format"];
|
|
81
|
+
NSNumber *quality = config[@"quality"];
|
|
82
|
+
NSString *result = config[@"result"];
|
|
83
|
+
|
|
84
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
85
|
+
MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
|
|
86
|
+
|
|
87
|
+
options.mapType = mapView.mapType;
|
|
88
|
+
options.region = (region.center.latitude && region.center.longitude) ? region : mapView.region;
|
|
89
|
+
options.size = CGSizeMake(
|
|
90
|
+
([width floatValue] == 0) ? mapView.bounds.size.width : [width floatValue],
|
|
91
|
+
([height floatValue] == 0) ? mapView.bounds.size.height : [height floatValue]
|
|
92
|
+
);
|
|
93
|
+
options.scale = [[UIScreen mainScreen] scale];
|
|
94
|
+
|
|
95
|
+
MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
|
|
96
|
+
|
|
97
|
+
[self takeMapSnapshot:mapView
|
|
98
|
+
snapshotter:snapshotter
|
|
99
|
+
format:format
|
|
100
|
+
quality:quality.floatValue
|
|
101
|
+
result:result
|
|
102
|
+
resolver:resolve
|
|
103
|
+
rejecter:reject];
|
|
104
|
+
}
|
|
105
|
+
}];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
RCT_EXPORT_METHOD(pointForCoordinate:(nonnull NSNumber *)reactTag
|
|
109
|
+
coordinate: (NSDictionary *)coordinate
|
|
110
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
111
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
112
|
+
{
|
|
113
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
114
|
+
id view = viewRegistry[reactTag];
|
|
115
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
116
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
117
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMMap, got: %@", view], NULL);
|
|
118
|
+
} else {
|
|
119
|
+
CGPoint touchPoint = [mapView convertCoordinate:
|
|
120
|
+
CLLocationCoordinate2DMake(
|
|
121
|
+
[coordinate[@"latitude"] doubleValue],
|
|
122
|
+
[coordinate[@"longitude"] doubleValue]
|
|
123
|
+
)
|
|
124
|
+
toPointToView:mapView];
|
|
125
|
+
|
|
126
|
+
resolve(@{
|
|
127
|
+
@"x": @(touchPoint.x),
|
|
128
|
+
@"y": @(touchPoint.y),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
RCT_EXPORT_METHOD(getMarkersFrames:(nonnull NSNumber *)reactTag
|
|
135
|
+
onlyVisible:(BOOL)onlyVisible
|
|
136
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
137
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
138
|
+
{
|
|
139
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
140
|
+
id view = viewRegistry[reactTag];
|
|
141
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
142
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
143
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMMap, got: %@", view], NULL);
|
|
144
|
+
} else {
|
|
145
|
+
resolve([mapView getMarkersFramesWithOnlyVisible:onlyVisible]);
|
|
146
|
+
}
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
RCT_EXPORT_METHOD(coordinateForPoint:(nonnull NSNumber *)reactTag
|
|
153
|
+
point:(NSDictionary *)point
|
|
154
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
155
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
156
|
+
{
|
|
157
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
158
|
+
id view = viewRegistry[reactTag];
|
|
159
|
+
RNMMap *mapView = (RNMMap *)view;
|
|
160
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
161
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMMap, got: %@", view], NULL);
|
|
162
|
+
} else {
|
|
163
|
+
CLLocationCoordinate2D coordinate = [mapView convertPoint:
|
|
164
|
+
CGPointMake(
|
|
165
|
+
[point[@"x"] doubleValue],
|
|
166
|
+
[point[@"y"] doubleValue]
|
|
167
|
+
)
|
|
168
|
+
toCoordinateFromView:mapView];
|
|
169
|
+
|
|
170
|
+
resolve(@{
|
|
171
|
+
@"latitude": @(coordinate.latitude),
|
|
172
|
+
@"longitude": @(coordinate.longitude),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
179
|
+
coordinate: (NSDictionary *)coordinate
|
|
180
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
181
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
182
|
+
{
|
|
183
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
184
|
+
id view = viewRegistry[reactTag];
|
|
185
|
+
if (![view isKindOfClass:[RNMMap class]]) {
|
|
186
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMMap, got: %@", view], NULL);
|
|
187
|
+
} else {
|
|
188
|
+
if (coordinate == nil ||
|
|
189
|
+
![[coordinate allKeys] containsObject:@"latitude"] ||
|
|
190
|
+
![[coordinate allKeys] containsObject:@"longitude"]) {
|
|
191
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid coordinate format"], NULL);
|
|
192
|
+
}
|
|
193
|
+
CLLocation *location = [[CLLocation alloc] initWithLatitude:[coordinate[@"latitude"] doubleValue]
|
|
194
|
+
longitude:[coordinate[@"longitude"] doubleValue]];
|
|
195
|
+
CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
|
|
196
|
+
[geoCoder reverseGeocodeLocation:location
|
|
197
|
+
completionHandler:^(NSArray *placemarks, NSError *error) {
|
|
198
|
+
if (error == nil && [placemarks count] > 0){
|
|
199
|
+
CLPlacemark *placemark = placemarks[0];
|
|
200
|
+
resolve(@{
|
|
201
|
+
@"name" : [NSString stringWithFormat:@"%@", placemark.name],
|
|
202
|
+
@"thoroughfare" : [NSString stringWithFormat:@"%@", placemark.thoroughfare],
|
|
203
|
+
@"subThoroughfare" : [NSString stringWithFormat:@"%@", placemark.subThoroughfare],
|
|
204
|
+
@"locality" : [NSString stringWithFormat:@"%@", placemark.locality],
|
|
205
|
+
@"subLocality" : [NSString stringWithFormat:@"%@", placemark.subLocality],
|
|
206
|
+
@"administrativeArea" : [NSString stringWithFormat:@"%@", placemark.administrativeArea],
|
|
207
|
+
@"subAdministrativeArea" : [NSString stringWithFormat:@"%@", placemark.subAdministrativeArea],
|
|
208
|
+
@"postalCode" : [NSString stringWithFormat:@"%@", placemark.postalCode],
|
|
209
|
+
@"countryCode" : [NSString stringWithFormat:@"%@", placemark.ISOcountryCode],
|
|
210
|
+
@"country" : [NSString stringWithFormat:@"%@", placemark.country],
|
|
211
|
+
});
|
|
212
|
+
} else {
|
|
213
|
+
reject(@"Invalid argument", [NSString stringWithFormat:@"Can not get address location"], NULL);
|
|
214
|
+
}
|
|
215
|
+
}];
|
|
216
|
+
}
|
|
217
|
+
}];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
- (void)takeMapSnapshot:(RNMMap *)mapView
|
|
221
|
+
snapshotter:(MKMapSnapshotter *) snapshotter
|
|
222
|
+
format:(NSString *)format
|
|
223
|
+
quality:(CGFloat) quality
|
|
224
|
+
result:(NSString *)result
|
|
225
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
226
|
+
rejecter:(RCTPromiseRejectBlock)reject {
|
|
227
|
+
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
|
|
228
|
+
NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
|
|
229
|
+
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
|
|
230
|
+
|
|
231
|
+
[snapshotter startWithQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
|
|
232
|
+
completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
|
|
233
|
+
if (error) {
|
|
234
|
+
NSString *msg = [error localizedDescription];
|
|
235
|
+
reject(@"takeMapSnapshot_error", msg, nil);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
MKAnnotationView *pin = [[MKMarkerAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
|
|
239
|
+
|
|
240
|
+
UIImage *image = snapshot.image;
|
|
241
|
+
UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale);
|
|
242
|
+
{
|
|
243
|
+
[image drawAtPoint:CGPointMake(0.0f, 0.0f)];
|
|
244
|
+
|
|
245
|
+
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
|
|
246
|
+
|
|
247
|
+
for (id <RNMMapSnapshot> overlay in mapView.overlays) {
|
|
248
|
+
if ([overlay respondsToSelector:@selector(drawToSnapshot:context:)]) {
|
|
249
|
+
[overlay drawToSnapshot:snapshot context:UIGraphicsGetCurrentContext()];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
for (id <MKAnnotation> annotation in mapView.annotations) {
|
|
254
|
+
CGPoint point = [snapshot pointForCoordinate:annotation.coordinate];
|
|
255
|
+
|
|
256
|
+
MKAnnotationView* anView = [mapView viewForAnnotation: annotation];
|
|
257
|
+
|
|
258
|
+
if (anView){
|
|
259
|
+
pin = anView;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (CGRectContainsPoint(rect, point)) {
|
|
263
|
+
point.x = point.x + pin.centerOffset.x - (pin.bounds.size.width / 2.0f);
|
|
264
|
+
point.y = point.y + pin.centerOffset.y - (pin.bounds.size.height / 2.0f);
|
|
265
|
+
if (pin.image) {
|
|
266
|
+
[pin.image drawAtPoint:point];
|
|
267
|
+
} else {
|
|
268
|
+
CGRect pinRect = CGRectMake(point.x, point.y, pin.bounds.size.width, pin.bounds.size.height);
|
|
269
|
+
[pin drawViewHierarchyInRect:pinRect afterScreenUpdates:NO];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
UIImage *compositeImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
275
|
+
|
|
276
|
+
NSData *data;
|
|
277
|
+
if ([format isEqualToString:@"png"]) {
|
|
278
|
+
data = UIImagePNGRepresentation(compositeImage);
|
|
279
|
+
}
|
|
280
|
+
else if([format isEqualToString:@"jpg"]) {
|
|
281
|
+
data = UIImageJPEGRepresentation(compositeImage, quality);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if ([result isEqualToString:@"file"]) {
|
|
285
|
+
[data writeToFile:filePath atomically:YES];
|
|
286
|
+
resolve(filePath);
|
|
287
|
+
}
|
|
288
|
+
else if ([result isEqualToString:@"base64"]) {
|
|
289
|
+
NSString *base64 = [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn];
|
|
290
|
+
resolve(base64);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
UIGraphicsEndImageContext();
|
|
294
|
+
}];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@end
|