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