react-native-maps 1.21.0-alpha.5 → 1.21.0-alpha.7
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/ios/AirGoogleMaps/AIRGoogleMap.h +6 -1
- package/ios/AirGoogleMaps/AIRGoogleMap.m +90 -7
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- 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 +13 -91
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +2 -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/RCTConvert+GMSMapViewType.m +16 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +529 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +2 -2
- package/ios/AirMaps/AIRMap.m +2 -2
- package/ios/AirMaps/AIRMapManager.m +4 -4
- package/ios/AirMaps/RNMapsAirModule.h +3 -0
- package/ios/AirMaps/RNMapsMapView.h +3 -0
- package/ios/AirMaps/RNMapsMapView.mm +2 -25
- package/lib/FabricMapView.d.ts +7 -2
- package/lib/FabricMapView.js +7 -1
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapView.d.ts +2 -2
- package/lib/MapView.js +5 -12
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentMapView.d.ts +4 -11
- package/package.json +6 -6
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsGoogleMapView.mm
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
9
|
+
|
|
10
|
+
#import "RNMapsGoogleMapView.h"
|
|
11
|
+
#import "AirGoogleMap.h"
|
|
12
|
+
#import "AIRMapMarker.h"
|
|
13
|
+
#import "AirGoogleMapManager.h"
|
|
14
|
+
|
|
15
|
+
#import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
|
|
16
|
+
#import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
|
|
17
|
+
#import <react/renderer/components/RNMapsSpecs/Props.h>
|
|
18
|
+
#import <react/renderer/components/RNMapsSpecs/RCTComponentViewHelpers.h>
|
|
19
|
+
|
|
20
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
21
|
+
#import <React/RCTConversions.h>
|
|
22
|
+
#import "RCTConvert+GMSMapViewType.h"
|
|
23
|
+
#import "RCTConvert+AirMap.h"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
using namespace facebook::react;
|
|
27
|
+
|
|
28
|
+
@interface RNMapsGoogleMapView () <RCTRNMapsGoogleMapViewViewProtocol>
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@implementation RNMapsGoogleMapView {
|
|
32
|
+
AIRGoogleMap *_view;
|
|
33
|
+
AIRGoogleMapManager* _legacyMapManager;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
- (AIRGoogleMap *) mapView {
|
|
38
|
+
return _view;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pragma mark - JS Commands
|
|
42
|
+
- (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
|
|
43
|
+
NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
|
|
44
|
+
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:regionDic];
|
|
45
|
+
[CATransaction begin];
|
|
46
|
+
[CATransaction setAnimationDuration:duration/1000];
|
|
47
|
+
GMSCameraPosition *camera = [AIRGoogleMap makeGMSCameraPositionFromMap:_view andMKCoordinateRegion:region];
|
|
48
|
+
[self->_view animateToCameraPosition:camera];
|
|
49
|
+
[CATransaction commit];
|
|
50
|
+
}
|
|
51
|
+
- (void)setCamera:(NSString *)cameraJSON{
|
|
52
|
+
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
53
|
+
GMSCameraPosition* camera = [RCTConvert GMSCameraPositionWithDefaults:cameraDic existingCamera:[_view camera]];
|
|
54
|
+
[_view setCamera:camera];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)animateCamera:(NSString *)cameraJSON duration:(NSInteger)duration{
|
|
58
|
+
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
59
|
+
GMSCameraPosition* camera = [RCTConvert GMSCameraPositionWithDefaults:cameraDic existingCamera:[_view camera]];
|
|
60
|
+
[_view animateToCameraPosition:camera];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)fitToElements:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
64
|
+
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
65
|
+
[_view fitToElementsWithEdgePadding:edgePadding animated:animated];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)fitToSuppliedMarkers:(NSString *)markersJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
69
|
+
NSArray* markers = [RCTConvert arrayFromString:markersJSON];
|
|
70
|
+
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
71
|
+
[_view fitToSuppliedMarkers:markers withEdgePadding:edgePadding animated:animated];
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
- (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
75
|
+
NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
|
|
76
|
+
|
|
77
|
+
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
78
|
+
|
|
79
|
+
// [_view fitToCoordinates:coordinatesArr withEdgePadding:edgePadding animated:animated];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#pragma mark - Native commands
|
|
83
|
+
|
|
84
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
85
|
+
{
|
|
86
|
+
RCTRNMapsGoogleMapViewHandleCommand(self, commandName, args);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
91
|
+
{
|
|
92
|
+
return concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDescriptor>();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (void) prepareContentView {
|
|
96
|
+
|
|
97
|
+
_view = (AIRGoogleMap *)[_legacyMapManager view];
|
|
98
|
+
|
|
99
|
+
self.contentView = _view;
|
|
100
|
+
|
|
101
|
+
_view.onPress = [self](NSDictionary* dictionary) {
|
|
102
|
+
if (_eventEmitter) {
|
|
103
|
+
// Extract values from the NSDictionary
|
|
104
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
105
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
106
|
+
|
|
107
|
+
// Populate the OnMapPressCoordinate struct
|
|
108
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPressCoordinate coordinate = {
|
|
109
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
110
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Populate the OnMapPressPosition struct
|
|
114
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPressPosition position = {
|
|
115
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
116
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
120
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPress data = {
|
|
121
|
+
.action = std::string([@"press" UTF8String]),
|
|
122
|
+
.position = position,
|
|
123
|
+
.coordinate = coordinate
|
|
124
|
+
};
|
|
125
|
+
mapViewEventEmitter->onPress(data);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
_view.onMapReady = [self](NSDictionary* dictionary) {
|
|
130
|
+
if (_eventEmitter) {
|
|
131
|
+
NSLog(@"mapReady");
|
|
132
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
133
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapReady data = {};
|
|
134
|
+
mapViewEventEmitter->onMapReady(data);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
_view.onMapLoaded = [self](NSDictionary* dictionary) {
|
|
139
|
+
if (_eventEmitter) {
|
|
140
|
+
NSLog(@"mapLoaded");
|
|
141
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
142
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapLoaded data = {};
|
|
143
|
+
mapViewEventEmitter->onMapLoaded(data);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
_view.onKmlReady = [self](NSDictionary* dictionary) {
|
|
148
|
+
if (_eventEmitter) {
|
|
149
|
+
|
|
150
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
151
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnKmlReady data = {};
|
|
152
|
+
mapViewEventEmitter->onKmlReady(data);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
_view.onChange = [self](NSDictionary* dictionary) {
|
|
156
|
+
if (_eventEmitter) {
|
|
157
|
+
|
|
158
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
159
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
160
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChange data = {
|
|
161
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
162
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
163
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
164
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
165
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
166
|
+
};
|
|
167
|
+
mapViewEventEmitter->onRegionChange(data);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
_view.onPanDrag = [self](NSDictionary* dictionary) {
|
|
172
|
+
if (_eventEmitter) {
|
|
173
|
+
|
|
174
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
175
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
176
|
+
|
|
177
|
+
// Populate the OnMapPressCoordinate struct
|
|
178
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPanDragCoordinate coordinate = {
|
|
179
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
180
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// Populate the OnMapDouplePressPosition struct
|
|
184
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPanDragPosition position = {
|
|
185
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
186
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
190
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPanDrag data = {
|
|
191
|
+
.position = position,
|
|
192
|
+
.coordinate = coordinate,
|
|
193
|
+
};
|
|
194
|
+
mapViewEventEmitter->onPanDrag(data);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
_view.onUserLocationChange = [self](NSDictionary* dictionary) {
|
|
199
|
+
if (_eventEmitter) {
|
|
200
|
+
|
|
201
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
202
|
+
NSDictionary* errorDict = dictionary[@"error"];
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
// Populate the OnMapPressCoordinate struct
|
|
206
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
|
|
207
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
208
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
209
|
+
};
|
|
210
|
+
NSString* str = @"";
|
|
211
|
+
if (errorDict){
|
|
212
|
+
str = errorDict[@"message"];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChangeError error = {
|
|
216
|
+
.message = std::string([str UTF8String]),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
221
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChange data = {
|
|
222
|
+
.coordinate = coordinate,
|
|
223
|
+
.error = error,
|
|
224
|
+
};
|
|
225
|
+
mapViewEventEmitter->onUserLocationChange(data);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
_view.onRegionChangeStart = [self](NSDictionary* dictionary) {
|
|
232
|
+
if (_eventEmitter) {
|
|
233
|
+
|
|
234
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
235
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
236
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChangeStart data = {
|
|
237
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
238
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
239
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
240
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
241
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
242
|
+
};
|
|
243
|
+
mapViewEventEmitter->onRegionChangeStart(data);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
_view.onRegionChange = [self](NSDictionary* dictionary) {
|
|
248
|
+
if (_eventEmitter) {
|
|
249
|
+
|
|
250
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
251
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
252
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChange data = {
|
|
253
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
254
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
255
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
256
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
257
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
258
|
+
};
|
|
259
|
+
mapViewEventEmitter->onRegionChange(data);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
_view.onRegionChangeComplete = [self](NSDictionary* dictionary) {
|
|
264
|
+
if (_eventEmitter) {
|
|
265
|
+
|
|
266
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
267
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
268
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChangeComplete data = {
|
|
269
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
270
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
271
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
272
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
273
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
274
|
+
};
|
|
275
|
+
mapViewEventEmitter->onRegionChangeComplete(data);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
#define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
|
|
281
|
+
if (_eventEmitter) { \
|
|
282
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
283
|
+
auto mapViewEventEmitter = \
|
|
284
|
+
std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter); \
|
|
285
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::eventName data = { \
|
|
286
|
+
.coordinate.latitude = [coordinateDict[@"latitude"] doubleValue], \
|
|
287
|
+
.coordinate.longitude = [coordinateDict[@"longitude"] doubleValue], \
|
|
288
|
+
.id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
|
|
289
|
+
}; \
|
|
290
|
+
mapViewEventEmitter->emitterFunction(data); \
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
#define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
|
|
296
|
+
if (_eventEmitter) { \
|
|
297
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
298
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::eventName##Coordinate coordinate = { \
|
|
299
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue], \
|
|
300
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue], \
|
|
301
|
+
}; \
|
|
302
|
+
\
|
|
303
|
+
auto mapViewEventEmitter = \
|
|
304
|
+
std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter); \
|
|
305
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::eventName data = { \
|
|
306
|
+
.action = std::string([@actionName UTF8String]), \
|
|
307
|
+
.id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
|
|
308
|
+
.coordinate = coordinate \
|
|
309
|
+
}; \
|
|
310
|
+
mapViewEventEmitter->emitterFunction(data); \
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
_view.onMarkerSelect = [self](NSDictionary* dictionary) {
|
|
314
|
+
HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
_view.onMarkerDeselect = [self](NSDictionary* dictionary) {
|
|
318
|
+
HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
_view.onMarkerPress = [self](NSDictionary* dictionary) {
|
|
322
|
+
HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
327
|
+
{
|
|
328
|
+
if (self = [super initWithFrame:frame]) {
|
|
329
|
+
static const auto defaultProps = std::make_shared<const RNMapsGoogleMapViewProps>();
|
|
330
|
+
_props = defaultProps;
|
|
331
|
+
_legacyMapManager = [[AIRGoogleMapManager alloc] init];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return self;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
- (id)getPaperViewFromChildComponentView:(UIView *)childComponentView {
|
|
338
|
+
// Check if the childComponentView responds to the "adapter" selector
|
|
339
|
+
if ([childComponentView respondsToSelector:@selector(paperView)]) {
|
|
340
|
+
// Safely return the paperView
|
|
341
|
+
return [childComponentView valueForKey:@"paperView"];
|
|
342
|
+
}
|
|
343
|
+
// Return nil if paperView is not accessible
|
|
344
|
+
return nil;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
|
|
348
|
+
id<RCTComponent> paperView = [self getPaperViewFromChildComponentView:childComponentView];
|
|
349
|
+
if (paperView){
|
|
350
|
+
[_view insertReactSubview:paperView atIndex:index];
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
- (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
354
|
+
{
|
|
355
|
+
id<RCTComponent> paperView = [self getPaperViewFromChildComponentView:childComponentView];
|
|
356
|
+
if (paperView){
|
|
357
|
+
[_view removeReactSubview:paperView];
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
363
|
+
{
|
|
364
|
+
const auto &oldViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(_props);
|
|
365
|
+
const auto &newViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(props);
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
if (oldViewProps.googleMapId != newViewProps.googleMapId) {
|
|
369
|
+
NSString* mapID = RCTNSStringFromString(newViewProps.googleMapId);
|
|
370
|
+
if (mapID && [mapID length]){
|
|
371
|
+
_legacyMapManager.googleMapId = mapID;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (!newViewProps.zoomTapEnabled) {
|
|
375
|
+
_legacyMapManager.zoomTapEnabled = newViewProps.zoomTapEnabled;
|
|
376
|
+
} else {
|
|
377
|
+
_legacyMapManager.zoomTapEnabled = true;
|
|
378
|
+
}
|
|
379
|
+
if (oldViewProps.loadingBackgroundColor != newViewProps.loadingBackgroundColor){
|
|
380
|
+
_legacyMapManager.backgroundColor = RCTUIColorFromSharedColor(newViewProps.backgroundColor);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
NSLog(@"initialCamera lat:%f lng:%f pitch:%f zoom:%f heading: %f", newViewProps.initialCamera.center.latitude, newViewProps.initialCamera.center.longitude, newViewProps.initialCamera.pitch, newViewProps.initialCamera.zoom, newViewProps.initialCamera.heading);
|
|
384
|
+
|
|
385
|
+
// bug with zoom / pitch / heading where value is not 0 even though
|
|
386
|
+
// nothing is passed from JS so we depend on lat / lng comparison for now
|
|
387
|
+
if (newViewProps.initialCamera.center.latitude != oldViewProps.initialCamera.center.latitude ||
|
|
388
|
+
newViewProps.initialCamera.center.longitude != oldViewProps.initialCamera.center.longitude ||
|
|
389
|
+
newViewProps.initialCamera.pitch != oldViewProps.initialCamera.pitch ||
|
|
390
|
+
newViewProps.initialCamera.zoom != oldViewProps.initialCamera.zoom
|
|
391
|
+
|| newViewProps.initialCamera.heading != oldViewProps.initialCamera.heading) {
|
|
392
|
+
GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.initialCamera.center.latitude
|
|
393
|
+
longitude:newViewProps.initialCamera.center.longitude
|
|
394
|
+
zoom:newViewProps.initialCamera.zoom
|
|
395
|
+
bearing:newViewProps.initialCamera.heading
|
|
396
|
+
viewingAngle:newViewProps.initialCamera.pitch];
|
|
397
|
+
_legacyMapManager.camera = camera;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
if (!_view){
|
|
403
|
+
[self prepareContentView];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
#define REMAP_MAPVIEW_PROP(name) \
|
|
407
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
408
|
+
_view.name = newViewProps.name; \
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
#define REMAP_MAPVIEW_STRING_PROP(name) \
|
|
412
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
413
|
+
_view.name = RCTNSStringFromString(newViewProps.name); \
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
#define REMAP_MAPVIEW_POINT_PROP(name) \
|
|
417
|
+
if (newViewProps.name.x != oldViewProps.name.x || \
|
|
418
|
+
newViewProps.name.y != oldViewProps.name.y) { \
|
|
419
|
+
_view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
#define REMAP_MAPVIEW_REGION_PROP(name) \
|
|
423
|
+
if (newViewProps.name.latitude != oldViewProps.name.latitude || \
|
|
424
|
+
newViewProps.name.longitude != oldViewProps.name.longitude || \
|
|
425
|
+
newViewProps.name.latitudeDelta != oldViewProps.name.latitudeDelta ||\
|
|
426
|
+
newViewProps.name.longitudeDelta != oldViewProps.name.longitudeDelta) { \
|
|
427
|
+
MKCoordinateSpan span = MKCoordinateSpanMake(newViewProps.name.latitudeDelta, \
|
|
428
|
+
newViewProps.name.longitudeDelta); \
|
|
429
|
+
MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake( \
|
|
430
|
+
newViewProps.name.latitude, newViewProps.name.longitude), span); \
|
|
431
|
+
_view.name = region; \
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
#define REMAP_GOOGLEMAPVIEW_CAMERA_PROP(name) \
|
|
435
|
+
if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
|
|
436
|
+
newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
|
|
437
|
+
newViewProps.name.heading != oldViewProps.name.heading || \
|
|
438
|
+
newViewProps.name.pitch != oldViewProps.name.pitch || \
|
|
439
|
+
newViewProps.name.zoom != oldViewProps.name.zoom) { \
|
|
440
|
+
GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.name.center.latitude \
|
|
441
|
+
longitude:newViewProps.name.center.longitude \
|
|
442
|
+
zoom:newViewProps.name.zoom \
|
|
443
|
+
bearing:newViewProps.name.heading \
|
|
444
|
+
viewingAngle:newViewProps.name.pitch]; \
|
|
445
|
+
_view.name = camera; \
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
#define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
|
|
450
|
+
if (newViewProps.name.top != oldViewProps.name.top || \
|
|
451
|
+
newViewProps.name.right != oldViewProps.name.right || \
|
|
452
|
+
newViewProps.name.bottom != oldViewProps.name.bottom || \
|
|
453
|
+
newViewProps.name.left != oldViewProps.name.left) { \
|
|
454
|
+
_view.name = UIEdgeInsetsMake(newViewProps.name.top, \
|
|
455
|
+
newViewProps.name.left, \
|
|
456
|
+
newViewProps.name.bottom, \
|
|
457
|
+
newViewProps.name.right); \
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
REMAP_MAPVIEW_PROP(pitchEnabled)
|
|
462
|
+
|
|
463
|
+
REMAP_MAPVIEW_PROP(zoomTapEnabled)
|
|
464
|
+
|
|
465
|
+
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
466
|
+
|
|
467
|
+
if (newViewProps.minZoom != oldViewProps.minZoom || newViewProps.maxZoom != oldViewProps.maxZoom){
|
|
468
|
+
[_view setMinZoom:newViewProps.minZoom maxZoom:newViewProps.maxZoom];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
REMAP_MAPVIEW_PROP(showsCompass)
|
|
472
|
+
REMAP_MAPVIEW_PROP(showsTraffic)
|
|
473
|
+
REMAP_MAPVIEW_PROP(showsUserLocation)
|
|
474
|
+
REMAP_MAPVIEW_PROP(zoomEnabled)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
REMAP_MAPVIEW_REGION_PROP(region)
|
|
478
|
+
REMAP_MAPVIEW_REGION_PROP(initialRegion)
|
|
479
|
+
|
|
480
|
+
REMAP_GOOGLEMAPVIEW_CAMERA_PROP(camera)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
if (oldViewProps.mapType != newViewProps.mapType){
|
|
487
|
+
switch (newViewProps.mapType) {
|
|
488
|
+
case RNMapsGoogleMapViewMapType::Standard:
|
|
489
|
+
_view.mapType = kGMSTypeNormal;
|
|
490
|
+
break;
|
|
491
|
+
case RNMapsGoogleMapViewMapType::Satellite:
|
|
492
|
+
_view.mapType = kGMSTypeSatellite;
|
|
493
|
+
break;
|
|
494
|
+
case RNMapsGoogleMapViewMapType::Terrain:
|
|
495
|
+
_view.mapType = kGMSTypeTerrain;
|
|
496
|
+
case RNMapsGoogleMapViewMapType::Hybrid:
|
|
497
|
+
_view.mapType = kGMSTypeHybrid;
|
|
498
|
+
default:
|
|
499
|
+
_view.mapType = kGMSTypeNormal;
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
|
|
505
|
+
switch (newViewProps.userInterfaceStyle) {
|
|
506
|
+
case RNMapsGoogleMapViewUserInterfaceStyle::Light:
|
|
507
|
+
_view.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
508
|
+
break;
|
|
509
|
+
case RNMapsGoogleMapViewUserInterfaceStyle::Dark:
|
|
510
|
+
_view.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
|
|
511
|
+
break;
|
|
512
|
+
case RNMapsGoogleMapViewUserInterfaceStyle::System:
|
|
513
|
+
_view.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
[super updateProps:props oldProps:oldProps];
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
@end
|
|
523
|
+
|
|
524
|
+
Class<RCTComponentViewProtocol> RNMapsGoogleMapViewCls(void)
|
|
525
|
+
{
|
|
526
|
+
return RNMapsGoogleMapView.class;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsMapViewManager.mm
|
|
3
|
+
// AirMaps
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
9
|
+
|
|
10
|
+
#import <React/RCTLog.h>
|
|
11
|
+
#import <React/RCTUIManager.h>
|
|
12
|
+
#import <React/RCTViewManager.h>
|
|
13
|
+
|
|
14
|
+
@interface RNMapsGoogleMapViewManager : RCTViewManager
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
@implementation RNMapsGoogleMapViewManager
|
|
18
|
+
|
|
19
|
+
RCT_EXPORT_MODULE(RNMapsGoogleMapViewManager)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
#endif
|
package/ios/AirMaps/AIRMap.h
CHANGED
|
@@ -42,8 +42,8 @@ extern const NSInteger AIRMapMaxZoomLevel;
|
|
|
42
42
|
@property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
|
|
43
43
|
@property (nonatomic, assign) MKCoordinateRegion initialRegion;
|
|
44
44
|
@property (nonatomic, assign) MKMapCamera *initialCamera;
|
|
45
|
-
@property (nonatomic, assign) CGFloat
|
|
46
|
-
@property (nonatomic, assign) CGFloat
|
|
45
|
+
@property (nonatomic, assign) CGFloat minZoom;
|
|
46
|
+
@property (nonatomic, assign) CGFloat maxZoom;
|
|
47
47
|
@property (nonatomic, assign) CGPoint compassOffset;
|
|
48
48
|
@property (nonatomic, assign) UIEdgeInsets mapPadding;
|
|
49
49
|
|
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -85,8 +85,8 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
85
85
|
self.calloutView = [SMCalloutView platformCalloutView];
|
|
86
86
|
self.calloutView.delegate = self;
|
|
87
87
|
|
|
88
|
-
self.
|
|
89
|
-
self.
|
|
88
|
+
self.minZoom = 0;
|
|
89
|
+
self.maxZoom = AIRMapMaxZoomLevel;
|
|
90
90
|
self.compassOffset = CGPointMake(0, 0);
|
|
91
91
|
self.legacyZoomConstraintsEnabled = YES;
|
|
92
92
|
}
|
|
@@ -1175,11 +1175,11 @@ static int kDragCenterContext;
|
|
|
1175
1175
|
|
|
1176
1176
|
CGFloat zoomLevel = [mapView getZoomLevel];
|
|
1177
1177
|
|
|
1178
|
-
if (zoomLevel < mapView.
|
|
1179
|
-
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.
|
|
1178
|
+
if (zoomLevel < mapView.minZoom) {
|
|
1179
|
+
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.minZoom animated:TRUE mapView:mapView];
|
|
1180
1180
|
}
|
|
1181
|
-
else if (zoomLevel > mapView.
|
|
1182
|
-
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.
|
|
1181
|
+
else if (zoomLevel > mapView.maxZoom) {
|
|
1182
|
+
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.maxZoom animated:TRUE mapView:mapView];
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// Created by Salah Ghanim on 23.11.24.
|
|
6
6
|
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
7
|
//
|
|
8
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
8
9
|
|
|
9
10
|
#import <React/RCTViewComponentView.h>
|
|
10
11
|
#import <UIKit/UIKit.h>
|
|
@@ -19,3 +20,5 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
19
20
|
@end
|
|
20
21
|
|
|
21
22
|
NS_ASSUME_NONNULL_END
|
|
23
|
+
|
|
24
|
+
#endif
|
|
@@ -255,28 +255,6 @@ using namespace facebook::react;
|
|
|
255
255
|
.width = [positionDict[@"width"] doubleValue],
|
|
256
256
|
.height = [positionDict[@"height"] doubleValue],
|
|
257
257
|
};
|
|
258
|
-
/*
|
|
259
|
-
std::string action;
|
|
260
|
-
OnCalloutPressFrame frame;
|
|
261
|
-
std::string id;
|
|
262
|
-
OnCalloutPressPoint point;
|
|
263
|
-
OnCalloutPressCoordinate coordinate;
|
|
264
|
-
OnCalloutPressPosition position;
|
|
265
|
-
id event = @{
|
|
266
|
-
@"action": calloutSubview ? @"callout-inside-press" : @"callout-press",
|
|
267
|
-
@"id": marker.identifier ?: @"unknown",
|
|
268
|
-
@"point": @{
|
|
269
|
-
@"x": @(touchPointReal.x),
|
|
270
|
-
@"y": @(touchPointReal.y),
|
|
271
|
-
},
|
|
272
|
-
@"frame": @{
|
|
273
|
-
@"x": @(bubbleFrame.origin.x),
|
|
274
|
-
@"y": @(bubbleFrame.origin.y),
|
|
275
|
-
@"width": @(bubbleFrame.size.width),
|
|
276
|
-
@"height": @(bubbleFrame.size.height),
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
*/
|
|
280
258
|
|
|
281
259
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
282
260
|
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
|
|
@@ -482,9 +460,9 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
482
460
|
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
483
461
|
|
|
484
462
|
REMAP_MAPVIEW_PROP(maxDelta)
|
|
485
|
-
REMAP_MAPVIEW_PROP(
|
|
463
|
+
REMAP_MAPVIEW_PROP(maxZoom)
|
|
486
464
|
REMAP_MAPVIEW_PROP(minDelta)
|
|
487
|
-
REMAP_MAPVIEW_PROP(
|
|
465
|
+
REMAP_MAPVIEW_PROP(minZoom)
|
|
488
466
|
|
|
489
467
|
REMAP_MAPVIEW_PROP(showsCompass)
|
|
490
468
|
REMAP_MAPVIEW_PROP(showsScale)
|
|
@@ -508,7 +486,6 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
508
486
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
509
487
|
REMAP_MAPVIEW_COLOR_PROP(tintColor)
|
|
510
488
|
|
|
511
|
-
// userLocationAnnotationTitle
|
|
512
489
|
REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
|
|
513
490
|
|
|
514
491
|
if (oldViewProps.mapType != newViewProps.mapType){
|