react-native-maps 1.21.0-alpha.3 → 1.21.0-alpha.30
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/build.gradle +14 -3
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
- package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +166 -11
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +20 -11
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +344 -243
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +29 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +599 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +8 -4
- package/ios/AirMaps/AIRMap.m +226 -101
- package/ios/AirMaps/AIRMapManager.m +12 -21
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +160 -103
- package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsAirModule.h +3 -0
- package/ios/AirMaps/RNMapsAirModule.mm +42 -172
- package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
- package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
- package/ios/AirMaps/RNMapsMapView.h +6 -3
- package/ios/AirMaps/RNMapsMapView.mm +340 -334
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +404 -0
- package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
- package/ios/AirMaps/UIView +AirMap.m +20 -0
- package/ios/AirMaps/UIView+AirMap.h +11 -0
- package/lib/MapMarker.d.ts +3 -2
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapView.d.ts +5 -22
- package/lib/MapView.js +34 -21
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
- package/lib/createFabricMap.js +175 -0
- package/lib/decorateMapComponent.js +18 -0
- package/lib/specs/NativeAirMapsModule.d.ts +2 -2
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +21 -45
- package/lib/specs/NativeComponentMarker.d.ts +246 -0
- package/lib/specs/NativeComponentMarker.js +21 -0
- package/package.json +7 -7
- package/react-native-maps.podspec +1 -1
- package/lib/FabricMapView.js +0 -175
|
@@ -16,141 +16,225 @@
|
|
|
16
16
|
#import "AIRDummyView.h"
|
|
17
17
|
|
|
18
18
|
CGRect unionRect(CGRect a, CGRect b) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
return CGRectMake(
|
|
20
|
+
MIN(a.origin.x, b.origin.x),
|
|
21
|
+
MIN(a.origin.y, b.origin.y),
|
|
22
|
+
MAX(a.size.width, b.size.width),
|
|
23
|
+
MAX(a.size.height, b.size.height));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
@interface AIRGoogleMapMarker ()
|
|
27
27
|
@end
|
|
28
28
|
|
|
29
29
|
@implementation AIRGoogleMapMarker {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
RCTImageLoaderCancellationBlock _reloadImageCancellationBlock;
|
|
31
|
+
RCTBubblingEventBlock _onPress;
|
|
32
|
+
RCTBubblingEventBlock _onSelect;
|
|
33
|
+
RCTBubblingEventBlock _onDeselect;
|
|
34
|
+
__weak UIImageView *_iconImageView;
|
|
35
|
+
UIView *_iconView;
|
|
36
|
+
UIColor *_pinColor;
|
|
37
|
+
CLLocationCoordinate2D _coordinates;
|
|
38
|
+
CLLocationDegrees _rotation;
|
|
39
|
+
BOOL _tracksInfoWindowChanges;
|
|
40
|
+
BOOL _tracksViewChanges;
|
|
41
|
+
BOOL _draggable;
|
|
42
|
+
BOOL _tappable;
|
|
43
|
+
BOOL _flat;
|
|
44
|
+
double _opacity;
|
|
45
|
+
NSString* _identifier;
|
|
46
|
+
NSString* _title;
|
|
47
|
+
NSString* _subtitle;
|
|
48
|
+
|
|
33
49
|
}
|
|
34
50
|
|
|
35
51
|
- (instancetype)init
|
|
36
52
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
if ((self = [super init])) {
|
|
54
|
+
_tracksViewChanges = true;
|
|
55
|
+
_tracksInfoWindowChanges = false;
|
|
56
|
+
_tappable = true;
|
|
57
|
+
_opacity = 1.0;
|
|
58
|
+
}
|
|
59
|
+
return self;
|
|
44
60
|
}
|
|
45
61
|
|
|
46
62
|
- (void)layoutSubviews {
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
float width = 0;
|
|
64
|
+
float height = 0;
|
|
65
|
+
|
|
66
|
+
for (UIView *v in [_iconView subviews]) {
|
|
67
|
+
|
|
68
|
+
float fw = v.frame.origin.x + v.frame.size.width;
|
|
69
|
+
float fh = v.frame.origin.y + v.frame.size.height;
|
|
70
|
+
|
|
71
|
+
width = MAX(fw, width);
|
|
72
|
+
height = MAX(fh, height);
|
|
73
|
+
}
|
|
49
74
|
|
|
50
|
-
|
|
75
|
+
[_iconView setFrame:CGRectMake(0, 0, width, height)];
|
|
76
|
+
}
|
|
51
77
|
|
|
52
|
-
float fw = v.frame.origin.x + v.frame.size.width;
|
|
53
|
-
float fh = v.frame.origin.y + v.frame.size.height;
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
- (UIView *) iconView
|
|
80
|
+
{
|
|
81
|
+
return _iconView;
|
|
82
|
+
}
|
|
58
83
|
|
|
59
|
-
|
|
84
|
+
- (void) didUpdateReactSubviews
|
|
85
|
+
{
|
|
86
|
+
[super didUpdateReactSubviews];
|
|
87
|
+
if (_iconView){
|
|
88
|
+
[_iconView setFrame:self.frame];
|
|
89
|
+
}
|
|
60
90
|
}
|
|
61
91
|
|
|
92
|
+
- (void) didInsertInMap:(AIRGoogleMap *) map
|
|
93
|
+
{
|
|
94
|
+
_realMarker = [AIRGMSMarker new];
|
|
95
|
+
_realMarker.fakeMarker = self;
|
|
96
|
+
_realMarker.tracksViewChanges = _tracksViewChanges;
|
|
97
|
+
_realMarker.tracksInfoWindowChanges = _tracksInfoWindowChanges;
|
|
62
98
|
|
|
99
|
+
[_realMarker setPosition:_coordinates];
|
|
100
|
+
if (_iconView){
|
|
101
|
+
[_realMarker setIconView:_iconView];
|
|
102
|
+
}
|
|
103
|
+
if (_rotation != 0){
|
|
104
|
+
[_realMarker setRotation:_rotation];
|
|
105
|
+
}
|
|
106
|
+
if (_identifier){
|
|
107
|
+
[_realMarker setIdentifier:_identifier];
|
|
108
|
+
}
|
|
109
|
+
if (_title){
|
|
110
|
+
[_realMarker setTitle:_title];
|
|
111
|
+
}
|
|
112
|
+
if (_subtitle){
|
|
113
|
+
[_realMarker setSnippet:_subtitle];
|
|
114
|
+
}
|
|
115
|
+
if (!CGPointEqualToPoint(_anchor, CGPointZero)){
|
|
116
|
+
[_realMarker setGroundAnchor:_anchor];
|
|
117
|
+
}
|
|
118
|
+
if (!CGPointEqualToPoint(_calloutAnchor, CGPointZero)){
|
|
119
|
+
[_realMarker setInfoWindowAnchor:_calloutAnchor];
|
|
120
|
+
}
|
|
121
|
+
if (_flat){
|
|
122
|
+
[_realMarker setFlat:_flat];
|
|
123
|
+
}
|
|
124
|
+
if (_draggable){
|
|
125
|
+
[_realMarker setDraggable:_draggable];
|
|
126
|
+
}
|
|
127
|
+
[_realMarker setTappable:_tappable];
|
|
128
|
+
if (_pinColor){
|
|
129
|
+
_realMarker.icon = [GMSMarker markerImageWithColor:_pinColor];
|
|
130
|
+
}
|
|
131
|
+
if (_opacity != 1.0){
|
|
132
|
+
[_realMarker setOpacity:_opacity];
|
|
133
|
+
}
|
|
134
|
+
if (_onSelect){
|
|
135
|
+
[_realMarker setOnSelect:_onSelect];
|
|
136
|
+
}
|
|
137
|
+
if (_onDeselect){
|
|
138
|
+
[_realMarker setOnDeselect:_onDeselect];
|
|
139
|
+
}
|
|
140
|
+
if (_onPress){
|
|
141
|
+
[_realMarker setOnPress:_onPress];
|
|
142
|
+
}
|
|
143
|
+
[_realMarker setMap:map];
|
|
144
|
+
}
|
|
63
145
|
|
|
64
146
|
- (void)iconViewInsertSubview:(UIView*)subview atIndex:(NSInteger)atIndex {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
147
|
+
if (!_iconView){
|
|
148
|
+
_iconView = [[UIView alloc] init];
|
|
149
|
+
}
|
|
150
|
+
if (!_realMarker.iconView) {
|
|
151
|
+
_realMarker.iconView = _iconView;
|
|
152
|
+
}
|
|
153
|
+
[_iconView insertSubview:subview atIndex:atIndex];
|
|
70
154
|
}
|
|
71
155
|
|
|
72
156
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
157
|
+
if ([subview isKindOfClass:[AIRGoogleMapCallout class]]) {
|
|
158
|
+
self.calloutView = (AIRGoogleMapCallout *)subview;
|
|
159
|
+
} else { // a child view of the marker
|
|
160
|
+
[self iconViewInsertSubview:(UIView*)subview atIndex:atIndex+1];
|
|
161
|
+
}
|
|
162
|
+
AIRDummyView *dummySubview = [[AIRDummyView alloc] initWithView:(UIView *)subview];
|
|
163
|
+
[super insertReactSubview:(UIView*)dummySubview atIndex:atIndex];
|
|
80
164
|
}
|
|
81
165
|
|
|
82
166
|
- (void)removeReactSubview:(id<RCTComponent>)dummySubview {
|
|
83
|
-
|
|
167
|
+
UIView *subview = [dummySubview isKindOfClass:[AIRDummyView class]] ? ((AIRDummyView *)dummySubview).view : (UIView *)dummySubview;
|
|
84
168
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
169
|
+
if ([subview isKindOfClass:[AIRGoogleMapCallout class]]) {
|
|
170
|
+
self.calloutView = nil;
|
|
171
|
+
} else {
|
|
172
|
+
[subview removeFromSuperview];
|
|
173
|
+
}
|
|
174
|
+
[super removeReactSubview:(UIView*)dummySubview];
|
|
91
175
|
}
|
|
92
176
|
|
|
93
177
|
- (void)showCalloutView {
|
|
94
|
-
|
|
178
|
+
[_realMarker.map setSelectedMarker:_realMarker];
|
|
95
179
|
}
|
|
96
180
|
|
|
97
181
|
- (void)hideCalloutView {
|
|
98
|
-
|
|
182
|
+
[_realMarker.map setSelectedMarker:Nil];
|
|
99
183
|
}
|
|
100
184
|
|
|
101
185
|
- (void)redraw {
|
|
102
|
-
|
|
186
|
+
if (!_realMarker.iconView) return;
|
|
103
187
|
|
|
104
|
-
|
|
188
|
+
BOOL oldValue = _realMarker.tracksViewChanges;
|
|
105
189
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
190
|
+
if (oldValue == YES)
|
|
191
|
+
{
|
|
192
|
+
// Immediate refresh, like right now. Not waiting for next frame.
|
|
193
|
+
UIView *view = _realMarker.iconView;
|
|
194
|
+
_realMarker.iconView = nil;
|
|
195
|
+
_realMarker.iconView = view;
|
|
196
|
+
}
|
|
197
|
+
else
|
|
198
|
+
{
|
|
199
|
+
// Refresh according to docs
|
|
200
|
+
_realMarker.tracksViewChanges = YES;
|
|
201
|
+
_realMarker.tracksViewChanges = NO;
|
|
202
|
+
}
|
|
119
203
|
}
|
|
120
204
|
|
|
121
205
|
- (UIView *)markerInfoContents {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
206
|
+
if (self.calloutView && !self.calloutView.tooltip) {
|
|
207
|
+
return self.calloutView;
|
|
208
|
+
}
|
|
209
|
+
return nil;
|
|
126
210
|
}
|
|
127
211
|
|
|
128
212
|
- (UIView *)markerInfoWindow {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
213
|
+
if (self.calloutView && self.calloutView.tooltip) {
|
|
214
|
+
return self.calloutView;
|
|
215
|
+
}
|
|
216
|
+
return nil;
|
|
133
217
|
}
|
|
134
218
|
|
|
135
219
|
- (void)didTapInfoWindowOfMarker:(AIRGMSMarker *)marker point:(CGPoint)point frame:(CGRect)frame {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
220
|
+
if (self.calloutView && self.calloutView.onPress) {
|
|
221
|
+
//todo: why not 'callout-press' ?
|
|
222
|
+
id event = @{
|
|
223
|
+
@"action": @"marker-overlay-press",
|
|
224
|
+
@"id": self.identifier ?: @"unknown",
|
|
225
|
+
@"point": @{
|
|
226
|
+
@"x": @(point.x),
|
|
227
|
+
@"y": @(point.y),
|
|
228
|
+
},
|
|
229
|
+
@"frame": @{
|
|
230
|
+
@"x": @(frame.origin.x),
|
|
231
|
+
@"y": @(frame.origin.y),
|
|
232
|
+
@"width": @(frame.size.width),
|
|
233
|
+
@"height": @(frame.size.height),
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
self.calloutView.onPress(event);
|
|
237
|
+
}
|
|
154
238
|
}
|
|
155
239
|
|
|
156
240
|
- (void)didTapInfoWindowOfMarker:(AIRGMSMarker *)marker {
|
|
@@ -161,19 +245,19 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
161
245
|
if (subview && subview.onPress) {
|
|
162
246
|
//todo: why not 'callout-inside-press' ?
|
|
163
247
|
id event = @{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
248
|
+
@"action": @"marker-inside-overlay-press",
|
|
249
|
+
@"id": self.identifier ?: @"unknown",
|
|
250
|
+
@"point": @{
|
|
251
|
+
@"x": @(point.x),
|
|
252
|
+
@"y": @(point.y),
|
|
253
|
+
},
|
|
254
|
+
@"frame": @{
|
|
255
|
+
@"x": @(frame.origin.x),
|
|
256
|
+
@"y": @(frame.origin.y),
|
|
257
|
+
@"width": @(frame.size.width),
|
|
258
|
+
@"height": @(frame.size.height),
|
|
259
|
+
}
|
|
260
|
+
};
|
|
177
261
|
subview.onPress(event);
|
|
178
262
|
} else {
|
|
179
263
|
[self didTapInfoWindowOfMarker:marker point:point frame:frame];
|
|
@@ -181,30 +265,32 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
181
265
|
}
|
|
182
266
|
|
|
183
267
|
- (void)didBeginDraggingMarker:(AIRGMSMarker *)marker {
|
|
184
|
-
|
|
185
|
-
|
|
268
|
+
if (!self.onDragStart) return;
|
|
269
|
+
self.onDragStart([self makeEventData]);
|
|
186
270
|
}
|
|
187
271
|
|
|
188
272
|
- (void)didEndDraggingMarker:(AIRGMSMarker *)marker {
|
|
189
|
-
|
|
190
|
-
|
|
273
|
+
if (!self.onDragEnd) return;
|
|
274
|
+
self.onDragEnd([self makeEventData]);
|
|
191
275
|
}
|
|
192
276
|
|
|
193
277
|
- (void)didDragMarker:(AIRGMSMarker *)marker {
|
|
194
|
-
|
|
195
|
-
|
|
278
|
+
if (!self.onDrag) return;
|
|
279
|
+
self.onDrag([self makeEventData]);
|
|
196
280
|
}
|
|
197
281
|
|
|
198
282
|
- (void)setCoordinate:(CLLocationCoordinate2D)coordinate {
|
|
199
|
-
|
|
283
|
+
_realMarker.position = coordinate;
|
|
284
|
+
_coordinates = coordinate;
|
|
200
285
|
}
|
|
201
286
|
|
|
202
287
|
- (CLLocationCoordinate2D)coordinate {
|
|
203
|
-
|
|
288
|
+
return _realMarker.position;
|
|
204
289
|
}
|
|
205
290
|
|
|
206
291
|
- (void)setRotation:(CLLocationDegrees)rotation {
|
|
207
292
|
_realMarker.rotation = rotation;
|
|
293
|
+
_rotation = rotation;
|
|
208
294
|
}
|
|
209
295
|
|
|
210
296
|
- (CLLocationDegrees)rotation {
|
|
@@ -212,220 +298,235 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
212
298
|
}
|
|
213
299
|
|
|
214
300
|
- (void)setIdentifier:(NSString *)identifier {
|
|
215
|
-
|
|
301
|
+
_realMarker.identifier = identifier;
|
|
302
|
+
_identifier = identifier;
|
|
216
303
|
}
|
|
217
304
|
|
|
218
305
|
- (NSString *)identifier {
|
|
219
|
-
|
|
306
|
+
return _realMarker.identifier;
|
|
220
307
|
}
|
|
221
308
|
|
|
222
309
|
- (void)setOnPress:(RCTBubblingEventBlock)onPress {
|
|
223
|
-
|
|
310
|
+
_realMarker.onPress = onPress;
|
|
311
|
+
_onPress = onPress;
|
|
224
312
|
}
|
|
225
313
|
|
|
226
314
|
- (RCTBubblingEventBlock)onPress {
|
|
227
|
-
|
|
315
|
+
return _realMarker.onPress;
|
|
228
316
|
}
|
|
229
317
|
|
|
230
318
|
- (void)setOnSelect:(RCTDirectEventBlock)onSelect {
|
|
231
|
-
|
|
319
|
+
_realMarker.onSelect = onSelect;
|
|
320
|
+
_onSelect = onSelect;
|
|
232
321
|
}
|
|
233
322
|
|
|
234
323
|
- (RCTDirectEventBlock)onSelect {
|
|
235
|
-
|
|
324
|
+
return _realMarker.onSelect;
|
|
236
325
|
}
|
|
237
326
|
|
|
238
327
|
- (void)setOnDeselect:(RCTDirectEventBlock)onDeselect {
|
|
239
|
-
|
|
328
|
+
_realMarker.onDeselect = onDeselect;
|
|
329
|
+
_onDeselect = onDeselect;
|
|
240
330
|
}
|
|
241
331
|
|
|
242
332
|
- (RCTDirectEventBlock)onDeselect {
|
|
243
|
-
|
|
333
|
+
return _realMarker.onDeselect;
|
|
244
334
|
}
|
|
245
335
|
|
|
246
336
|
- (void)setOpacity:(double)opacity
|
|
247
337
|
{
|
|
248
|
-
|
|
338
|
+
_realMarker.opacity = opacity;
|
|
339
|
+
_opacity = opacity;
|
|
249
340
|
}
|
|
250
341
|
|
|
251
342
|
- (void)setImageSrc:(NSString *)imageSrc
|
|
252
343
|
{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
344
|
+
_imageSrc = imageSrc;
|
|
345
|
+
|
|
346
|
+
if (_reloadImageCancellationBlock) {
|
|
347
|
+
_reloadImageCancellationBlock();
|
|
348
|
+
_reloadImageCancellationBlock = nil;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!_imageSrc) {
|
|
352
|
+
if (_iconImageView) [_iconImageView removeFromSuperview];
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (!_iconImageView) {
|
|
357
|
+
// prevent glitch with marker (cf. https://github.com/react-native-maps/react-native-maps/issues/738)
|
|
358
|
+
UIImageView *empyImageView = [[UIImageView alloc] init];
|
|
359
|
+
_iconImageView = empyImageView;
|
|
360
|
+
[self iconViewInsertSubview:_iconImageView atIndex:0];
|
|
361
|
+
}
|
|
362
|
+
__weak AIRGoogleMapMarker* weakSelf = self;
|
|
363
|
+
|
|
364
|
+
_reloadImageCancellationBlock = [[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
|
|
365
|
+
size:self.bounds.size
|
|
366
|
+
scale:RCTScreenScale()
|
|
367
|
+
clipped:YES
|
|
368
|
+
resizeMode:RCTResizeModeCenter
|
|
369
|
+
progressBlock:nil
|
|
370
|
+
partialLoadBlock:nil
|
|
371
|
+
completionBlock:^(NSError *error, UIImage *image) {
|
|
372
|
+
if (error) {
|
|
373
|
+
// TODO(lmr): do something with the error?
|
|
374
|
+
NSLog(@"%@", error);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
378
|
+
__strong AIRGoogleMapMarker* strongSelf = weakSelf;
|
|
379
|
+
|
|
380
|
+
// TODO(gil): This way allows different image sizes
|
|
381
|
+
if (strongSelf->_iconImageView) [strongSelf->_iconImageView removeFromSuperview];
|
|
382
|
+
|
|
383
|
+
// ... but this way is more efficient?
|
|
384
|
+
// if (_iconImageView) {
|
|
385
|
+
// [_iconImageView setImage:image];
|
|
386
|
+
// return;
|
|
387
|
+
// }
|
|
388
|
+
|
|
389
|
+
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
|
|
390
|
+
|
|
391
|
+
// TODO: w,h or pixel density could be a prop.
|
|
392
|
+
float density = 1;
|
|
393
|
+
float w = image.size.width/density;
|
|
394
|
+
float h = image.size.height/density;
|
|
395
|
+
CGRect bounds = CGRectMake(0, 0, w, h);
|
|
396
|
+
|
|
397
|
+
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
398
|
+
[imageView setFrame:bounds];
|
|
399
|
+
|
|
400
|
+
// NOTE: sizeToFit doesn't work instead. Not sure why.
|
|
401
|
+
// TODO: Doing it this way is not ideal because it causes things to reshuffle
|
|
402
|
+
// when the image loads IF the image is larger than the UIView.
|
|
403
|
+
// Shouldn't required images have size info automatically via RN?
|
|
404
|
+
CGRect selfBounds = unionRect(bounds, self.bounds);
|
|
405
|
+
[strongSelf setFrame:selfBounds];
|
|
406
|
+
|
|
407
|
+
strongSelf->_iconImageView = imageView;
|
|
408
|
+
[strongSelf iconViewInsertSubview:imageView atIndex:0];
|
|
409
|
+
[strongSelf layoutSubviews];
|
|
410
|
+
[strongSelf.realMarker setIconView:strongSelf.iconView];
|
|
411
|
+
});
|
|
412
|
+
}];
|
|
317
413
|
}
|
|
318
414
|
|
|
319
415
|
- (void)setIconSrc:(NSString *)iconSrc
|
|
320
416
|
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
417
|
+
_iconSrc = iconSrc;
|
|
418
|
+
|
|
419
|
+
if (_reloadImageCancellationBlock) {
|
|
420
|
+
_reloadImageCancellationBlock();
|
|
421
|
+
_reloadImageCancellationBlock = nil;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (!_realMarker.icon) {
|
|
425
|
+
// prevent glitch with marker (cf. https://github.com/react-native-maps/react-native-maps/issues/3657)
|
|
426
|
+
UIImage *emptyImage = [[UIImage alloc] init];
|
|
427
|
+
_realMarker.icon = emptyImage;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
_reloadImageCancellationBlock =
|
|
431
|
+
[[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_iconSrc]
|
|
432
|
+
size:self.bounds.size
|
|
433
|
+
scale:RCTScreenScale()
|
|
434
|
+
clipped:YES
|
|
435
|
+
resizeMode:RCTResizeModeCenter
|
|
436
|
+
progressBlock:nil
|
|
437
|
+
partialLoadBlock:nil
|
|
438
|
+
completionBlock:^(NSError *error, UIImage *image) {
|
|
439
|
+
if (error) {
|
|
440
|
+
// TODO(lmr): do something with the error?
|
|
441
|
+
NSLog(@"%@", error);
|
|
442
|
+
}
|
|
443
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
444
|
+
self->_realMarker.icon = image;
|
|
445
|
+
});
|
|
446
|
+
}];
|
|
351
447
|
}
|
|
352
448
|
|
|
353
449
|
- (void)setTitle:(NSString *)title {
|
|
354
|
-
|
|
450
|
+
_realMarker.title = [title copy];
|
|
451
|
+
_title = title;
|
|
355
452
|
}
|
|
356
453
|
|
|
357
454
|
- (NSString *)title {
|
|
358
|
-
|
|
455
|
+
return _realMarker.title;
|
|
359
456
|
}
|
|
360
457
|
|
|
361
458
|
- (void)setSubtitle:(NSString *)subtitle {
|
|
362
|
-
|
|
459
|
+
_realMarker.snippet = subtitle;
|
|
460
|
+
_subtitle = subtitle;
|
|
363
461
|
}
|
|
364
462
|
|
|
365
463
|
- (NSString *)subtitle {
|
|
366
|
-
|
|
464
|
+
return _realMarker.snippet;
|
|
367
465
|
}
|
|
368
466
|
|
|
369
467
|
- (void)setPinColor:(UIColor *)pinColor {
|
|
370
|
-
|
|
371
|
-
|
|
468
|
+
_pinColor = pinColor;
|
|
469
|
+
_realMarker.icon = [GMSMarker markerImageWithColor:pinColor];
|
|
372
470
|
}
|
|
373
471
|
|
|
374
472
|
- (void)setAnchor:(CGPoint)anchor {
|
|
375
|
-
|
|
376
|
-
|
|
473
|
+
_anchor = anchor;
|
|
474
|
+
_realMarker.groundAnchor = anchor;
|
|
377
475
|
}
|
|
378
476
|
|
|
379
477
|
- (void)setCalloutAnchor:(CGPoint)calloutAnchor {
|
|
380
|
-
|
|
381
|
-
|
|
478
|
+
_calloutAnchor = calloutAnchor;
|
|
479
|
+
_realMarker.infoWindowAnchor = calloutAnchor;
|
|
382
480
|
}
|
|
383
481
|
|
|
384
482
|
|
|
385
483
|
- (void)setZIndex:(NSInteger)zIndex
|
|
386
484
|
{
|
|
387
|
-
|
|
388
|
-
|
|
485
|
+
_zIndex = zIndex;
|
|
486
|
+
_realMarker.zIndex = (int)zIndex;
|
|
389
487
|
}
|
|
390
488
|
|
|
391
489
|
- (void)setDraggable:(BOOL)draggable {
|
|
392
|
-
|
|
490
|
+
_realMarker.draggable = draggable;
|
|
491
|
+
_draggable = draggable;
|
|
393
492
|
}
|
|
394
493
|
|
|
395
494
|
- (BOOL)draggable {
|
|
396
|
-
|
|
495
|
+
return _realMarker.draggable;
|
|
397
496
|
}
|
|
398
497
|
|
|
399
498
|
- (void)setTappable:(BOOL)tappable {
|
|
400
|
-
|
|
499
|
+
_realMarker.tappable = tappable;
|
|
500
|
+
_tappable = tappable;
|
|
401
501
|
}
|
|
402
502
|
|
|
403
503
|
- (BOOL)tappable {
|
|
404
|
-
|
|
504
|
+
return _realMarker.tappable;
|
|
405
505
|
}
|
|
406
506
|
|
|
407
507
|
- (void)setFlat:(BOOL)flat {
|
|
408
|
-
|
|
508
|
+
_realMarker.flat = flat;
|
|
509
|
+
_flat = flat;
|
|
409
510
|
}
|
|
410
511
|
|
|
411
512
|
- (BOOL)flat {
|
|
412
|
-
|
|
513
|
+
return _realMarker.flat;
|
|
413
514
|
}
|
|
414
515
|
|
|
415
516
|
- (void)setTracksViewChanges:(BOOL)tracksViewChanges {
|
|
416
|
-
|
|
517
|
+
_realMarker.tracksViewChanges = tracksViewChanges;
|
|
417
518
|
}
|
|
418
519
|
|
|
419
520
|
- (BOOL)tracksViewChanges {
|
|
420
|
-
|
|
521
|
+
return _realMarker.tracksViewChanges;
|
|
421
522
|
}
|
|
422
523
|
|
|
423
524
|
- (void)setTracksInfoWindowChanges:(BOOL)tracksInfoWindowChanges {
|
|
424
|
-
|
|
525
|
+
_realMarker.tracksInfoWindowChanges = tracksInfoWindowChanges;
|
|
425
526
|
}
|
|
426
527
|
|
|
427
528
|
- (BOOL)tracksInfoWindowChanges {
|
|
428
|
-
|
|
529
|
+
return _realMarker.tracksInfoWindowChanges;
|
|
429
530
|
}
|
|
430
531
|
|
|
431
532
|
|
|
@@ -434,17 +535,17 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
434
535
|
CGPoint position = [self.realMarker.map.projection pointForCoordinate:coordinate];
|
|
435
536
|
|
|
436
537
|
return @{
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
538
|
+
@"id": self.identifier ?: @"unknown",
|
|
539
|
+
@"position": @{
|
|
540
|
+
@"x": @(position.x),
|
|
541
|
+
@"y": @(position.y),
|
|
542
|
+
},
|
|
543
|
+
@"coordinate": @{
|
|
544
|
+
@"latitude": @(coordinate.latitude),
|
|
545
|
+
@"longitude": @(coordinate.longitude),
|
|
546
|
+
},
|
|
547
|
+
@"action": action,
|
|
548
|
+
};
|
|
448
549
|
}
|
|
449
550
|
|
|
450
551
|
- (id)makeEventData {
|