@lugg/maps 1.0.0-beta.4 → 1.0.0-beta.6

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.
Files changed (104) hide show
  1. package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +4 -2
  2. package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +4 -3
  3. package/android/src/main/java/com/luggmaps/LuggMapView.kt +40 -0
  4. package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +31 -0
  5. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +23 -0
  6. package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
  7. package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +166 -21
  8. package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +5 -0
  9. package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +11 -0
  10. package/ios/LuggCalloutView.h +1 -1
  11. package/ios/LuggCalloutView.mm +21 -11
  12. package/ios/LuggMapView.mm +41 -2
  13. package/ios/LuggMarkerView.h +3 -0
  14. package/ios/LuggMarkerView.mm +23 -0
  15. package/ios/core/AppleMapProvider.mm +236 -16
  16. package/ios/core/GoogleMapProvider.mm +91 -18
  17. package/ios/core/MapProviderDelegate.h +8 -1
  18. package/lib/module/MapProvider.web.js +4 -1
  19. package/lib/module/MapProvider.web.js.map +1 -1
  20. package/lib/module/MapView.js +12 -1
  21. package/lib/module/MapView.js.map +1 -1
  22. package/lib/module/MapView.web.js +21 -18
  23. package/lib/module/MapView.web.js.map +1 -1
  24. package/lib/module/components/Circle.web.js +3 -3
  25. package/lib/module/components/Circle.web.js.map +1 -1
  26. package/lib/module/components/GeoJson.js +3 -3
  27. package/lib/module/components/GeoJson.js.map +1 -1
  28. package/lib/module/components/GroundOverlay.web.js +3 -3
  29. package/lib/module/components/GroundOverlay.web.js.map +1 -1
  30. package/lib/module/components/Marker.js +17 -3
  31. package/lib/module/components/Marker.js.map +1 -1
  32. package/lib/module/components/Marker.web.js +23 -10
  33. package/lib/module/components/Marker.web.js.map +1 -1
  34. package/lib/module/components/Polygon.web.js +3 -3
  35. package/lib/module/components/Polygon.web.js.map +1 -1
  36. package/lib/module/components/Polyline.web.js +6 -12
  37. package/lib/module/components/Polyline.web.js.map +1 -1
  38. package/lib/module/components/TileOverlay.web.js +3 -3
  39. package/lib/module/components/TileOverlay.web.js.map +1 -1
  40. package/lib/module/components/index.js.map +1 -1
  41. package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
  42. package/lib/module/fabric/LuggMapViewNativeComponent.ts +9 -1
  43. package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/typescript/src/MapProvider.web.d.ts +3 -2
  46. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
  47. package/lib/typescript/src/MapView.d.ts +1 -1
  48. package/lib/typescript/src/MapView.d.ts.map +1 -1
  49. package/lib/typescript/src/MapView.types.d.ts +36 -1
  50. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  51. package/lib/typescript/src/MapView.web.d.ts +1 -1
  52. package/lib/typescript/src/MapView.web.d.ts.map +1 -1
  53. package/lib/typescript/src/components/Circle.web.d.ts +1 -1
  54. package/lib/typescript/src/components/Circle.web.d.ts.map +1 -1
  55. package/lib/typescript/src/components/GeoJson.d.ts +2 -1
  56. package/lib/typescript/src/components/GeoJson.d.ts.map +1 -1
  57. package/lib/typescript/src/components/GroundOverlay.web.d.ts +1 -1
  58. package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -1
  59. package/lib/typescript/src/components/Marker.d.ts +6 -3
  60. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Marker.types.d.ts +14 -5
  62. package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
  63. package/lib/typescript/src/components/Marker.web.d.ts +3 -2
  64. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
  65. package/lib/typescript/src/components/Polygon.web.d.ts +1 -1
  66. package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -1
  67. package/lib/typescript/src/components/Polyline.web.d.ts +1 -1
  68. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
  69. package/lib/typescript/src/components/TileOverlay.web.d.ts +1 -1
  70. package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -1
  71. package/lib/typescript/src/components/index.d.ts +1 -1
  72. package/lib/typescript/src/components/index.d.ts.map +1 -1
  73. package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
  74. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts +6 -1
  75. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
  76. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +8 -1
  77. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
  78. package/lib/typescript/src/index.d.ts +3 -3
  79. package/lib/typescript/src/index.d.ts.map +1 -1
  80. package/lib/typescript/src/index.web.d.ts +1 -1
  81. package/lib/typescript/src/index.web.d.ts.map +1 -1
  82. package/lib/typescript/src/types.d.ts +0 -4
  83. package/lib/typescript/src/types.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/src/MapProvider.web.tsx +5 -3
  86. package/src/MapView.tsx +12 -1
  87. package/src/MapView.types.ts +118 -1
  88. package/src/MapView.web.tsx +378 -345
  89. package/src/components/Circle.web.tsx +81 -79
  90. package/src/components/GeoJson.tsx +3 -3
  91. package/src/components/GroundOverlay.web.tsx +65 -69
  92. package/src/components/Marker.tsx +28 -5
  93. package/src/components/Marker.types.ts +15 -5
  94. package/src/components/Marker.web.tsx +196 -150
  95. package/src/components/Polygon.web.tsx +93 -89
  96. package/src/components/Polyline.web.tsx +235 -235
  97. package/src/components/TileOverlay.web.tsx +83 -81
  98. package/src/components/index.ts +1 -0
  99. package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
  100. package/src/fabric/LuggMapViewNativeComponent.ts +9 -1
  101. package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
  102. package/src/index.ts +6 -1
  103. package/src/index.web.ts +3 -0
  104. package/src/types.ts +0 -5
