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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsMarker.h
|
|
3
|
+
// AirMaps
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
9
|
+
|
|
10
|
+
#import <React/RCTViewComponentView.h>
|
|
11
|
+
#import <UIKit/UIKit.h>
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
14
|
+
|
|
15
|
+
typedef void (^LoadCompletionHandler)(UIView *view);
|
|
16
|
+
|
|
17
|
+
@class AIRMapMarker;
|
|
18
|
+
@interface RNMapsMarkerView : RCTViewComponentView
|
|
19
|
+
- (AIRMapMarker*) marker;
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
NS_ASSUME_NONNULL_END
|
|
23
|
+
|
|
24
|
+
#endif
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsMarker.m
|
|
3
|
+
// AirMaps
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "RNMapsMarkerView.h"
|
|
10
|
+
#import "AirMap.h"
|
|
11
|
+
#import "AIRMapMarker.h"
|
|
12
|
+
#import "AIRMapMarkerManager.h"
|
|
13
|
+
#import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
|
|
14
|
+
#import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
|
|
15
|
+
#import <react/renderer/components/RNMapsSpecs/Props.h>
|
|
16
|
+
#import <react/renderer/components/RNMapsSpecs/RCTComponentViewHelpers.h>
|
|
17
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
18
|
+
#import <React/RCTConversions.h>
|
|
19
|
+
#import "UIView+AirMap.h"
|
|
20
|
+
|
|
21
|
+
using namespace facebook::react;
|
|
22
|
+
|
|
23
|
+
@interface RNMapsMarkerView () <RCTRNMapsMarkerViewProtocol>
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
@implementation RNMapsMarkerView {
|
|
27
|
+
AIRMapMarker *_view;
|
|
28
|
+
AIRMapMarkerManager* _legacyMapManager;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (AIRMapMarker *) marker {
|
|
32
|
+
return _view;
|
|
33
|
+
}
|
|
34
|
+
- (void) prepareForRecycle
|
|
35
|
+
{
|
|
36
|
+
[super prepareForRecycle];
|
|
37
|
+
[_view removeFromSuperview];
|
|
38
|
+
_view = nil;
|
|
39
|
+
_legacyMapManager = nil;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#pragma mark - JS Commands
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
#pragma mark - Native commands
|
|
46
|
+
|
|
47
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
48
|
+
{
|
|
49
|
+
RCTRNMapsMarkerHandleCommand(self, commandName, args);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
54
|
+
{
|
|
55
|
+
return concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void) animateToCoordinates:(double)latitude longitude:(double)longitude duration:(NSInteger)duration
|
|
59
|
+
{
|
|
60
|
+
[_view animateToCoordinate:CLLocationCoordinate2DMake(latitude, longitude) duration:duration/1000];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void) showCallout
|
|
64
|
+
{
|
|
65
|
+
[_view.map selectAnnotation:_view animated:YES];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void) hideCallout
|
|
69
|
+
{
|
|
70
|
+
[_view.map deselectAnnotation:_view animated:YES];
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (void) setCoordinates:(double)latitude longitude:(double)longitude
|
|
75
|
+
{
|
|
76
|
+
[_view setCoordinate:CLLocationCoordinate2DMake(latitude, longitude)];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
- (void) prepareMarkerView
|
|
82
|
+
{
|
|
83
|
+
if (_legacyMapManager && _view) return;
|
|
84
|
+
static const auto defaultProps = std::make_shared<const RNMapsMarkerProps>();
|
|
85
|
+
_props = defaultProps;
|
|
86
|
+
_legacyMapManager = [[AIRMapMarkerManager alloc] init];
|
|
87
|
+
_view = (AIRMapMarker *)[_legacyMapManager view];
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
_view.onPress = [self](NSDictionary* dictionary) {
|
|
91
|
+
if (_eventEmitter) {
|
|
92
|
+
// Extract values from the NSDictionary
|
|
93
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
94
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
95
|
+
|
|
96
|
+
// Populate the OnCalloutPressPoint struct
|
|
97
|
+
facebook::react::RNMapsMarkerEventEmitter::OnPressPosition point = {
|
|
98
|
+
.x = [coordinateDict[@"x"] doubleValue],
|
|
99
|
+
.y = [coordinateDict[@"y"] doubleValue],
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
facebook::react::RNMapsMarkerEventEmitter::OnPressCoordinate coordinate = {
|
|
104
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
105
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
109
|
+
facebook::react::RNMapsMarkerEventEmitter::OnPress data = {
|
|
110
|
+
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
111
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
112
|
+
.position = point,
|
|
113
|
+
.coordinate = coordinate,
|
|
114
|
+
};
|
|
115
|
+
eventEmitter->onPress(data);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
_view.onDeselect = [self](NSDictionary* dictionary) {
|
|
120
|
+
if (_eventEmitter) {
|
|
121
|
+
// Extract values from the NSDictionary
|
|
122
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
123
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
124
|
+
|
|
125
|
+
// Populate the OnCalloutPressPoint struct
|
|
126
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDeselectPosition point = {
|
|
127
|
+
.x = [coordinateDict[@"x"] doubleValue],
|
|
128
|
+
.y = [coordinateDict[@"y"] doubleValue],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDeselectCoordinate coordinate = {
|
|
133
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
134
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
138
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDeselect data = {
|
|
139
|
+
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
140
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
141
|
+
.position = point,
|
|
142
|
+
.coordinate = coordinate,
|
|
143
|
+
};
|
|
144
|
+
eventEmitter->onDeselect(data);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
_view.onDrag = [self](NSDictionary* dictionary) {
|
|
149
|
+
if (_eventEmitter) {
|
|
150
|
+
// Extract values from the NSDictionary
|
|
151
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDragCoordinate coordinate = {
|
|
155
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
156
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
160
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDrag data = {
|
|
161
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
162
|
+
.coordinate = coordinate,
|
|
163
|
+
};
|
|
164
|
+
eventEmitter->onDrag(data);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
_view.onDragStart = [self](NSDictionary* dictionary) {
|
|
168
|
+
if (_eventEmitter) {
|
|
169
|
+
// Extract values from the NSDictionary
|
|
170
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
171
|
+
|
|
172
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDragStartCoordinate coordinate = {
|
|
173
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
174
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
178
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDragStart data = {
|
|
179
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
180
|
+
.coordinate = coordinate,
|
|
181
|
+
};
|
|
182
|
+
eventEmitter->onDragStart(data);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
_view.onDragEnd = [self](NSDictionary* dictionary) {
|
|
187
|
+
if (_eventEmitter) {
|
|
188
|
+
// Extract values from the NSDictionary
|
|
189
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDragEndCoordinate coordinate = {
|
|
193
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
194
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
198
|
+
facebook::react::RNMapsMarkerEventEmitter::OnDragEnd data = {
|
|
199
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
200
|
+
.coordinate = coordinate,
|
|
201
|
+
};
|
|
202
|
+
eventEmitter->onDragEnd(data);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
_view.onSelect = [self](NSDictionary* dictionary) {
|
|
207
|
+
if (_eventEmitter) {
|
|
208
|
+
// Extract values from the NSDictionary
|
|
209
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
210
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
211
|
+
|
|
212
|
+
// Populate the OnCalloutPressPoint struct
|
|
213
|
+
facebook::react::RNMapsMarkerEventEmitter::OnSelectPosition point = {
|
|
214
|
+
.x = [coordinateDict[@"x"] doubleValue],
|
|
215
|
+
.y = [coordinateDict[@"y"] doubleValue],
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
facebook::react::RNMapsMarkerEventEmitter::OnSelectCoordinate coordinate = {
|
|
220
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
221
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
225
|
+
facebook::react::RNMapsMarkerEventEmitter::OnSelect data = {
|
|
226
|
+
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
227
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
228
|
+
.position = point,
|
|
229
|
+
.coordinate = coordinate,
|
|
230
|
+
};
|
|
231
|
+
eventEmitter->onSelect(data);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
_view.onCalloutPress = [self](NSDictionary* dictionary) {
|
|
237
|
+
if (_eventEmitter) {
|
|
238
|
+
// Extract values from the NSDictionary
|
|
239
|
+
NSDictionary* pointDict = dictionary[@"point"];
|
|
240
|
+
NSDictionary* frameDict = dictionary[@"frame"];
|
|
241
|
+
|
|
242
|
+
// Populate the OnCalloutPressPoint struct
|
|
243
|
+
facebook::react::RNMapsMarkerEventEmitter::OnCalloutPressPoint point = {
|
|
244
|
+
.x = [pointDict[@"x"] doubleValue],
|
|
245
|
+
.y = [pointDict[@"y"] doubleValue],
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
facebook::react::RNMapsMarkerEventEmitter::OnCalloutPressFrame frame = {
|
|
250
|
+
.x = [frameDict[@"x"] doubleValue],
|
|
251
|
+
.y = [frameDict[@"x"] doubleValue],
|
|
252
|
+
.width = [frameDict[@"width"] doubleValue],
|
|
253
|
+
.height = [frameDict[@"height"] doubleValue],
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
|
|
257
|
+
facebook::react::RNMapsMarkerEventEmitter::OnCalloutPress data = {
|
|
258
|
+
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
259
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
260
|
+
.frame = frame,
|
|
261
|
+
.point = point,
|
|
262
|
+
};
|
|
263
|
+
eventEmitter->onCalloutPress(data);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
|
|
270
|
+
if (!_view){
|
|
271
|
+
[self prepareMarkerView];
|
|
272
|
+
}
|
|
273
|
+
id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
|
|
274
|
+
if (paperView){
|
|
275
|
+
[_view insertReactSubview:paperView atIndex:index];
|
|
276
|
+
} else {
|
|
277
|
+
[_view insertReactSubview:childComponentView atIndex:index];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
- (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
282
|
+
{
|
|
283
|
+
id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
|
|
284
|
+
if (paperView){
|
|
285
|
+
[_view removeReactSubview:paperView];
|
|
286
|
+
} else {
|
|
287
|
+
[_view removeReactSubview:childComponentView];
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
291
|
+
{
|
|
292
|
+
if (self = [super initWithFrame:frame]) {
|
|
293
|
+
[self prepareMarkerView];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return self;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
300
|
+
{
|
|
301
|
+
[self prepareMarkerView];
|
|
302
|
+
const auto &oldViewProps = *std::static_pointer_cast<RNMapsMarkerProps const>(_props);
|
|
303
|
+
const auto &newViewProps = *std::static_pointer_cast<RNMapsMarkerProps const>(props);
|
|
304
|
+
BOOL completionHandlerCalled = false;
|
|
305
|
+
|
|
306
|
+
#define REMAP_MAPVIEW_PROP(name) \
|
|
307
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
308
|
+
_view.name = newViewProps.name; \
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#define REMAP_MAPVIEW_STRING_PROP(name) \
|
|
312
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
313
|
+
_view.name = RCTNSStringFromString(newViewProps.name); \
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
#define REMAP_MAPVIEW_COLOR_PROP(name) \
|
|
317
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
318
|
+
_view.name = RCTUIColorFromSharedColor(newViewProps.name); \
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
#define REMAP_MAPVIEW_POINT_PROP(name) \
|
|
322
|
+
if (newViewProps.name.x != oldViewProps.name.x || \
|
|
323
|
+
newViewProps.name.y != oldViewProps.name.y) { \
|
|
324
|
+
_view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (newViewProps.zIndex != oldViewProps.zIndex){
|
|
328
|
+
if (newViewProps.zIndex.has_value()){
|
|
329
|
+
_view.zIndex = newViewProps.zIndex.value();
|
|
330
|
+
} else {
|
|
331
|
+
// default
|
|
332
|
+
_view.zIndex = 0;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (newViewProps.image != oldViewProps.image){
|
|
336
|
+
if (newViewProps.image.uri.size()){
|
|
337
|
+
[_view setImageSrc:RCTNSStringFromString(newViewProps.image.uri)];
|
|
338
|
+
completionHandlerCalled = true;
|
|
339
|
+
} else {
|
|
340
|
+
[_view setImageSrc:nil];
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
REMAP_MAPVIEW_PROP(useLegacyPinView)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
REMAP_MAPVIEW_PROP(opacity)
|
|
348
|
+
REMAP_MAPVIEW_PROP(draggable)
|
|
349
|
+
REMAP_MAPVIEW_PROP(isPreselected)
|
|
350
|
+
|
|
351
|
+
REMAP_MAPVIEW_COLOR_PROP(pinColor)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
REMAP_MAPVIEW_POINT_PROP(calloutOffset)
|
|
355
|
+
if (newViewProps.coordinate.latitude != oldViewProps.coordinate.latitude ||
|
|
356
|
+
newViewProps.coordinate.longitude != oldViewProps.coordinate.longitude) {
|
|
357
|
+
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
|
|
358
|
+
newViewProps.coordinate.latitude,
|
|
359
|
+
newViewProps.coordinate.longitude);
|
|
360
|
+
_view.coordinate = coordinates;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
if (newViewProps.description != oldViewProps.description){
|
|
365
|
+
_view.subtitle = RCTNSStringFromString(newViewProps.description);
|
|
366
|
+
}
|
|
367
|
+
REMAP_MAPVIEW_STRING_PROP(title)
|
|
368
|
+
REMAP_MAPVIEW_STRING_PROP(identifier)
|
|
369
|
+
if (newViewProps.titleVisibility != oldViewProps.titleVisibility){
|
|
370
|
+
switch (newViewProps.titleVisibility) {
|
|
371
|
+
case RNMapsMarkerTitleVisibility::Visible:
|
|
372
|
+
[_view setTitleVisibility:MKFeatureVisibilityVisible];
|
|
373
|
+
break;
|
|
374
|
+
case RNMapsMarkerTitleVisibility::Adaptive:
|
|
375
|
+
[_view setTitleVisibility:MKFeatureVisibilityAdaptive];
|
|
376
|
+
break;
|
|
377
|
+
case RNMapsMarkerTitleVisibility::Hidden:
|
|
378
|
+
[_view setTitleVisibility:MKFeatureVisibilityHidden];
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (newViewProps.subtitleVisibility != oldViewProps.subtitleVisibility){
|
|
383
|
+
switch (newViewProps.subtitleVisibility) {
|
|
384
|
+
case RNMapsMarkerSubtitleVisibility::Visible:
|
|
385
|
+
[_view setSubtitleVisibility:MKFeatureVisibilityVisible];
|
|
386
|
+
break;
|
|
387
|
+
case RNMapsMarkerSubtitleVisibility::Adaptive:
|
|
388
|
+
[_view setSubtitleVisibility:MKFeatureVisibilityAdaptive];
|
|
389
|
+
break;
|
|
390
|
+
case RNMapsMarkerSubtitleVisibility::Hidden:
|
|
391
|
+
[_view setSubtitleVisibility:MKFeatureVisibilityHidden];
|
|
392
|
+
break;
|
|
393
|
+
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (newViewProps.displayPriority != oldViewProps.displayPriority){
|
|
398
|
+
switch (newViewProps.displayPriority) {
|
|
399
|
+
case RNMapsMarkerDisplayPriority::Required:
|
|
400
|
+
[_view setDisplayPriority:MKFeatureDisplayPriorityRequired];
|
|
401
|
+
break;
|
|
402
|
+
case RNMapsMarkerDisplayPriority::High:
|
|
403
|
+
[_view setDisplayPriority:MKFeatureDisplayPriorityDefaultHigh];
|
|
404
|
+
break;
|
|
405
|
+
case RNMapsMarkerDisplayPriority::Low:
|
|
406
|
+
[_view setDisplayPriority:MKFeatureDisplayPriorityDefaultLow];
|
|
407
|
+
break;
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
[super updateProps:props oldProps:oldProps];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
@end
|
|
418
|
+
|
|
419
|
+
Class<RCTComponentViewProtocol> RNMapsMarkerCls(void)
|
|
420
|
+
{
|
|
421
|
+
return RNMapsMarkerView.class;
|
|
422
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsMarkerManager.m
|
|
3
|
+
// AirMaps
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <React/RCTLog.h>
|
|
10
|
+
#import <React/RCTUIManager.h>
|
|
11
|
+
#import <React/RCTViewManager.h>
|
|
12
|
+
|
|
13
|
+
@interface RNMapsMarkerViewManager : RCTViewManager
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation RNMapsMarkerViewManager
|
|
17
|
+
|
|
18
|
+
RCT_EXPORT_MODULE(RNMapsMarkerViewManager)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Leland Richardson on 12/27/15.
|
|
3
|
+
// Copyright (c) 2015 Facebook. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#import "UIView+AirMap.h"
|
|
7
|
+
|
|
8
|
+
@implementation UIView (AirMap)
|
|
9
|
+
|
|
10
|
+
- (UIView *) getPaperViewFromChildComponentView {
|
|
11
|
+
// Check if the childComponentView responds to the "adapter" selector
|
|
12
|
+
if ([self respondsToSelector:@selector(paperView)]) {
|
|
13
|
+
// Safely return the paperView
|
|
14
|
+
return [self valueForKey:@"paperView"];
|
|
15
|
+
}
|
|
16
|
+
// Return nil if paperView is not accessible
|
|
17
|
+
return nil;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@end
|
package/lib/MapMarker.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Animated, ViewProps, ImageURISource, ImageRequireSource } from 'react-native';
|
|
3
3
|
import { MapManagerCommand, NativeComponent, ProviderContext, UIManagerCommand } from './decorateMapComponent';
|
|
4
4
|
import { MapMarkerNativeComponentType } from './MapMarkerNativeComponent';
|
|
5
|
+
import type { AppleMarkerPriority } from './specs/NativeComponentMarker';
|
|
5
6
|
import { CalloutPressEvent, LatLng, MarkerDeselectEvent, MarkerDragEvent, MarkerDragStartEndEvent, MarkerPressEvent, MarkerSelectEvent, Point } from './sharedTypes';
|
|
6
7
|
import { Modify } from './sharedTypesInternal';
|
|
7
8
|
type AppleMarkerVisibility = 'hidden' | 'adaptive' | 'visible';
|
|
@@ -42,7 +43,7 @@ export type MapMarkerProps = ViewProps & {
|
|
|
42
43
|
*
|
|
43
44
|
* @default {x: 0.0, y: 0.0}
|
|
44
45
|
* @platform iOS: Apple Maps only. For Google Maps, see the `calloutAnchor` prop
|
|
45
|
-
* @platform Android: Not supported.
|
|
46
|
+
* @platform Android: Not supported. see the `calloutAnchor` prop
|
|
46
47
|
*/
|
|
47
48
|
calloutOffset?: Point;
|
|
48
49
|
/**
|
|
@@ -54,7 +55,7 @@ export type MapMarkerProps = ViewProps & {
|
|
|
54
55
|
*
|
|
55
56
|
* @default {x: 0.0, y: 0.0}
|
|
56
57
|
* @platform iOS: Apple Maps only. For Google Maps, see the `anchor` prop
|
|
57
|
-
* @platform Android: Not supported.
|
|
58
|
+
* @platform Android: Not supported. see the `anchor` prop
|
|
58
59
|
*/
|
|
59
60
|
centerOffset?: Point;
|
|
60
61
|
/**
|
|
@@ -261,6 +262,17 @@ export type MapMarkerProps = ViewProps & {
|
|
|
261
262
|
* @platform Android: Supported
|
|
262
263
|
*/
|
|
263
264
|
zIndex?: number;
|
|
265
|
+
/**
|
|
266
|
+
Constants that indicates the display priority for annotations.
|
|
267
|
+
@default required
|
|
268
|
+
@platform iOS: Apple Maps only.
|
|
269
|
+
@platform Android: Not supported
|
|
270
|
+
|
|
271
|
+
Required: A constant indicating that the item is required.
|
|
272
|
+
High: A constant indicating that the item’s display priority is high.
|
|
273
|
+
Low: A constant indicating that the item’s display priority is Low.
|
|
274
|
+
*/
|
|
275
|
+
displayPriority?: AppleMarkerPriority;
|
|
264
276
|
/**
|
|
265
277
|
* Visibility of the title text rendered beneath Marker balloon
|
|
266
278
|
* @platform iOS: Apple Maps only
|
|
@@ -295,6 +307,7 @@ export declare class MapMarker extends React.Component<MapMarkerProps> {
|
|
|
295
307
|
getUIManagerCommand: (name: string) => UIManagerCommand;
|
|
296
308
|
static Animated: Animated.AnimatedComponent<typeof MapMarker>;
|
|
297
309
|
private marker;
|
|
310
|
+
private fabricMarker?;
|
|
298
311
|
constructor(props: MapMarkerProps);
|
|
299
312
|
setNativeProps(props: Partial<NativeProps>): void;
|
|
300
313
|
showCallout(): void;
|
package/lib/MapMarker.js
CHANGED
|
@@ -28,12 +28,15 @@ const React = __importStar(require("react"));
|
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
|
|
30
30
|
const MapMarkerNativeComponent_1 = require("./MapMarkerNativeComponent");
|
|
31
|
+
const NativeComponentMarker_1 = require("./specs/NativeComponentMarker");
|
|
32
|
+
const ProviderConstants_1 = require("./ProviderConstants");
|
|
31
33
|
class MapMarker extends React.Component {
|
|
32
34
|
getNativeComponent;
|
|
33
35
|
getMapManagerCommand;
|
|
34
36
|
getUIManagerCommand;
|
|
35
37
|
static Animated;
|
|
36
38
|
marker;
|
|
39
|
+
fabricMarker = undefined;
|
|
37
40
|
constructor(props) {
|
|
38
41
|
super(props);
|
|
39
42
|
this.marker = React.createRef();
|
|
@@ -49,27 +52,59 @@ class MapMarker extends React.Component {
|
|
|
49
52
|
}
|
|
50
53
|
showCallout() {
|
|
51
54
|
if (this.marker.current) {
|
|
52
|
-
|
|
55
|
+
if (this.fabricMarker) {
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
NativeComponentMarker_1.Commands.showCallout(this.marker.current);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
MapMarkerNativeComponent_1.Commands.showCallout(this.marker.current);
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
hideCallout() {
|
|
56
65
|
if (this.marker.current) {
|
|
57
|
-
|
|
66
|
+
if (this.fabricMarker) {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
NativeComponentMarker_1.Commands.hideCallout(this.marker.current);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
MapMarkerNativeComponent_1.Commands.hideCallout(this.marker.current);
|
|
72
|
+
}
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
75
|
setCoordinates(coordinate) {
|
|
61
76
|
if (this.marker.current) {
|
|
62
|
-
|
|
77
|
+
if (this.fabricMarker) {
|
|
78
|
+
NativeComponentMarker_1.Commands.setCoordinates(
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
this.marker.current, coordinate.latitude, coordinate.longitude);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
MapMarkerNativeComponent_1.Commands.setCoordinates(this.marker.current, coordinate);
|
|
84
|
+
}
|
|
63
85
|
}
|
|
64
86
|
}
|
|
65
87
|
redrawCallout() {
|
|
66
88
|
if (this.marker.current) {
|
|
67
|
-
|
|
89
|
+
if (this.fabricMarker) {
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
NativeComponentMarker_1.Commands.redrawCallout(this.marker.current);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
MapMarkerNativeComponent_1.Commands.redrawCallout(this.marker.current);
|
|
95
|
+
}
|
|
68
96
|
}
|
|
69
97
|
}
|
|
70
98
|
animateMarkerToCoordinate(coordinate, duration = 500) {
|
|
71
99
|
if (this.marker.current) {
|
|
72
|
-
|
|
100
|
+
if (this.fabricMarker) {
|
|
101
|
+
NativeComponentMarker_1.Commands.animateToCoordinates(
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
this.marker.current, coordinate.latitude, coordinate.longitude, duration);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
MapMarkerNativeComponent_1.Commands.animateMarkerToCoordinate(this.marker.current, coordinate, duration);
|
|
107
|
+
}
|
|
73
108
|
}
|
|
74
109
|
}
|
|
75
110
|
redraw() {
|
|
@@ -79,10 +114,9 @@ class MapMarker extends React.Component {
|
|
|
79
114
|
}
|
|
80
115
|
render() {
|
|
81
116
|
const { stopPropagation = false } = this.props;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
image = image.uri || this.props.image;
|
|
117
|
+
if (this.fabricMarker === undefined) {
|
|
118
|
+
const provider = this.context;
|
|
119
|
+
this.fabricMarker = provider !== ProviderConstants_1.PROVIDER_GOOGLE && react_native_1.Platform.OS === 'ios';
|
|
86
120
|
}
|
|
87
121
|
let icon;
|
|
88
122
|
if (this.props.icon) {
|
|
@@ -90,6 +124,16 @@ class MapMarker extends React.Component {
|
|
|
90
124
|
icon = icon.uri;
|
|
91
125
|
}
|
|
92
126
|
const AIRMapMarker = this.getNativeComponent();
|
|
127
|
+
let image;
|
|
128
|
+
if (this.props.image) {
|
|
129
|
+
if (this.fabricMarker) {
|
|
130
|
+
image = this.props.image;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
image = react_native_1.Image.resolveAssetSource(this.props.image) || {};
|
|
134
|
+
image = image.uri || this.props.image;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
93
137
|
return (<AIRMapMarker {...this.props} ref={this.marker} image={image} icon={icon} style={[styles.marker, this.props.style]} onPress={event => {
|
|
94
138
|
if (stopPropagation) {
|
|
95
139
|
event.stopPropagation();
|