@lugg/maps 1.0.0-beta.4 → 1.0.0-beta.5
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/luggmaps/LuggCalloutView.kt +4 -2
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +4 -3
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +40 -0
- package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +31 -0
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +23 -0
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +166 -21
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +5 -0
- package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +11 -0
- package/ios/LuggCalloutView.h +1 -1
- package/ios/LuggCalloutView.mm +21 -11
- package/ios/LuggMapView.mm +41 -2
- package/ios/LuggMarkerView.h +3 -0
- package/ios/LuggMarkerView.mm +23 -0
- package/ios/core/AppleMapProvider.mm +197 -16
- package/ios/core/GoogleMapProvider.mm +91 -18
- package/ios/core/MapProviderDelegate.h +8 -1
- package/lib/module/MapView.js +11 -0
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +3 -0
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Marker.js +17 -3
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +20 -7
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/lib/module/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +36 -1
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.d.ts +6 -3
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +14 -5
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +3 -2
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +1 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts +6 -1
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +8 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +0 -4
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapView.tsx +11 -0
- package/src/MapView.types.ts +85 -1
- package/src/MapView.web.tsx +11 -0
- package/src/components/Marker.tsx +28 -5
- package/src/components/Marker.types.ts +15 -5
- package/src/components/Marker.web.tsx +191 -148
- package/src/components/index.ts +1 -0
- package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/src/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/src/index.ts +6 -1
- package/src/index.web.ts +3 -0
- package/src/types.ts +0 -5
package/ios/LuggCalloutView.mm
CHANGED
|
@@ -43,7 +43,7 @@ using namespace facebook::react;
|
|
|
43
43
|
@implementation LuggCalloutView {
|
|
44
44
|
LuggCalloutContentView *_contentView;
|
|
45
45
|
BOOL _bubbled;
|
|
46
|
-
CGPoint
|
|
46
|
+
CGPoint _offset;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
@@ -58,7 +58,7 @@ using namespace facebook::react;
|
|
|
58
58
|
_props = defaultProps;
|
|
59
59
|
|
|
60
60
|
_bubbled = YES;
|
|
61
|
-
|
|
61
|
+
_offset = CGPointZero;
|
|
62
62
|
_contentView = [[LuggCalloutContentView alloc] init];
|
|
63
63
|
_contentView.backgroundColor = [UIColor clearColor];
|
|
64
64
|
|
|
@@ -74,29 +74,39 @@ using namespace facebook::react;
|
|
|
74
74
|
const auto &newViewProps =
|
|
75
75
|
*std::static_pointer_cast<LuggCalloutViewProps const>(props);
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
BOOL changed = NO;
|
|
78
|
+
|
|
79
|
+
if (_bubbled != newViewProps.bubbled) {
|
|
80
|
+
_bubbled = newViewProps.bubbled;
|
|
81
|
+
changed = YES;
|
|
82
|
+
}
|
|
78
83
|
|
|
79
84
|
if (oldProps) {
|
|
80
85
|
const auto &oldViewProps =
|
|
81
86
|
*std::static_pointer_cast<LuggCalloutViewProps const>(oldProps);
|
|
82
|
-
if (newViewProps.
|
|
83
|
-
newViewProps.
|
|
84
|
-
|
|
87
|
+
if (newViewProps.offset.x != oldViewProps.offset.x ||
|
|
88
|
+
newViewProps.offset.y != oldViewProps.offset.y) {
|
|
89
|
+
_offset = CGPointMake(newViewProps.offset.x, newViewProps.offset.y);
|
|
90
|
+
changed = YES;
|
|
85
91
|
}
|
|
86
|
-
} else if (newViewProps.
|
|
87
|
-
|
|
92
|
+
} else if (newViewProps.offset.x != 0 || newViewProps.offset.y != 0) {
|
|
93
|
+
_offset = CGPointMake(newViewProps.offset.x, newViewProps.offset.y);
|
|
94
|
+
changed = YES;
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
[super updateProps:props oldProps:oldProps];
|
|
91
|
-
|
|
98
|
+
|
|
99
|
+
if (changed) {
|
|
100
|
+
[_delegate calloutViewDidUpdate:self];
|
|
101
|
+
}
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
- (BOOL)bubbled {
|
|
95
105
|
return _bubbled;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
- (CGPoint)
|
|
99
|
-
return
|
|
108
|
+
- (CGPoint)offset {
|
|
109
|
+
return _offset;
|
|
100
110
|
}
|
|
101
111
|
|
|
102
112
|
- (void)mountChildComponentView:
|
package/ios/LuggMapView.mm
CHANGED
|
@@ -40,11 +40,16 @@ using namespace luggmaps::events;
|
|
|
40
40
|
BOOL _rotateEnabled;
|
|
41
41
|
BOOL _pitchEnabled;
|
|
42
42
|
BOOL _userLocationEnabled;
|
|
43
|
+
LuggMapViewMapType _mapType;
|
|
43
44
|
LuggMapViewTheme _theme;
|
|
45
|
+
BOOL _poiEnabled;
|
|
46
|
+
LuggMapViewPoiFilterMode _poiFilterMode;
|
|
47
|
+
NSArray<NSString *> *_poiFilterCategories;
|
|
44
48
|
double _minZoom;
|
|
45
49
|
double _maxZoom;
|
|
46
50
|
UIEdgeInsets _edgeInsets;
|
|
47
51
|
UIEdgeInsets _oldEdgeInsets;
|
|
52
|
+
LuggMapViewInsetAdjustment _insetAdjustment;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
@@ -64,8 +69,13 @@ using namespace luggmaps::events;
|
|
|
64
69
|
_rotateEnabled = YES;
|
|
65
70
|
_pitchEnabled = YES;
|
|
66
71
|
_userLocationEnabled = NO;
|
|
72
|
+
_poiEnabled = NO;
|
|
73
|
+
_poiFilterMode = LuggMapViewPoiFilterMode::Including;
|
|
74
|
+
_poiFilterCategories = @[];
|
|
75
|
+
_mapType = LuggMapViewMapType::Standard;
|
|
67
76
|
_theme = LuggMapViewTheme::System;
|
|
68
77
|
_edgeInsets = UIEdgeInsetsZero;
|
|
78
|
+
_insetAdjustment = LuggMapViewInsetAdjustment::Never;
|
|
69
79
|
}
|
|
70
80
|
return self;
|
|
71
81
|
}
|
|
@@ -272,9 +282,14 @@ using namespace luggmaps::events;
|
|
|
272
282
|
[_provider setRotateEnabled:_rotateEnabled];
|
|
273
283
|
[_provider setPitchEnabled:_pitchEnabled];
|
|
274
284
|
[_provider setUserLocationEnabled:_userLocationEnabled];
|
|
275
|
-
[_provider
|
|
285
|
+
[_provider setMapType:_mapType];
|
|
286
|
+
[_provider setTheme:_theme];
|
|
287
|
+
[_provider setPoiEnabled:_poiEnabled];
|
|
288
|
+
[_provider setPoiFilterMode:_poiFilterMode];
|
|
289
|
+
[_provider setPoiFilterCategories:_poiFilterCategories];
|
|
276
290
|
[_provider setMinZoom:_minZoom];
|
|
277
291
|
[_provider setMaxZoom:_maxZoom];
|
|
292
|
+
[_provider setInsetAdjustment:_insetAdjustment];
|
|
278
293
|
}
|
|
279
294
|
|
|
280
295
|
- (void)updateProps:(Props::Shared const &)props
|
|
@@ -312,6 +327,26 @@ using namespace luggmaps::events;
|
|
|
312
327
|
_userLocationEnabled = newViewProps.userLocationEnabled;
|
|
313
328
|
[_provider setUserLocationEnabled:_userLocationEnabled];
|
|
314
329
|
}
|
|
330
|
+
if (newViewProps.poiEnabled != prevViewProps.poiEnabled) {
|
|
331
|
+
_poiEnabled = newViewProps.poiEnabled;
|
|
332
|
+
[_provider setPoiEnabled:_poiEnabled];
|
|
333
|
+
}
|
|
334
|
+
if (newViewProps.poiFilterMode != prevViewProps.poiFilterMode) {
|
|
335
|
+
_poiFilterMode = newViewProps.poiFilterMode;
|
|
336
|
+
[_provider setPoiFilterMode:_poiFilterMode];
|
|
337
|
+
}
|
|
338
|
+
if (newViewProps.poiFilterCategories != prevViewProps.poiFilterCategories) {
|
|
339
|
+
NSMutableArray<NSString *> *categories = [NSMutableArray array];
|
|
340
|
+
for (const auto &category : newViewProps.poiFilterCategories) {
|
|
341
|
+
[categories addObject:[NSString stringWithUTF8String:category.c_str()]];
|
|
342
|
+
}
|
|
343
|
+
_poiFilterCategories = [categories copy];
|
|
344
|
+
[_provider setPoiFilterCategories:_poiFilterCategories];
|
|
345
|
+
}
|
|
346
|
+
if (newViewProps.mapType != prevViewProps.mapType) {
|
|
347
|
+
_mapType = newViewProps.mapType;
|
|
348
|
+
[_provider setMapType:_mapType];
|
|
349
|
+
}
|
|
315
350
|
if (newViewProps.minZoom != prevViewProps.minZoom) {
|
|
316
351
|
_minZoom = newViewProps.minZoom;
|
|
317
352
|
[_provider setMinZoom:_minZoom];
|
|
@@ -322,7 +357,11 @@ using namespace luggmaps::events;
|
|
|
322
357
|
}
|
|
323
358
|
if (newViewProps.theme != prevViewProps.theme) {
|
|
324
359
|
_theme = newViewProps.theme;
|
|
325
|
-
[_provider setTheme:
|
|
360
|
+
[_provider setTheme:_theme];
|
|
361
|
+
}
|
|
362
|
+
if (newViewProps.insetAdjustment != prevViewProps.insetAdjustment) {
|
|
363
|
+
_insetAdjustment = newViewProps.insetAdjustment;
|
|
364
|
+
[_provider setInsetAdjustment:_insetAdjustment];
|
|
326
365
|
}
|
|
327
366
|
|
|
328
367
|
UIEdgeInsets newEdgeInsets = UIEdgeInsetsMake(
|
package/ios/LuggMarkerView.h
CHANGED
|
@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
11
11
|
@optional
|
|
12
12
|
- (void)markerViewDidLayout:(LuggMarkerView *)markerView;
|
|
13
13
|
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView;
|
|
14
|
+
- (void)showCalloutForMarkerView:(LuggMarkerView *)markerView;
|
|
15
|
+
- (void)hideCalloutForMarkerView:(LuggMarkerView *)markerView;
|
|
14
16
|
@end
|
|
15
17
|
|
|
16
18
|
@interface LuggMarkerView : RCTViewComponentView
|
|
@@ -24,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
24
26
|
@property(nonatomic, readonly) CLLocationDegrees rotate;
|
|
25
27
|
@property(nonatomic, readonly) CGFloat scale;
|
|
26
28
|
@property(nonatomic, readonly) BOOL rasterize;
|
|
29
|
+
@property(nonatomic, readonly) BOOL centerOnPress;
|
|
27
30
|
@property(nonatomic, readonly) BOOL draggable;
|
|
28
31
|
@property(nonatomic, readonly) BOOL hasCustomView;
|
|
29
32
|
@property(nonatomic, readonly) BOOL didLayout;
|
package/ios/LuggMarkerView.mm
CHANGED
|
@@ -26,6 +26,7 @@ using namespace luggmaps::events;
|
|
|
26
26
|
CLLocationDegrees _rotate;
|
|
27
27
|
CGFloat _scale;
|
|
28
28
|
BOOL _rasterize;
|
|
29
|
+
BOOL _centerOnPress;
|
|
29
30
|
BOOL _draggable;
|
|
30
31
|
BOOL _didLayout;
|
|
31
32
|
UIView *_iconView;
|
|
@@ -49,6 +50,7 @@ using namespace luggmaps::events;
|
|
|
49
50
|
_rotate = 0;
|
|
50
51
|
_scale = 1;
|
|
51
52
|
_rasterize = YES;
|
|
53
|
+
_centerOnPress = YES;
|
|
52
54
|
_didLayout = NO;
|
|
53
55
|
|
|
54
56
|
_iconView = [[UIView alloc] init];
|
|
@@ -78,6 +80,7 @@ using namespace luggmaps::events;
|
|
|
78
80
|
_rotate = newViewProps.rotate;
|
|
79
81
|
_scale = newViewProps.scale;
|
|
80
82
|
_rasterize = newViewProps.rasterize;
|
|
83
|
+
_centerOnPress = newViewProps.centerOnPress;
|
|
81
84
|
_draggable = newViewProps.draggable;
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -174,6 +177,10 @@ using namespace luggmaps::events;
|
|
|
174
177
|
return _rasterize;
|
|
175
178
|
}
|
|
176
179
|
|
|
180
|
+
- (BOOL)centerOnPress {
|
|
181
|
+
return _centerOnPress;
|
|
182
|
+
}
|
|
183
|
+
|
|
177
184
|
- (BOOL)draggable {
|
|
178
185
|
return _draggable;
|
|
179
186
|
}
|
|
@@ -282,6 +289,22 @@ using namespace luggmaps::events;
|
|
|
282
289
|
_iconView.bounds.size.height);
|
|
283
290
|
}
|
|
284
291
|
|
|
292
|
+
- (void)showCallout {
|
|
293
|
+
if ([self.delegate respondsToSelector:@selector(showCalloutForMarkerView:)]) {
|
|
294
|
+
[self.delegate showCalloutForMarkerView:self];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
- (void)hideCallout {
|
|
299
|
+
if ([self.delegate respondsToSelector:@selector(hideCalloutForMarkerView:)]) {
|
|
300
|
+
[self.delegate hideCalloutForMarkerView:self];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
305
|
+
RCTLuggMarkerViewHandleCommand(self, commandName, args);
|
|
306
|
+
}
|
|
307
|
+
|
|
285
308
|
- (void)prepareForRecycle {
|
|
286
309
|
[super prepareForRecycle];
|
|
287
310
|
_didLayout = NO;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#import "AppleMapProvider.h"
|
|
2
|
+
|
|
3
|
+
using facebook::react::LuggMapViewInsetAdjustment;
|
|
4
|
+
using facebook::react::LuggMapViewMapType;
|
|
5
|
+
using facebook::react::LuggMapViewPoiFilterMode;
|
|
6
|
+
using facebook::react::LuggMapViewTheme;
|
|
7
|
+
|
|
2
8
|
#import "../LuggCalloutView.h"
|
|
3
9
|
#import "../LuggCircleView.h"
|
|
4
10
|
#import "../LuggGroundOverlayView.h"
|
|
@@ -125,12 +131,17 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
125
131
|
UILongPressGestureRecognizer *_longPressGesture;
|
|
126
132
|
LuggMarkerView *_activeNonBubbledMarker;
|
|
127
133
|
BOOL _isReselectingAnnotation;
|
|
134
|
+
BOOL _isProgrammaticSelect;
|
|
128
135
|
// Edge insets animation
|
|
129
136
|
CADisplayLink *_edgeInsetsDisplayLink;
|
|
130
137
|
UIEdgeInsets _edgeInsetsFrom;
|
|
131
138
|
UIEdgeInsets _edgeInsetsTo;
|
|
139
|
+
UIEdgeInsets _edgeInsetsCurrent;
|
|
132
140
|
CFTimeInterval _edgeInsetsAnimationStart;
|
|
133
141
|
CFTimeInterval _edgeInsetsAnimationDuration;
|
|
142
|
+
BOOL _poiEnabled;
|
|
143
|
+
LuggMapViewPoiFilterMode _poiFilterMode;
|
|
144
|
+
NSArray<NSString *> *_poiFilterCategories;
|
|
134
145
|
}
|
|
135
146
|
|
|
136
147
|
@synthesize delegate = _delegate;
|
|
@@ -142,6 +153,9 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
142
153
|
_overlayToCircleMap = [NSMapTable strongToWeakObjectsMapTable];
|
|
143
154
|
_overlayToGroundOverlayMap = [NSMapTable strongToWeakObjectsMapTable];
|
|
144
155
|
_overlayToTileOverlayMap = [NSMapTable strongToWeakObjectsMapTable];
|
|
156
|
+
_poiEnabled = YES;
|
|
157
|
+
_poiFilterMode = LuggMapViewPoiFilterMode::Including;
|
|
158
|
+
_poiFilterCategories = @[];
|
|
145
159
|
}
|
|
146
160
|
return self;
|
|
147
161
|
}
|
|
@@ -235,15 +249,142 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
235
249
|
_mapView.showsUserLocation = enabled;
|
|
236
250
|
}
|
|
237
251
|
|
|
238
|
-
|
|
252
|
+
static MKPointOfInterestCategory poiCategoryFromString(NSString *string) {
|
|
253
|
+
static NSDictionary<NSString *, MKPointOfInterestCategory> *map;
|
|
254
|
+
static dispatch_once_t onceToken;
|
|
255
|
+
dispatch_once(&onceToken, ^{
|
|
256
|
+
map = @{
|
|
257
|
+
@"airport" : MKPointOfInterestCategoryAirport,
|
|
258
|
+
@"amusement-park" : MKPointOfInterestCategoryAmusementPark,
|
|
259
|
+
@"aquarium" : MKPointOfInterestCategoryAquarium,
|
|
260
|
+
@"atm" : MKPointOfInterestCategoryATM,
|
|
261
|
+
@"bakery" : MKPointOfInterestCategoryBakery,
|
|
262
|
+
@"bank" : MKPointOfInterestCategoryBank,
|
|
263
|
+
@"beach" : MKPointOfInterestCategoryBeach,
|
|
264
|
+
@"brewery" : MKPointOfInterestCategoryBrewery,
|
|
265
|
+
@"cafe" : MKPointOfInterestCategoryCafe,
|
|
266
|
+
@"campground" : MKPointOfInterestCategoryCampground,
|
|
267
|
+
@"car-rental" : MKPointOfInterestCategoryCarRental,
|
|
268
|
+
@"ev-charger" : MKPointOfInterestCategoryEVCharger,
|
|
269
|
+
@"fire-station" : MKPointOfInterestCategoryFireStation,
|
|
270
|
+
@"fitness-center" : MKPointOfInterestCategoryFitnessCenter,
|
|
271
|
+
@"food-market" : MKPointOfInterestCategoryFoodMarket,
|
|
272
|
+
@"gas-station" : MKPointOfInterestCategoryGasStation,
|
|
273
|
+
@"hospital" : MKPointOfInterestCategoryHospital,
|
|
274
|
+
@"hotel" : MKPointOfInterestCategoryHotel,
|
|
275
|
+
@"laundry" : MKPointOfInterestCategoryLaundry,
|
|
276
|
+
@"library" : MKPointOfInterestCategoryLibrary,
|
|
277
|
+
@"marina" : MKPointOfInterestCategoryMarina,
|
|
278
|
+
@"movie-theater" : MKPointOfInterestCategoryMovieTheater,
|
|
279
|
+
@"museum" : MKPointOfInterestCategoryMuseum,
|
|
280
|
+
@"national-park" : MKPointOfInterestCategoryNationalPark,
|
|
281
|
+
@"nightlife" : MKPointOfInterestCategoryNightlife,
|
|
282
|
+
@"park" : MKPointOfInterestCategoryPark,
|
|
283
|
+
@"parking" : MKPointOfInterestCategoryParking,
|
|
284
|
+
@"pharmacy" : MKPointOfInterestCategoryPharmacy,
|
|
285
|
+
@"police" : MKPointOfInterestCategoryPolice,
|
|
286
|
+
@"post-office" : MKPointOfInterestCategoryPostOffice,
|
|
287
|
+
@"public-transport" : MKPointOfInterestCategoryPublicTransport,
|
|
288
|
+
@"restaurant" : MKPointOfInterestCategoryRestaurant,
|
|
289
|
+
@"restroom" : MKPointOfInterestCategoryRestroom,
|
|
290
|
+
@"school" : MKPointOfInterestCategorySchool,
|
|
291
|
+
@"stadium" : MKPointOfInterestCategoryStadium,
|
|
292
|
+
@"store" : MKPointOfInterestCategoryStore,
|
|
293
|
+
@"theater" : MKPointOfInterestCategoryTheater,
|
|
294
|
+
@"university" : MKPointOfInterestCategoryUniversity,
|
|
295
|
+
@"winery" : MKPointOfInterestCategoryWinery,
|
|
296
|
+
@"zoo" : MKPointOfInterestCategoryZoo,
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
return map[string];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
- (void)applyPoiFilter {
|
|
303
|
+
if (!_poiEnabled) {
|
|
304
|
+
_mapView.pointOfInterestFilter =
|
|
305
|
+
MKPointOfInterestFilter.filterExcludingAllCategories;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (_poiFilterCategories.count > 0) {
|
|
309
|
+
NSMutableArray<MKPointOfInterestCategory> *categories =
|
|
310
|
+
[NSMutableArray array];
|
|
311
|
+
for (NSString *name in _poiFilterCategories) {
|
|
312
|
+
MKPointOfInterestCategory category = poiCategoryFromString(name);
|
|
313
|
+
if (category) {
|
|
314
|
+
[categories addObject:category];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (categories.count > 0) {
|
|
318
|
+
if (_poiFilterMode == LuggMapViewPoiFilterMode::Excluding) {
|
|
319
|
+
_mapView.pointOfInterestFilter = [[MKPointOfInterestFilter alloc]
|
|
320
|
+
initExcludingCategories:categories];
|
|
321
|
+
} else {
|
|
322
|
+
_mapView.pointOfInterestFilter = [[MKPointOfInterestFilter alloc]
|
|
323
|
+
initIncludingCategories:categories];
|
|
324
|
+
}
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
_mapView.pointOfInterestFilter = nil;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
- (void)setInsetAdjustment:(LuggMapViewInsetAdjustment)insetAdjustment {
|
|
332
|
+
BOOL automatic = (insetAdjustment == LuggMapViewInsetAdjustment::Automatic);
|
|
333
|
+
if (_mapView.insetsLayoutMarginsFromSafeArea == automatic)
|
|
334
|
+
return;
|
|
335
|
+
|
|
336
|
+
CLLocationCoordinate2D center = _mapView.centerCoordinate;
|
|
337
|
+
_mapView.insetsLayoutMarginsFromSafeArea = automatic;
|
|
338
|
+
|
|
339
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
340
|
+
[self->_mapView setCenterCoordinate:center animated:NO];
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
- (void)setPoiEnabled:(BOOL)enabled {
|
|
345
|
+
_poiEnabled = enabled;
|
|
346
|
+
[self applyPoiFilter];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
- (void)setPoiFilterMode:(LuggMapViewPoiFilterMode)mode {
|
|
350
|
+
_poiFilterMode = mode;
|
|
351
|
+
[self applyPoiFilter];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
- (void)setPoiFilterCategories:(NSArray<NSString *> *)categories {
|
|
355
|
+
_poiFilterCategories = categories;
|
|
356
|
+
[self applyPoiFilter];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
- (void)setMapType:(LuggMapViewMapType)mapType {
|
|
360
|
+
switch (mapType) {
|
|
361
|
+
case LuggMapViewMapType::Satellite:
|
|
362
|
+
_mapView.mapType = MKMapTypeSatellite;
|
|
363
|
+
break;
|
|
364
|
+
case LuggMapViewMapType::Terrain:
|
|
365
|
+
_mapView.mapType = MKMapTypeStandard;
|
|
366
|
+
break;
|
|
367
|
+
case LuggMapViewMapType::Hybrid:
|
|
368
|
+
_mapView.mapType = MKMapTypeHybrid;
|
|
369
|
+
break;
|
|
370
|
+
case LuggMapViewMapType::MutedStandard:
|
|
371
|
+
_mapView.mapType = MKMapTypeMutedStandard;
|
|
372
|
+
break;
|
|
373
|
+
default:
|
|
374
|
+
_mapView.mapType = MKMapTypeStandard;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
- (void)setTheme:(LuggMapViewTheme)theme {
|
|
239
380
|
switch (theme) {
|
|
240
|
-
case
|
|
381
|
+
case LuggMapViewTheme::Dark:
|
|
241
382
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
|
|
242
383
|
break;
|
|
243
|
-
case
|
|
384
|
+
case LuggMapViewTheme::Light:
|
|
244
385
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
245
386
|
break;
|
|
246
|
-
default:
|
|
387
|
+
default:
|
|
247
388
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
248
389
|
break;
|
|
249
390
|
}
|
|
@@ -270,6 +411,7 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
270
411
|
CGFloat deltaY = newOffsetY - oldOffsetY;
|
|
271
412
|
|
|
272
413
|
_mapView.layoutMargins = edgeInsets;
|
|
414
|
+
_edgeInsetsCurrent = edgeInsets;
|
|
273
415
|
|
|
274
416
|
if (deltaX != 0 || deltaY != 0) {
|
|
275
417
|
CLLocationCoordinate2D currentCenter = _mapView.centerCoordinate;
|
|
@@ -320,7 +462,7 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
320
462
|
_edgeInsetsFrom.right +
|
|
321
463
|
(_edgeInsetsTo.right - _edgeInsetsFrom.right) * t);
|
|
322
464
|
|
|
323
|
-
[self setEdgeInsets:current oldEdgeInsets:
|
|
465
|
+
[self setEdgeInsets:current oldEdgeInsets:_edgeInsetsCurrent];
|
|
324
466
|
|
|
325
467
|
if (progress >= 1.0) {
|
|
326
468
|
[self stopEdgeInsetsAnimation];
|
|
@@ -719,9 +861,11 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
719
861
|
LuggMarkerView *markerView = annotation.markerView;
|
|
720
862
|
|
|
721
863
|
if (markerView) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
864
|
+
if (!_isProgrammaticSelect) {
|
|
865
|
+
CGPoint point = [_mapView convertCoordinate:markerView.coordinate
|
|
866
|
+
toPointToView:_mapView];
|
|
867
|
+
[markerView emitPressEventWithPoint:point];
|
|
868
|
+
}
|
|
725
869
|
|
|
726
870
|
LuggCalloutView *calloutView = markerView.calloutView;
|
|
727
871
|
if (calloutView && !calloutView.bubbled && calloutView.hasCustomContent) {
|
|
@@ -785,24 +929,23 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
785
929
|
if (contentSize.width <= 0 || contentSize.height <= 0)
|
|
786
930
|
return;
|
|
787
931
|
|
|
788
|
-
CGPoint
|
|
932
|
+
CGPoint offset = calloutView.offset;
|
|
789
933
|
|
|
790
934
|
AppleMarkerAnnotation *annotation =
|
|
791
935
|
(AppleMarkerAnnotation *)_activeNonBubbledMarker.marker;
|
|
792
936
|
MKAnnotationView *annotationView = annotation.annotationView;
|
|
793
937
|
|
|
794
938
|
if (annotationView && contentView.superview == annotationView) {
|
|
795
|
-
CGPoint center =
|
|
796
|
-
|
|
797
|
-
|
|
939
|
+
CGPoint center =
|
|
940
|
+
CGPointMake(annotationView.bounds.size.width / 2.0 + offset.x,
|
|
941
|
+
-contentSize.height / 2.0 + offset.y);
|
|
798
942
|
contentView.center = center;
|
|
799
943
|
} else {
|
|
800
944
|
CGPoint point =
|
|
801
945
|
[_mapView convertCoordinate:_activeNonBubbledMarker.coordinate
|
|
802
946
|
toPointToView:_wrapperView];
|
|
803
|
-
contentView.center =
|
|
804
|
-
|
|
805
|
-
point.y + contentSize.height * (0.5 - anchor.y));
|
|
947
|
+
contentView.center = CGPointMake(
|
|
948
|
+
point.x + offset.x, point.y - contentSize.height / 2.0 + offset.y);
|
|
806
949
|
}
|
|
807
950
|
|
|
808
951
|
contentView.hidden = NO;
|
|
@@ -876,7 +1019,9 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
876
1019
|
if ([view.annotation isKindOfClass:[AppleMarkerAnnotation class]]) {
|
|
877
1020
|
AppleMarkerAnnotation *annotation =
|
|
878
1021
|
(AppleMarkerAnnotation *)view.annotation;
|
|
879
|
-
|
|
1022
|
+
if (annotation.markerView.centerOnPress) {
|
|
1023
|
+
[_mapView setCenterCoordinate:annotation.coordinate animated:YES];
|
|
1024
|
+
}
|
|
880
1025
|
}
|
|
881
1026
|
}
|
|
882
1027
|
|
|
@@ -901,6 +1046,42 @@ static double tileToLng(NSInteger x, NSInteger z) {
|
|
|
901
1046
|
calloutView.hasCustomContent ? calloutView.contentView : nil;
|
|
902
1047
|
}
|
|
903
1048
|
|
|
1049
|
+
- (void)showCalloutForMarkerView:(LuggMarkerView *)markerView {
|
|
1050
|
+
LuggCalloutView *calloutView = markerView.calloutView;
|
|
1051
|
+
_isProgrammaticSelect = YES;
|
|
1052
|
+
|
|
1053
|
+
if (calloutView && calloutView.hasCustomContent) {
|
|
1054
|
+
[self dismissNonBubbledCallout];
|
|
1055
|
+
AppleMarkerAnnotation *annotation =
|
|
1056
|
+
(AppleMarkerAnnotation *)markerView.marker;
|
|
1057
|
+
if (!calloutView.bubbled) {
|
|
1058
|
+
[self showNonBubbledCallout:markerView];
|
|
1059
|
+
} else if (annotation) {
|
|
1060
|
+
[_mapView selectAnnotation:annotation animated:YES];
|
|
1061
|
+
}
|
|
1062
|
+
_isProgrammaticSelect = NO;
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
if (markerView.title.length > 0) {
|
|
1067
|
+
AppleMarkerAnnotation *annotation =
|
|
1068
|
+
(AppleMarkerAnnotation *)markerView.marker;
|
|
1069
|
+
if (annotation) {
|
|
1070
|
+
[_mapView selectAnnotation:annotation animated:YES];
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
_isProgrammaticSelect = NO;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
- (void)hideCalloutForMarkerView:(LuggMarkerView *)markerView {
|
|
1077
|
+
[self dismissNonBubbledCallout];
|
|
1078
|
+
AppleMarkerAnnotation *annotation =
|
|
1079
|
+
(AppleMarkerAnnotation *)markerView.marker;
|
|
1080
|
+
if (annotation) {
|
|
1081
|
+
[_mapView deselectAnnotation:annotation animated:YES];
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
904
1085
|
#pragma mark - MarkerViewDelegate
|
|
905
1086
|
|
|
906
1087
|
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#import "GoogleMapProvider.h"
|
|
2
|
+
|
|
3
|
+
using facebook::react::LuggMapViewInsetAdjustment;
|
|
4
|
+
using facebook::react::LuggMapViewMapType;
|
|
5
|
+
using facebook::react::LuggMapViewPoiFilterMode;
|
|
6
|
+
using facebook::react::LuggMapViewTheme;
|
|
7
|
+
|
|
2
8
|
#import "../LuggCalloutView.h"
|
|
3
9
|
#import "../LuggCircleView.h"
|
|
4
10
|
#import "../LuggGroundOverlayView.h"
|
|
@@ -22,7 +28,7 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
22
28
|
GMSMapView *_mapView;
|
|
23
29
|
BOOL _isMapReady;
|
|
24
30
|
BOOL _isDragging;
|
|
25
|
-
|
|
31
|
+
LuggMapViewTheme _theme;
|
|
26
32
|
UIEdgeInsets _edgeInsets;
|
|
27
33
|
NSMutableArray<LuggMarkerView *> *_pendingMarkerViews;
|
|
28
34
|
NSMutableArray<LuggPolylineView *> *_pendingPolylineViews;
|
|
@@ -164,7 +170,43 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
164
170
|
_mapView.myLocationEnabled = enabled;
|
|
165
171
|
}
|
|
166
172
|
|
|
167
|
-
- (void)
|
|
173
|
+
- (void)setInsetAdjustment:(LuggMapViewInsetAdjustment)insetAdjustment {
|
|
174
|
+
_mapView.paddingAdjustmentBehavior =
|
|
175
|
+
(insetAdjustment == LuggMapViewInsetAdjustment::Automatic)
|
|
176
|
+
? kGMSMapViewPaddingAdjustmentBehaviorAlways
|
|
177
|
+
: kGMSMapViewPaddingAdjustmentBehaviorNever;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)setPoiEnabled:(BOOL)enabled {
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
- (void)setPoiFilterMode:(LuggMapViewPoiFilterMode)mode {
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
- (void)setPoiFilterCategories:(NSArray<NSString *> *)categories {
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (void)setMapType:(LuggMapViewMapType)mapType {
|
|
190
|
+
if (!_mapView)
|
|
191
|
+
return;
|
|
192
|
+
|
|
193
|
+
switch (mapType) {
|
|
194
|
+
case LuggMapViewMapType::Satellite:
|
|
195
|
+
_mapView.mapType = kGMSTypeSatellite;
|
|
196
|
+
break;
|
|
197
|
+
case LuggMapViewMapType::Terrain:
|
|
198
|
+
_mapView.mapType = kGMSTypeTerrain;
|
|
199
|
+
break;
|
|
200
|
+
case LuggMapViewMapType::Hybrid:
|
|
201
|
+
_mapView.mapType = kGMSTypeHybrid;
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
_mapView.mapType = kGMSTypeNormal;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
- (void)setTheme:(LuggMapViewTheme)theme {
|
|
168
210
|
_theme = theme;
|
|
169
211
|
[self applyTheme];
|
|
170
212
|
}
|
|
@@ -174,13 +216,13 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
174
216
|
return;
|
|
175
217
|
|
|
176
218
|
switch (_theme) {
|
|
177
|
-
case
|
|
219
|
+
case LuggMapViewTheme::Dark:
|
|
178
220
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
|
|
179
221
|
break;
|
|
180
|
-
case
|
|
222
|
+
case LuggMapViewTheme::Light:
|
|
181
223
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
182
224
|
break;
|
|
183
|
-
default:
|
|
225
|
+
default:
|
|
184
226
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
185
227
|
break;
|
|
186
228
|
}
|
|
@@ -346,15 +388,21 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
346
388
|
|
|
347
389
|
LuggCalloutView *calloutView = markerView.calloutView;
|
|
348
390
|
if (calloutView && calloutView.hasCustomContent) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
391
|
+
if (markerView.centerOnPress) {
|
|
392
|
+
[mapView animateToLocation:marker.position];
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
mapView.selectedMarker = marker;
|
|
396
|
+
|
|
397
|
+
if (!calloutView.bubbled) {
|
|
398
|
+
[self showNonBubbledCallout:markerView];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return YES;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (!markerView.centerOnPress) {
|
|
405
|
+
mapView.selectedMarker = marker;
|
|
358
406
|
return YES;
|
|
359
407
|
}
|
|
360
408
|
}
|
|
@@ -473,7 +521,7 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
473
521
|
if (contentSize.width <= 0 || contentSize.height <= 0)
|
|
474
522
|
return;
|
|
475
523
|
|
|
476
|
-
CGPoint
|
|
524
|
+
CGPoint offset = calloutView.offset;
|
|
477
525
|
CGPoint point = [_mapView.projection
|
|
478
526
|
pointForCoordinate:_activeNonBubbledMarker.coordinate];
|
|
479
527
|
|
|
@@ -482,9 +530,34 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
482
530
|
iconView.bounds.size.height * _activeNonBubbledMarker.scale;
|
|
483
531
|
|
|
484
532
|
contentView.center =
|
|
485
|
-
CGPointMake(point.x +
|
|
486
|
-
point.y - markerHeight * _activeNonBubbledMarker.anchor.y
|
|
487
|
-
contentSize.height
|
|
533
|
+
CGPointMake(point.x + offset.x,
|
|
534
|
+
point.y - markerHeight * _activeNonBubbledMarker.anchor.y -
|
|
535
|
+
contentSize.height / 2.0 + offset.y);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
- (void)showCalloutForMarkerView:(LuggMarkerView *)markerView {
|
|
539
|
+
LuggCalloutView *calloutView = markerView.calloutView;
|
|
540
|
+
if (calloutView && calloutView.hasCustomContent) {
|
|
541
|
+
[self dismissNonBubbledCallout];
|
|
542
|
+
GMSMarker *marker = (GMSMarker *)markerView.marker;
|
|
543
|
+
if (calloutView.bubbled) {
|
|
544
|
+
_mapView.selectedMarker = marker;
|
|
545
|
+
} else {
|
|
546
|
+
[self showNonBubbledCallout:markerView];
|
|
547
|
+
}
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (markerView.title.length > 0) {
|
|
552
|
+
_mapView.selectedMarker = (GMSMarker *)markerView.marker;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
- (void)hideCalloutForMarkerView:(LuggMarkerView *)markerView {
|
|
557
|
+
[self dismissNonBubbledCallout];
|
|
558
|
+
if (_mapView.selectedMarker == markerView.marker) {
|
|
559
|
+
_mapView.selectedMarker = nil;
|
|
560
|
+
}
|
|
488
561
|
}
|
|
489
562
|
|
|
490
563
|
#pragma mark - MarkerViewDelegate
|