@@ -43,7 +43,7 @@ using namespace facebook::react;
43
43
  @implementation LuggCalloutView {
44
44
  LuggCalloutContentView *_contentView;
45
45
  BOOL _bubbled;
46
- CGPoint _anchor;
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
- _anchor = CGPointMake(0.5, 1.0);
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
- _bubbled = newViewProps.bubbled;
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.anchor.x != oldViewProps.anchor.x ||
83
- newViewProps.anchor.y != oldViewProps.anchor.y) {
84
- _anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
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.anchor.x != 0 || newViewProps.anchor.y != 0) {
87
- _anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
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
- [_delegate calloutViewDidUpdate:self];
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)anchor {
99
- return _anchor;
108
+ - (CGPoint)offset {
109
+ return _offset;
100
110
  }
101
111
 
102
112
  - (void)mountChildComponentView:
@@ -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 setTheme:(NSInteger)_theme];
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:(NSInteger)_theme];
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(
@@ -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;
@@ -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,181 @@ static double tileToLng(NSInteger x, NSInteger z) {
235
249
  _mapView.showsUserLocation = enabled;
236
250
  }
237
251
 
238
- - (void)setTheme:(NSInteger)theme {
252
+ static MKPointOfInterestCategory poiCategoryFromString(NSString *string) {
253
+ static NSDictionary<NSString *, MKPointOfInterestCategory> *map;
254
+ static dispatch_once_t onceToken;
255
+ dispatch_once(&onceToken, ^{
256
+ NSMutableDictionary<NSString *, MKPointOfInterestCategory> *m =
257
+ [NSMutableDictionary dictionaryWithDictionary:@{
258
+ @"airport" : MKPointOfInterestCategoryAirport,
259
+ @"amusement-park" : MKPointOfInterestCategoryAmusementPark,
260
+ @"aquarium" : MKPointOfInterestCategoryAquarium,
261
+ @"atm" : MKPointOfInterestCategoryATM,
262
+ @"bakery" : MKPointOfInterestCategoryBakery,
263
+ @"bank" : MKPointOfInterestCategoryBank,
264
+ @"beach" : MKPointOfInterestCategoryBeach,
265
+ @"brewery" : MKPointOfInterestCategoryBrewery,
266
+ @"cafe" : MKPointOfInterestCategoryCafe,
267
+ @"campground" : MKPointOfInterestCategoryCampground,
268
+ @"car-rental" : MKPointOfInterestCategoryCarRental,
269
+ @"ev-charger" : MKPointOfInterestCategoryEVCharger,
270
+ @"fire-station" : MKPointOfInterestCategoryFireStation,
271
+ @"fitness-center" : MKPointOfInterestCategoryFitnessCenter,
272
+ @"food-market" : MKPointOfInterestCategoryFoodMarket,
273
+ @"gas-station" : MKPointOfInterestCategoryGasStation,
274
+ @"hospital" : MKPointOfInterestCategoryHospital,
275
+ @"hotel" : MKPointOfInterestCategoryHotel,
276
+ @"laundry" : MKPointOfInterestCategoryLaundry,
277
+ @"library" : MKPointOfInterestCategoryLibrary,
278
+ @"marina" : MKPointOfInterestCategoryMarina,
279
+ @"movie-theater" : MKPointOfInterestCategoryMovieTheater,
280
+ @"museum" : MKPointOfInterestCategoryMuseum,
281
+ @"national-park" : MKPointOfInterestCategoryNationalPark,
282
+ @"nightlife" : MKPointOfInterestCategoryNightlife,
283
+ @"park" : MKPointOfInterestCategoryPark,
284
+ @"parking" : MKPointOfInterestCategoryParking,
285
+ @"pharmacy" : MKPointOfInterestCategoryPharmacy,
286
+ @"police" : MKPointOfInterestCategoryPolice,
287
+ @"post-office" : MKPointOfInterestCategoryPostOffice,
288
+ @"public-transport" : MKPointOfInterestCategoryPublicTransport,
289
+ @"restaurant" : MKPointOfInterestCategoryRestaurant,
290
+ @"restroom" : MKPointOfInterestCategoryRestroom,
291
+ @"school" : MKPointOfInterestCategorySchool,
292
+ @"stadium" : MKPointOfInterestCategoryStadium,
293
+ @"store" : MKPointOfInterestCategoryStore,
294
+ @"theater" : MKPointOfInterestCategoryTheater,
295
+ @"university" : MKPointOfInterestCategoryUniversity,
296
+ @"winery" : MKPointOfInterestCategoryWinery,
297
+ @"zoo" : MKPointOfInterestCategoryZoo,
298
+ }];
299
+ if (@available(iOS 18.0, *)) {
300
+ [m addEntriesFromDictionary:@{
301
+ @"animal-service" : MKPointOfInterestCategoryAnimalService,
302
+ @"automotive-repair" : MKPointOfInterestCategoryAutomotiveRepair,
303
+ @"baseball" : MKPointOfInterestCategoryBaseball,
304
+ @"basketball" : MKPointOfInterestCategoryBasketball,
305
+ @"beauty" : MKPointOfInterestCategoryBeauty,
306
+ @"bowling" : MKPointOfInterestCategoryBowling,
307
+ @"castle" : MKPointOfInterestCategoryCastle,
308
+ @"convention-center" : MKPointOfInterestCategoryConventionCenter,
309
+ @"distillery" : MKPointOfInterestCategoryDistillery,
310
+ @"fairground" : MKPointOfInterestCategoryFairground,
311
+ @"fishing" : MKPointOfInterestCategoryFishing,
312
+ @"fortress" : MKPointOfInterestCategoryFortress,
313
+ @"go-kart" : MKPointOfInterestCategoryGoKart,
314
+ @"golf" : MKPointOfInterestCategoryGolf,
315
+ @"hiking" : MKPointOfInterestCategoryHiking,
316
+ @"kayaking" : MKPointOfInterestCategoryKayaking,
317
+ @"landmark" : MKPointOfInterestCategoryLandmark,
318
+ @"mailbox" : MKPointOfInterestCategoryMailbox,
319
+ @"mini-golf" : MKPointOfInterestCategoryMiniGolf,
320
+ @"music-venue" : MKPointOfInterestCategoryMusicVenue,
321
+ @"national-monument" : MKPointOfInterestCategoryNationalMonument,
322
+ @"planetarium" : MKPointOfInterestCategoryPlanetarium,
323
+ @"rock-climbing" : MKPointOfInterestCategoryRockClimbing,
324
+ @"rv-park" : MKPointOfInterestCategoryRVPark,
325
+ @"skate-park" : MKPointOfInterestCategorySkatePark,
326
+ @"skating" : MKPointOfInterestCategorySkating,
327
+ @"skiing" : MKPointOfInterestCategorySkiing,
328
+ @"soccer" : MKPointOfInterestCategorySoccer,
329
+ @"spa" : MKPointOfInterestCategorySpa,
330
+ @"surfing" : MKPointOfInterestCategorySurfing,
331
+ @"swimming" : MKPointOfInterestCategorySwimming,
332
+ @"tennis" : MKPointOfInterestCategoryTennis,
333
+ @"volleyball" : MKPointOfInterestCategoryVolleyball,
334
+ }];
335
+ }
336
+ map = [m copy];
337
+ });
338
+ return map[string];
339
+ }
340
+
341
+ - (void)applyPoiFilter {
342
+ if (!_poiEnabled) {
343
+ _mapView.pointOfInterestFilter =
344
+ MKPointOfInterestFilter.filterExcludingAllCategories;
345
+ return;
346
+ }
347
+ if (_poiFilterCategories.count > 0) {
348
+ NSMutableArray<MKPointOfInterestCategory> *categories =
349
+ [NSMutableArray array];
350
+ for (NSString *name in _poiFilterCategories) {
351
+ MKPointOfInterestCategory category = poiCategoryFromString(name);
352
+ if (category) {
353
+ [categories addObject:category];
354
+ }
355
+ }
356
+ if (categories.count > 0) {
357
+ if (_poiFilterMode == LuggMapViewPoiFilterMode::Excluding) {
358
+ _mapView.pointOfInterestFilter = [[MKPointOfInterestFilter alloc]
359
+ initExcludingCategories:categories];
360
+ } else {
361
+ _mapView.pointOfInterestFilter = [[MKPointOfInterestFilter alloc]
362
+ initIncludingCategories:categories];
363
+ }
364
+ return;
365
+ }
366
+ }
367
+ _mapView.pointOfInterestFilter = nil;
368
+ }
369
+
370
+ - (void)setInsetAdjustment:(LuggMapViewInsetAdjustment)insetAdjustment {
371
+ BOOL automatic = (insetAdjustment == LuggMapViewInsetAdjustment::Automatic);
372
+ if (_mapView.insetsLayoutMarginsFromSafeArea == automatic)
373
+ return;
374
+
375
+ CLLocationCoordinate2D center = _mapView.centerCoordinate;
376
+ _mapView.insetsLayoutMarginsFromSafeArea = automatic;
377
+
378
+ dispatch_async(dispatch_get_main_queue(), ^{
379
+ [self->_mapView setCenterCoordinate:center animated:NO];
380
+ });
381
+ }
382
+
383
+ - (void)setPoiEnabled:(BOOL)enabled {
384
+ _poiEnabled = enabled;
385
+ [self applyPoiFilter];
386
+ }
387
+
388
+ - (void)setPoiFilterMode:(LuggMapViewPoiFilterMode)mode {
389
+ _poiFilterMode = mode;
390
+ [self applyPoiFilter];
391
+ }
392
+
393
+ - (void)setPoiFilterCategories:(NSArray<NSString *> *)categories {
394
+ _poiFilterCategories = categories;
395
+ [self applyPoiFilter];
396
+ }
397
+
398
+ - (void)setMapType:(LuggMapViewMapType)mapType {
399
+ switch (mapType) {
400
+ case LuggMapViewMapType::Satellite:
401
+ _mapView.mapType = MKMapTypeSatellite;
402
+ break;
403
+ case LuggMapViewMapType::Terrain:
404
+ _mapView.mapType = MKMapTypeStandard;
405
+ break;
406
+ case LuggMapViewMapType::Hybrid:
407
+ _mapView.mapType = MKMapTypeHybrid;
408
+ break;
409
+ case LuggMapViewMapType::MutedStandard:
410
+ _mapView.mapType = MKMapTypeMutedStandard;
411
+ break;
412
+ default:
413
+ _mapView.mapType = MKMapTypeStandard;
414
+ break;
415
+ }
416
+ }
417
+
418
+ - (void)setTheme:(LuggMapViewTheme)theme {
239
419
  switch (theme) {
240
- case 1: // Dark
420
+ case LuggMapViewTheme::Dark:
241
421
  _mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
242
422
  break;
243
- case 0: // Light
423
+ case LuggMapViewTheme::Light:
244
424
  _mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
245
425
  break;
246
- default: // System
426
+ default:
247
427
  _mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
248
428
  break;
249
429
  }
@@ -270,6 +450,7 @@ static double tileToLng(NSInteger x, NSInteger z) {
270
450
  CGFloat deltaY = newOffsetY - oldOffsetY;
271
451
 
272
452
  _mapView.layoutMargins = edgeInsets;
453
+ _edgeInsetsCurrent = edgeInsets;
273
454
 
274
455
  if (deltaX != 0 || deltaY != 0) {
275
456
  CLLocationCoordinate2D currentCenter = _mapView.centerCoordinate;
@@ -320,7 +501,7 @@ static double tileToLng(NSInteger x, NSInteger z) {
320
501
  _edgeInsetsFrom.right +
321
502
  (_edgeInsetsTo.right - _edgeInsetsFrom.right) * t);
322
503
 
323
- [self setEdgeInsets:current oldEdgeInsets:_mapView.layoutMargins];
504
+ [self setEdgeInsets:current oldEdgeInsets:_edgeInsetsCurrent];
324
505
 
325
506
  if (progress >= 1.0) {
326
507
  [self stopEdgeInsetsAnimation];
@@ -719,9 +900,11 @@ static double tileToLng(NSInteger x, NSInteger z) {
719
900
  LuggMarkerView *markerView = annotation.markerView;
720
901
 
721
902
  if (markerView) {
722
- CGPoint point = [_mapView convertCoordinate:markerView.coordinate
723
- toPointToView:_mapView];
724
- [markerView emitPressEventWithPoint:point];
903
+ if (!_isProgrammaticSelect) {
904
+ CGPoint point = [_mapView convertCoordinate:markerView.coordinate
905
+ toPointToView:_mapView];
906
+ [markerView emitPressEventWithPoint:point];
907
+ }
725
908
 
726
909
  LuggCalloutView *calloutView = markerView.calloutView;
727
910
  if (calloutView && !calloutView.bubbled && calloutView.hasCustomContent) {
@@ -785,24 +968,23 @@ static double tileToLng(NSInteger x, NSInteger z) {
785
968
  if (contentSize.width <= 0 || contentSize.height <= 0)
786
969
  return;
787
970
 
788
- CGPoint anchor = calloutView.anchor;
971
+ CGPoint offset = calloutView.offset;
789
972
 
790
973
  AppleMarkerAnnotation *annotation =
791
974
  (AppleMarkerAnnotation *)_activeNonBubbledMarker.marker;
792
975
  MKAnnotationView *annotationView = annotation.annotationView;
793
976
 
794
977
  if (annotationView && contentView.superview == annotationView) {
795
- CGPoint center = CGPointMake(annotationView.bounds.size.width / 2.0 +
796
- contentSize.width * (0.5 - anchor.x),
797
- contentSize.height * (0.5 - anchor.y));
978
+ CGPoint center =
979
+ CGPointMake(annotationView.bounds.size.width / 2.0 + offset.x,
980
+ -contentSize.height / 2.0 + offset.y);
798
981
  contentView.center = center;
799
982
  } else {
800
983
  CGPoint point =
801
984
  [_mapView convertCoordinate:_activeNonBubbledMarker.coordinate
802
985
  toPointToView:_wrapperView];
803
- contentView.center =
804
- CGPointMake(point.x + contentSize.width * (0.5 - anchor.x),
805
- point.y + contentSize.height * (0.5 - anchor.y));
986
+ contentView.center = CGPointMake(
987
+ point.x + offset.x, point.y - contentSize.height / 2.0 + offset.y);
806
988
  }
807
989
 
808
990
  contentView.hidden = NO;
@@ -876,7 +1058,9 @@ static double tileToLng(NSInteger x, NSInteger z) {
876
1058
  if ([view.annotation isKindOfClass:[AppleMarkerAnnotation class]]) {
877
1059
  AppleMarkerAnnotation *annotation =
878
1060
  (AppleMarkerAnnotation *)view.annotation;
879
- [_mapView setCenterCoordinate:annotation.coordinate animated:YES];
1061
+ if (annotation.markerView.centerOnPress) {
1062
+ [_mapView setCenterCoordinate:annotation.coordinate animated:YES];
1063
+ }
880
1064
  }
881
1065
  }
882
1066
 
@@ -901,6 +1085,42 @@ static double tileToLng(NSInteger x, NSInteger z) {
901
1085
  calloutView.hasCustomContent ? calloutView.contentView : nil;
902
1086
  }
903
1087
 
1088
+ - (void)showCalloutForMarkerView:(LuggMarkerView *)markerView {
1089
+ LuggCalloutView *calloutView = markerView.calloutView;
1090
+ _isProgrammaticSelect = YES;
1091
+
1092
+ if (calloutView && calloutView.hasCustomContent) {
1093
+ [self dismissNonBubbledCallout];
1094
+ AppleMarkerAnnotation *annotation =
1095
+ (AppleMarkerAnnotation *)markerView.marker;
1096
+ if (!calloutView.bubbled) {
1097
+ [self showNonBubbledCallout:markerView];
1098
+ } else if (annotation) {
1099
+ [_mapView selectAnnotation:annotation animated:YES];
1100
+ }
1101
+ _isProgrammaticSelect = NO;
1102
+ return;
1103
+ }
1104
+
1105
+ if (markerView.title.length > 0) {
1106
+ AppleMarkerAnnotation *annotation =
1107
+ (AppleMarkerAnnotation *)markerView.marker;
1108
+ if (annotation) {
1109
+ [_mapView selectAnnotation:annotation animated:YES];
1110
+ }
1111
+ }
1112
+ _isProgrammaticSelect = NO;
1113
+ }
1114
+
1115
+ - (void)hideCalloutForMarkerView:(LuggMarkerView *)markerView {
1116
+ [self dismissNonBubbledCallout];
1117
+ AppleMarkerAnnotation *annotation =
1118
+ (AppleMarkerAnnotation *)markerView.marker;
1119
+ if (annotation) {
1120
+ [_mapView deselectAnnotation:annotation animated:YES];
1121
+ }
1122
+ }
1123
+
904
1124
  #pragma mark - MarkerViewDelegate
905
1125
 
906
1126
  - (void)markerViewDidLayout:(LuggMarkerView *)markerView {