@lugg/maps 0.2.0-alpha.9 → 1.0.0-beta.0
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/README.md +20 -19
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +290 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +99 -36
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +13 -5
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +157 -13
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +28 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
- package/android/src/main/java/com/luggmaps/LuggPolygonView.kt +85 -0
- package/android/src/main/java/com/luggmaps/LuggPolygonViewManager.kt +100 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +698 -0
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +60 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -24
- package/android/src/main/java/com/luggmaps/events/LongPressEvent.kt +29 -0
- package/android/src/main/java/com/luggmaps/events/MarkerDragEvent.kt +41 -0
- package/android/src/main/java/com/luggmaps/events/MarkerPressEvent.kt +34 -0
- package/android/src/main/java/com/luggmaps/events/PolygonPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/PressEvent.kt +29 -0
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +343 -0
- package/ios/LuggMarkerView.h +13 -0
- package/ios/LuggMarkerView.mm +119 -0
- package/ios/LuggPolygonView.h +31 -0
- package/ios/LuggPolygonView.mm +151 -0
- package/ios/LuggPolylineView.h +4 -0
- package/ios/LuggPolylineView.mm +23 -0
- package/ios/core/AppleMapProvider.h +15 -0
- package/ios/core/AppleMapProvider.mm +1029 -0
- package/ios/core/GMSPolylineAnimator.h +3 -0
- package/ios/core/GMSPolylineAnimator.m +101 -15
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/core/GoogleMapProvider.mm +689 -0
- package/ios/core/MKPolylineAnimator.h +4 -0
- package/ios/core/MKPolylineAnimator.m +167 -42
- package/ios/core/MapProviderDelegate.h +84 -0
- package/ios/core/PolylineAnimatorBase.h +24 -1
- package/ios/core/PolylineAnimatorBase.m +82 -19
- package/ios/events/LongPressEvent.h +29 -0
- package/ios/events/MarkerDragEvent.h +69 -0
- package/ios/events/MarkerPressEvent.h +29 -0
- package/ios/events/PolygonPressEvent.h +20 -0
- package/ios/events/PressEvent.h +29 -0
- package/ios/extensions/MKMapView+Zoom.h +2 -0
- package/ios/extensions/MKMapView+Zoom.m +14 -4
- package/lib/module/MapProvider.js +2 -4
- package/lib/module/MapProvider.js.map +1 -1
- package/lib/module/MapProvider.web.js +12 -7
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +33 -16
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +283 -181
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/GeoJson.js +159 -0
- package/lib/module/components/GeoJson.js.map +1 -0
- package/lib/module/components/GeoJson.types.js +4 -0
- package/lib/module/components/GeoJson.types.js.map +1 -0
- package/lib/module/components/Marker.js +28 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.types.js +4 -0
- package/lib/module/components/Marker.types.js.map +1 -0
- package/lib/module/components/Marker.web.js +98 -27
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polygon.js +46 -0
- package/lib/module/components/Polygon.js.map +1 -0
- package/lib/module/components/Polygon.types.js +4 -0
- package/lib/module/components/Polygon.types.js.map +1 -0
- package/lib/module/components/Polygon.web.js +87 -0
- package/lib/module/components/Polygon.web.js.map +1 -0
- package/lib/module/components/Polyline.js +17 -4
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/Polyline.types.js +4 -0
- package/lib/module/components/Polyline.types.js.map +1 -0
- package/lib/module/components/Polyline.web.js +108 -31
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/components/index.js +4 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +2 -0
- package/lib/module/components/index.web.js.map +1 -1
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/lib/module/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +4 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/src/MapProvider.d.ts +1 -1
- package/lib/typescript/src/MapProvider.d.ts.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +17 -1
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.d.ts +4 -4
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +35 -9
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +2 -11
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/GeoJson.d.ts +4 -0
- package/lib/typescript/src/components/GeoJson.d.ts.map +1 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts +79 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +6 -33
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +74 -0
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.web.d.ts +2 -5
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polygon.d.ts +10 -0
- package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.types.d.ts +33 -0
- package/lib/typescript/src/components/Polygon.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.web.d.ts +3 -0
- package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +6 -21
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.types.d.ts +53 -0
- package/lib/typescript/src/components/Polyline.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.web.d.ts +2 -5
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +8 -2
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +6 -2
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +30 -4
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +45 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts +18 -0
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +9 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +11 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/MapProvider.tsx +1 -3
- package/src/MapProvider.web.tsx +12 -3
- package/src/MapView.tsx +32 -26
- package/src/MapView.types.ts +43 -9
- package/src/MapView.web.tsx +345 -211
- package/src/components/GeoJson.tsx +221 -0
- package/src/components/GeoJson.types.ts +107 -0
- package/src/components/Marker.tsx +45 -36
- package/src/components/Marker.types.ts +75 -0
- package/src/components/Marker.web.tsx +116 -28
- package/src/components/Polygon.tsx +52 -0
- package/src/components/Polygon.types.ts +33 -0
- package/src/components/Polygon.web.tsx +104 -0
- package/src/components/Polyline.tsx +23 -22
- package/src/components/Polyline.types.ts +55 -0
- package/src/components/Polyline.web.tsx +151 -37
- package/src/components/index.ts +16 -2
- package/src/components/index.web.ts +6 -2
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/src/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/src/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/src/index.ts +28 -1
- package/src/index.web.ts +15 -1
- package/src/types.ts +13 -0
- package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +0 -511
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggAppleMapView.mm +0 -592
- package/ios/LuggGoogleMapView.h +0 -13
- package/ios/LuggGoogleMapView.mm +0 -455
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
#import "GoogleMapProvider.h"
|
|
2
|
+
#import "../LuggMarkerView.h"
|
|
3
|
+
#import "../LuggPolygonView.h"
|
|
4
|
+
#import "../LuggPolylineView.h"
|
|
5
|
+
#import "GMSPolylineAnimator.h"
|
|
6
|
+
#import "PolylineAnimatorBase.h"
|
|
7
|
+
|
|
8
|
+
static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
9
|
+
|
|
10
|
+
@interface GoogleMapProvider () <
|
|
11
|
+
LuggMarkerViewDelegate, LuggPolylineViewDelegate, LuggPolygonViewDelegate>
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation GoogleMapProvider {
|
|
15
|
+
GMSMapView *_mapView;
|
|
16
|
+
BOOL _isMapReady;
|
|
17
|
+
BOOL _isDragging;
|
|
18
|
+
NSInteger _theme;
|
|
19
|
+
UIEdgeInsets _edgeInsets;
|
|
20
|
+
NSMutableArray<LuggMarkerView *> *_pendingMarkerViews;
|
|
21
|
+
NSMutableArray<LuggPolylineView *> *_pendingPolylineViews;
|
|
22
|
+
NSMutableArray<LuggPolygonView *> *_pendingPolygonViews;
|
|
23
|
+
NSMapTable<LuggPolylineView *, GMSPolylineAnimator *> *_polylineAnimators;
|
|
24
|
+
NSMapTable<GMSPolygon *, LuggPolygonView *> *_polygonToViewMap;
|
|
25
|
+
NSMapTable<GMSMarker *, LuggMarkerView *> *_markerToViewMap;
|
|
26
|
+
|
|
27
|
+
// Edge insets animation
|
|
28
|
+
CADisplayLink *_edgeInsetsDisplayLink;
|
|
29
|
+
UIEdgeInsets _edgeInsetsFrom;
|
|
30
|
+
UIEdgeInsets _edgeInsetsTo;
|
|
31
|
+
CFTimeInterval _edgeInsetsAnimationStart;
|
|
32
|
+
CFTimeInterval _edgeInsetsAnimationDuration;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@synthesize delegate = _delegate;
|
|
36
|
+
|
|
37
|
+
- (instancetype)init {
|
|
38
|
+
if (self = [super init]) {
|
|
39
|
+
_isMapReady = NO;
|
|
40
|
+
_mapId = kDemoMapId;
|
|
41
|
+
_pendingMarkerViews = [NSMutableArray array];
|
|
42
|
+
_pendingPolylineViews = [NSMutableArray array];
|
|
43
|
+
_pendingPolygonViews = [NSMutableArray array];
|
|
44
|
+
_polylineAnimators = [NSMapTable weakToStrongObjectsMapTable];
|
|
45
|
+
_polygonToViewMap = [NSMapTable strongToWeakObjectsMapTable];
|
|
46
|
+
_markerToViewMap = [NSMapTable strongToWeakObjectsMapTable];
|
|
47
|
+
}
|
|
48
|
+
return self;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (BOOL)isMapReady {
|
|
52
|
+
return _isMapReady;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (GMSMapView *)mapView {
|
|
56
|
+
return _mapView;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#pragma mark - MapProvider
|
|
60
|
+
|
|
61
|
+
- (void)initializeMapInView:(UIView *)wrapperView
|
|
62
|
+
initialCoordinate:(CLLocationCoordinate2D)coordinate
|
|
63
|
+
initialZoom:(double)zoom {
|
|
64
|
+
if (_mapView)
|
|
65
|
+
return;
|
|
66
|
+
|
|
67
|
+
GMSMapID *gmsMapId;
|
|
68
|
+
if ([_mapId isEqualToString:kDemoMapId] || _mapId.length == 0) {
|
|
69
|
+
gmsMapId = [GMSMapID demoMapID];
|
|
70
|
+
} else {
|
|
71
|
+
gmsMapId = [GMSMapID mapIDWithIdentifier:_mapId];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
GMSCameraPosition *camera =
|
|
75
|
+
[GMSCameraPosition cameraWithLatitude:coordinate.latitude
|
|
76
|
+
longitude:coordinate.longitude
|
|
77
|
+
zoom:zoom];
|
|
78
|
+
|
|
79
|
+
GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
|
|
80
|
+
options.frame = wrapperView.bounds;
|
|
81
|
+
options.camera = camera;
|
|
82
|
+
options.mapID = gmsMapId;
|
|
83
|
+
|
|
84
|
+
_mapView = [[GMSMapView alloc] initWithOptions:options];
|
|
85
|
+
_mapView.autoresizingMask =
|
|
86
|
+
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
87
|
+
_mapView.delegate = self;
|
|
88
|
+
_mapView.paddingAdjustmentBehavior =
|
|
89
|
+
kGMSMapViewPaddingAdjustmentBehaviorNever;
|
|
90
|
+
|
|
91
|
+
[wrapperView addSubview:_mapView];
|
|
92
|
+
|
|
93
|
+
[self applyTheme];
|
|
94
|
+
|
|
95
|
+
_isMapReady = YES;
|
|
96
|
+
[self processPendingMarkers];
|
|
97
|
+
[self processPendingPolylines];
|
|
98
|
+
[self processPendingPolygons];
|
|
99
|
+
|
|
100
|
+
[_delegate mapProviderDidReady];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
- (void)destroy {
|
|
104
|
+
[self stopEdgeInsetsAnimation];
|
|
105
|
+
[_pendingMarkerViews removeAllObjects];
|
|
106
|
+
[_pendingPolylineViews removeAllObjects];
|
|
107
|
+
[_pendingPolygonViews removeAllObjects];
|
|
108
|
+
[_polylineAnimators removeAllObjects];
|
|
109
|
+
[_polygonToViewMap removeAllObjects];
|
|
110
|
+
[_markerToViewMap removeAllObjects];
|
|
111
|
+
[_mapView clear];
|
|
112
|
+
[_mapView removeFromSuperview];
|
|
113
|
+
_mapView = nil;
|
|
114
|
+
_isMapReady = NO;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#pragma mark - Props
|
|
118
|
+
|
|
119
|
+
- (void)setZoomEnabled:(BOOL)enabled {
|
|
120
|
+
_mapView.settings.zoomGestures = enabled;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
- (void)setScrollEnabled:(BOOL)enabled {
|
|
124
|
+
_mapView.settings.scrollGestures = enabled;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (void)setRotateEnabled:(BOOL)enabled {
|
|
128
|
+
_mapView.settings.rotateGestures = enabled;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
- (void)setPitchEnabled:(BOOL)enabled {
|
|
132
|
+
_mapView.settings.tiltGestures = enabled;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
- (void)setUserLocationEnabled:(BOOL)enabled {
|
|
136
|
+
_mapView.myLocationEnabled = enabled;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (void)setTheme:(NSInteger)theme {
|
|
140
|
+
_theme = theme;
|
|
141
|
+
[self applyTheme];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)applyTheme {
|
|
145
|
+
if (!_mapView)
|
|
146
|
+
return;
|
|
147
|
+
|
|
148
|
+
switch (_theme) {
|
|
149
|
+
case 1: // Dark
|
|
150
|
+
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
|
|
151
|
+
break;
|
|
152
|
+
case 0: // Light
|
|
153
|
+
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
154
|
+
break;
|
|
155
|
+
default: // System
|
|
156
|
+
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
- (void)setMinZoom:(double)minZoom {
|
|
162
|
+
if (!_mapView)
|
|
163
|
+
return;
|
|
164
|
+
float min = minZoom > 0 ? (float)minZoom : _mapView.minZoom;
|
|
165
|
+
[_mapView setMinZoom:min maxZoom:_mapView.maxZoom];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void)setMaxZoom:(double)maxZoom {
|
|
169
|
+
if (!_mapView)
|
|
170
|
+
return;
|
|
171
|
+
float max = maxZoom > 0 ? (float)maxZoom : _mapView.maxZoom;
|
|
172
|
+
[_mapView setMinZoom:_mapView.minZoom maxZoom:max];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
- (void)setEdgeInsets:(UIEdgeInsets)edgeInsets
|
|
176
|
+
oldEdgeInsets:(UIEdgeInsets)oldEdgeInsets {
|
|
177
|
+
[self setEdgeInsets:edgeInsets oldEdgeInsets:oldEdgeInsets duration:0];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)setEdgeInsets:(UIEdgeInsets)edgeInsets
|
|
181
|
+
oldEdgeInsets:(UIEdgeInsets)oldEdgeInsets
|
|
182
|
+
duration:(double)duration {
|
|
183
|
+
if (UIEdgeInsetsEqualToEdgeInsets(_edgeInsets, edgeInsets))
|
|
184
|
+
return;
|
|
185
|
+
|
|
186
|
+
[self stopEdgeInsetsAnimation];
|
|
187
|
+
|
|
188
|
+
if (duration != 0 && _mapView) {
|
|
189
|
+
double actualDuration = duration < 0 ? 0.3 : duration / 1000.0;
|
|
190
|
+
_edgeInsetsFrom = _edgeInsets;
|
|
191
|
+
_edgeInsetsTo = edgeInsets;
|
|
192
|
+
_edgeInsets = edgeInsets;
|
|
193
|
+
_edgeInsetsAnimationDuration = actualDuration;
|
|
194
|
+
_edgeInsetsAnimationStart = CACurrentMediaTime();
|
|
195
|
+
|
|
196
|
+
_edgeInsetsDisplayLink = [CADisplayLink
|
|
197
|
+
displayLinkWithTarget:self
|
|
198
|
+
selector:@selector(edgeInsetsAnimationTick:)];
|
|
199
|
+
[_edgeInsetsDisplayLink addToRunLoop:[NSRunLoop mainRunLoop]
|
|
200
|
+
forMode:NSRunLoopCommonModes];
|
|
201
|
+
} else {
|
|
202
|
+
_edgeInsets = edgeInsets;
|
|
203
|
+
_mapView.padding = edgeInsets;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
- (void)edgeInsetsAnimationTick:(CADisplayLink *)displayLink {
|
|
208
|
+
CFTimeInterval elapsed = CACurrentMediaTime() - _edgeInsetsAnimationStart;
|
|
209
|
+
CGFloat progress = MIN(elapsed / _edgeInsetsAnimationDuration, 1.0);
|
|
210
|
+
|
|
211
|
+
// Ease out cubic
|
|
212
|
+
CGFloat t = 1.0 - (1.0 - progress) * (1.0 - progress) * (1.0 - progress);
|
|
213
|
+
|
|
214
|
+
UIEdgeInsets current = UIEdgeInsetsMake(
|
|
215
|
+
_edgeInsetsFrom.top + (_edgeInsetsTo.top - _edgeInsetsFrom.top) * t,
|
|
216
|
+
_edgeInsetsFrom.left + (_edgeInsetsTo.left - _edgeInsetsFrom.left) * t,
|
|
217
|
+
_edgeInsetsFrom.bottom +
|
|
218
|
+
(_edgeInsetsTo.bottom - _edgeInsetsFrom.bottom) * t,
|
|
219
|
+
_edgeInsetsFrom.right +
|
|
220
|
+
(_edgeInsetsTo.right - _edgeInsetsFrom.right) * t);
|
|
221
|
+
|
|
222
|
+
_mapView.padding = current;
|
|
223
|
+
|
|
224
|
+
if (progress >= 1.0) {
|
|
225
|
+
[self stopEdgeInsetsAnimation];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
- (void)stopEdgeInsetsAnimation {
|
|
230
|
+
[_edgeInsetsDisplayLink invalidate];
|
|
231
|
+
_edgeInsetsDisplayLink = nil;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
#pragma mark - GMSMapViewDelegate
|
|
235
|
+
|
|
236
|
+
- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture {
|
|
237
|
+
_isDragging = gesture;
|
|
238
|
+
if (_isDragging) {
|
|
239
|
+
for (GMSPolylineAnimator *animator in _polylineAnimators.objectEnumerator) {
|
|
240
|
+
[animator pause];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
- (void)mapView:(GMSMapView *)mapView
|
|
246
|
+
didChangeCameraPosition:(GMSCameraPosition *)position {
|
|
247
|
+
[_delegate mapProviderDidMoveCamera:position.target.latitude
|
|
248
|
+
longitude:position.target.longitude
|
|
249
|
+
zoom:position.zoom
|
|
250
|
+
gesture:_isDragging];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
- (void)mapView:(GMSMapView *)mapView
|
|
254
|
+
idleAtCameraPosition:(GMSCameraPosition *)position {
|
|
255
|
+
BOOL wasDragging = _isDragging;
|
|
256
|
+
_isDragging = NO;
|
|
257
|
+
if (wasDragging) {
|
|
258
|
+
for (GMSPolylineAnimator *animator in _polylineAnimators.objectEnumerator) {
|
|
259
|
+
[animator resume];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
[_delegate mapProviderDidIdleCamera:position.target.latitude
|
|
263
|
+
longitude:position.target.longitude
|
|
264
|
+
zoom:position.zoom
|
|
265
|
+
gesture:wasDragging];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
- (void)mapView:(GMSMapView *)mapView
|
|
269
|
+
didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
|
|
270
|
+
CGPoint point = [mapView.projection pointForCoordinate:coordinate];
|
|
271
|
+
[_delegate mapProviderDidPress:coordinate.latitude
|
|
272
|
+
longitude:coordinate.longitude
|
|
273
|
+
x:point.x
|
|
274
|
+
y:point.y];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
- (void)mapView:(GMSMapView *)mapView
|
|
278
|
+
didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate {
|
|
279
|
+
CGPoint point = [mapView.projection pointForCoordinate:coordinate];
|
|
280
|
+
[_delegate mapProviderDidLongPress:coordinate.latitude
|
|
281
|
+
longitude:coordinate.longitude
|
|
282
|
+
x:point.x
|
|
283
|
+
y:point.y];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
- (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay {
|
|
287
|
+
if (![overlay isKindOfClass:[GMSPolygon class]])
|
|
288
|
+
return;
|
|
289
|
+
|
|
290
|
+
GMSPolygon *polygon = (GMSPolygon *)overlay;
|
|
291
|
+
LuggPolygonView *polygonView = [_polygonToViewMap objectForKey:polygon];
|
|
292
|
+
if (!polygonView || !polygonView.tappable)
|
|
293
|
+
return;
|
|
294
|
+
|
|
295
|
+
[polygonView emitPressEvent];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
|
|
299
|
+
LuggMarkerView *markerView = [_markerToViewMap objectForKey:marker];
|
|
300
|
+
if (markerView) {
|
|
301
|
+
CGPoint point = [_mapView.projection pointForCoordinate:marker.position];
|
|
302
|
+
[markerView emitPressEventWithPoint:point];
|
|
303
|
+
}
|
|
304
|
+
return NO;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
- (void)mapView:(GMSMapView *)mapView
|
|
308
|
+
didBeginDraggingMarker:(GMSMarker *)marker {
|
|
309
|
+
LuggMarkerView *markerView = [_markerToViewMap objectForKey:marker];
|
|
310
|
+
if (markerView) {
|
|
311
|
+
[markerView updateCoordinate:marker.position];
|
|
312
|
+
CGPoint point = [_mapView.projection pointForCoordinate:marker.position];
|
|
313
|
+
[markerView emitDragStartEventWithPoint:point];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
- (void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker {
|
|
318
|
+
LuggMarkerView *markerView = [_markerToViewMap objectForKey:marker];
|
|
319
|
+
if (markerView) {
|
|
320
|
+
[markerView updateCoordinate:marker.position];
|
|
321
|
+
CGPoint point = [_mapView.projection pointForCoordinate:marker.position];
|
|
322
|
+
[markerView emitDragChangeEventWithPoint:point];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
- (void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker {
|
|
327
|
+
LuggMarkerView *markerView = [_markerToViewMap objectForKey:marker];
|
|
328
|
+
if (markerView) {
|
|
329
|
+
[markerView updateCoordinate:marker.position];
|
|
330
|
+
CGPoint point = [_mapView.projection pointForCoordinate:marker.position];
|
|
331
|
+
[markerView emitDragEndEventWithPoint:point];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
#pragma mark - MarkerViewDelegate
|
|
336
|
+
|
|
337
|
+
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
338
|
+
[self syncMarkerView:markerView];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
|
|
342
|
+
[self syncMarkerView:markerView];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
#pragma mark - PolylineViewDelegate
|
|
346
|
+
|
|
347
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
348
|
+
[self syncPolylineView:polylineView];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#pragma mark - PolygonViewDelegate
|
|
352
|
+
|
|
353
|
+
- (void)polygonViewDidUpdate:(LuggPolygonView *)polygonView {
|
|
354
|
+
[self syncPolygonView:polygonView];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#pragma mark - Marker Management
|
|
358
|
+
|
|
359
|
+
- (void)addMarkerView:(LuggMarkerView *)markerView {
|
|
360
|
+
markerView.delegate = self;
|
|
361
|
+
[self syncMarkerView:markerView];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
- (void)removeMarkerView:(LuggMarkerView *)markerView {
|
|
365
|
+
GMSAdvancedMarker *marker = (GMSAdvancedMarker *)markerView.marker;
|
|
366
|
+
if (marker) {
|
|
367
|
+
[_markerToViewMap removeObjectForKey:marker];
|
|
368
|
+
marker.iconView = nil;
|
|
369
|
+
marker.map = nil;
|
|
370
|
+
markerView.marker = nil;
|
|
371
|
+
}
|
|
372
|
+
[markerView resetIconViewTransform];
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
- (void)syncMarkerView:(LuggMarkerView *)markerView {
|
|
376
|
+
if (!_mapView) {
|
|
377
|
+
if (![_pendingMarkerViews containsObject:markerView]) {
|
|
378
|
+
[_pendingMarkerViews addObject:markerView];
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (!markerView.marker) {
|
|
384
|
+
[self addMarkerViewToMap:markerView];
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
GMSAdvancedMarker *marker = (GMSAdvancedMarker *)markerView.marker;
|
|
389
|
+
marker.position = markerView.coordinate;
|
|
390
|
+
marker.title = markerView.title;
|
|
391
|
+
marker.snippet = markerView.markerDescription;
|
|
392
|
+
marker.zIndex = (int)markerView.zIndex;
|
|
393
|
+
marker.draggable = markerView.draggable;
|
|
394
|
+
[self applyMarkerStyle:markerView marker:marker];
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
- (void)processPendingMarkers {
|
|
398
|
+
if (!_mapView)
|
|
399
|
+
return;
|
|
400
|
+
|
|
401
|
+
for (LuggMarkerView *markerView in _pendingMarkerViews) {
|
|
402
|
+
[self addMarkerViewToMap:markerView];
|
|
403
|
+
}
|
|
404
|
+
[_pendingMarkerViews removeAllObjects];
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
- (void)addMarkerViewToMap:(LuggMarkerView *)markerView {
|
|
408
|
+
if (!_mapView)
|
|
409
|
+
return;
|
|
410
|
+
|
|
411
|
+
GMSAdvancedMarker *marker = [[GMSAdvancedMarker alloc] init];
|
|
412
|
+
marker.position = markerView.coordinate;
|
|
413
|
+
marker.title = markerView.title;
|
|
414
|
+
marker.snippet = markerView.markerDescription;
|
|
415
|
+
marker.zIndex = (int)markerView.zIndex;
|
|
416
|
+
marker.draggable = markerView.draggable;
|
|
417
|
+
|
|
418
|
+
[self applyMarkerStyle:markerView marker:marker];
|
|
419
|
+
|
|
420
|
+
marker.map = _mapView;
|
|
421
|
+
markerView.marker = marker;
|
|
422
|
+
[_markerToViewMap setObject:markerView forKey:marker];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
- (void)applyMarkerStyle:(LuggMarkerView *)markerView
|
|
426
|
+
marker:(GMSAdvancedMarker *)marker {
|
|
427
|
+
if (markerView.hasCustomView) {
|
|
428
|
+
if (markerView.rasterize) {
|
|
429
|
+
marker.iconView = nil;
|
|
430
|
+
marker.icon = [markerView createScaledIconImage];
|
|
431
|
+
marker.rotation = markerView.rotate;
|
|
432
|
+
} else {
|
|
433
|
+
UIView *iconView = markerView.iconView;
|
|
434
|
+
if (marker.iconView != iconView) {
|
|
435
|
+
[iconView removeFromSuperview];
|
|
436
|
+
marker.iconView = iconView;
|
|
437
|
+
}
|
|
438
|
+
CGFloat scale = markerView.scale;
|
|
439
|
+
CGFloat radians = markerView.rotate * M_PI / 180.0;
|
|
440
|
+
iconView.transform =
|
|
441
|
+
CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale),
|
|
442
|
+
CGAffineTransformMakeRotation(radians));
|
|
443
|
+
marker.rotation = 0;
|
|
444
|
+
}
|
|
445
|
+
marker.groundAnchor = markerView.anchor;
|
|
446
|
+
} else {
|
|
447
|
+
marker.iconView = nil;
|
|
448
|
+
marker.icon = nil;
|
|
449
|
+
marker.rotation = markerView.rotate;
|
|
450
|
+
marker.groundAnchor = CGPointMake(0.5, 1);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
#pragma mark - Polyline Management
|
|
455
|
+
|
|
456
|
+
- (void)addPolylineView:(LuggPolylineView *)polylineView {
|
|
457
|
+
polylineView.delegate = self;
|
|
458
|
+
[self syncPolylineView:polylineView];
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
- (void)removePolylineView:(LuggPolylineView *)polylineView {
|
|
462
|
+
[_polylineAnimators removeObjectForKey:polylineView];
|
|
463
|
+
GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
|
|
464
|
+
if (polyline) {
|
|
465
|
+
polyline.map = nil;
|
|
466
|
+
polylineView.polyline = nil;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView {
|
|
471
|
+
if (!_mapView) {
|
|
472
|
+
if (![_pendingPolylineViews containsObject:polylineView]) {
|
|
473
|
+
[_pendingPolylineViews addObject:polylineView];
|
|
474
|
+
}
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (!polylineView.polyline) {
|
|
479
|
+
[self addPolylineViewToMap:polylineView];
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
|
|
484
|
+
polyline.strokeWidth = polylineView.strokeWidth;
|
|
485
|
+
polyline.zIndex = (int)polylineView.zIndex;
|
|
486
|
+
|
|
487
|
+
GMSPolylineAnimator *animator =
|
|
488
|
+
[_polylineAnimators objectForKey:polylineView];
|
|
489
|
+
if (animator) {
|
|
490
|
+
animator.coordinates = polylineView.coordinates;
|
|
491
|
+
animator.strokeColors = polylineView.strokeColors;
|
|
492
|
+
animator.animatedOptions = polylineView.animatedOptions;
|
|
493
|
+
animator.animated = polylineView.animated;
|
|
494
|
+
[animator update];
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
- (void)processPendingPolylines {
|
|
499
|
+
if (!_mapView)
|
|
500
|
+
return;
|
|
501
|
+
|
|
502
|
+
for (LuggPolylineView *polylineView in _pendingPolylineViews) {
|
|
503
|
+
[self addPolylineViewToMap:polylineView];
|
|
504
|
+
}
|
|
505
|
+
[_pendingPolylineViews removeAllObjects];
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
- (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
|
|
509
|
+
if (!_mapView)
|
|
510
|
+
return;
|
|
511
|
+
|
|
512
|
+
GMSPolyline *polyline = [GMSPolyline polylineWithPath:[GMSMutablePath path]];
|
|
513
|
+
polyline.strokeWidth = polylineView.strokeWidth;
|
|
514
|
+
polyline.zIndex = (int)polylineView.zIndex;
|
|
515
|
+
polyline.map = _mapView;
|
|
516
|
+
polylineView.polyline = polyline;
|
|
517
|
+
|
|
518
|
+
GMSPolylineAnimator *animator = [[GMSPolylineAnimator alloc] init];
|
|
519
|
+
animator.polyline = polyline;
|
|
520
|
+
animator.coordinates = polylineView.coordinates;
|
|
521
|
+
animator.strokeColors = polylineView.strokeColors;
|
|
522
|
+
animator.animatedOptions = polylineView.animatedOptions;
|
|
523
|
+
animator.animated = polylineView.animated;
|
|
524
|
+
[animator update];
|
|
525
|
+
|
|
526
|
+
[_polylineAnimators setObject:animator forKey:polylineView];
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
#pragma mark - Polygon Management
|
|
530
|
+
|
|
531
|
+
- (void)addPolygonView:(LuggPolygonView *)polygonView {
|
|
532
|
+
polygonView.delegate = self;
|
|
533
|
+
[self syncPolygonView:polygonView];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
- (void)removePolygonView:(LuggPolygonView *)polygonView {
|
|
537
|
+
GMSPolygon *polygon = (GMSPolygon *)polygonView.polygon;
|
|
538
|
+
if (polygon) {
|
|
539
|
+
[_polygonToViewMap removeObjectForKey:polygon];
|
|
540
|
+
polygon.map = nil;
|
|
541
|
+
polygonView.polygon = nil;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
- (void)syncPolygonView:(LuggPolygonView *)polygonView {
|
|
546
|
+
if (!_mapView) {
|
|
547
|
+
if (![_pendingPolygonViews containsObject:polygonView]) {
|
|
548
|
+
[_pendingPolygonViews addObject:polygonView];
|
|
549
|
+
}
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (!polygonView.polygon) {
|
|
554
|
+
[self addPolygonViewToMap:polygonView];
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
GMSPolygon *polygon = (GMSPolygon *)polygonView.polygon;
|
|
559
|
+
|
|
560
|
+
GMSMutablePath *path = [GMSMutablePath path];
|
|
561
|
+
for (CLLocation *location in polygonView.coordinates) {
|
|
562
|
+
[path addCoordinate:location.coordinate];
|
|
563
|
+
}
|
|
564
|
+
polygon.path = path;
|
|
565
|
+
polygon.holes = [self holesPathsFromPolygonView:polygonView];
|
|
566
|
+
polygon.fillColor = polygonView.fillColor;
|
|
567
|
+
polygon.strokeColor = polygonView.strokeColor;
|
|
568
|
+
polygon.strokeWidth = polygonView.strokeWidth;
|
|
569
|
+
polygon.zIndex = (int)polygonView.zIndex;
|
|
570
|
+
polygon.tappable = polygonView.tappable;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
- (NSArray<GMSPath *> *)holesPathsFromPolygonView:
|
|
574
|
+
(LuggPolygonView *)polygonView {
|
|
575
|
+
NSMutableArray<GMSPath *> *holePaths = [NSMutableArray array];
|
|
576
|
+
for (NSArray<CLLocation *> *hole in polygonView.holes) {
|
|
577
|
+
GMSMutablePath *holePath = [GMSMutablePath path];
|
|
578
|
+
for (CLLocation *location in hole) {
|
|
579
|
+
[holePath addCoordinate:location.coordinate];
|
|
580
|
+
}
|
|
581
|
+
[holePaths addObject:holePath];
|
|
582
|
+
}
|
|
583
|
+
return [holePaths copy];
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
- (void)processPendingPolygons {
|
|
587
|
+
if (!_mapView)
|
|
588
|
+
return;
|
|
589
|
+
|
|
590
|
+
for (LuggPolygonView *polygonView in _pendingPolygonViews) {
|
|
591
|
+
[self addPolygonViewToMap:polygonView];
|
|
592
|
+
}
|
|
593
|
+
[_pendingPolygonViews removeAllObjects];
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
- (void)addPolygonViewToMap:(LuggPolygonView *)polygonView {
|
|
597
|
+
if (!_mapView)
|
|
598
|
+
return;
|
|
599
|
+
|
|
600
|
+
GMSMutablePath *path = [GMSMutablePath path];
|
|
601
|
+
for (CLLocation *location in polygonView.coordinates) {
|
|
602
|
+
[path addCoordinate:location.coordinate];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
GMSPolygon *polygon = [GMSPolygon polygonWithPath:path];
|
|
606
|
+
polygon.holes = [self holesPathsFromPolygonView:polygonView];
|
|
607
|
+
polygon.fillColor = polygonView.fillColor;
|
|
608
|
+
polygon.strokeColor = polygonView.strokeColor;
|
|
609
|
+
polygon.strokeWidth = polygonView.strokeWidth;
|
|
610
|
+
polygon.zIndex = (int)polygonView.zIndex;
|
|
611
|
+
polygon.tappable = polygonView.tappable;
|
|
612
|
+
polygon.map = _mapView;
|
|
613
|
+
polygonView.polygon = polygon;
|
|
614
|
+
[_polygonToViewMap setObject:polygonView forKey:polygon];
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
#pragma mark - Lifecycle
|
|
618
|
+
|
|
619
|
+
- (void)pauseAnimations {
|
|
620
|
+
for (GMSPolylineAnimator *animator in _polylineAnimators.objectEnumerator) {
|
|
621
|
+
[animator pause];
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
- (void)resumeAnimations {
|
|
626
|
+
for (GMSPolylineAnimator *animator in _polylineAnimators.objectEnumerator) {
|
|
627
|
+
[animator resume];
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
#pragma mark - Commands
|
|
632
|
+
|
|
633
|
+
- (void)moveCamera:(double)latitude
|
|
634
|
+
longitude:(double)longitude
|
|
635
|
+
zoom:(double)zoom
|
|
636
|
+
duration:(double)duration {
|
|
637
|
+
if (!_mapView)
|
|
638
|
+
return;
|
|
639
|
+
|
|
640
|
+
float targetZoom = zoom > 0 ? (float)zoom : _mapView.camera.zoom;
|
|
641
|
+
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
|
|
642
|
+
longitude:longitude
|
|
643
|
+
zoom:targetZoom];
|
|
644
|
+
if (duration < 0) {
|
|
645
|
+
[_mapView animateToCameraPosition:camera];
|
|
646
|
+
} else if (duration > 0) {
|
|
647
|
+
[CATransaction begin];
|
|
648
|
+
[CATransaction setAnimationDuration:duration / 1000.0];
|
|
649
|
+
[_mapView animateToCameraPosition:camera];
|
|
650
|
+
[CATransaction commit];
|
|
651
|
+
} else {
|
|
652
|
+
[_mapView setCamera:camera];
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
- (void)fitCoordinates:(NSArray *)coordinates
|
|
657
|
+
edgeInsetsTop:(double)edgeInsetsTop
|
|
658
|
+
edgeInsetsLeft:(double)edgeInsetsLeft
|
|
659
|
+
edgeInsetsBottom:(double)edgeInsetsBottom
|
|
660
|
+
edgeInsetsRight:(double)edgeInsetsRight
|
|
661
|
+
duration:(double)duration {
|
|
662
|
+
if (!_mapView || coordinates.count == 0)
|
|
663
|
+
return;
|
|
664
|
+
|
|
665
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
|
|
666
|
+
for (NSDictionary *coord in coordinates) {
|
|
667
|
+
double lat = [coord[@"latitude"] doubleValue];
|
|
668
|
+
double lng = [coord[@"longitude"] doubleValue];
|
|
669
|
+
bounds = [bounds includingCoordinate:CLLocationCoordinate2DMake(lat, lng)];
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
UIEdgeInsets insets = UIEdgeInsetsMake(edgeInsetsTop, edgeInsetsLeft,
|
|
673
|
+
edgeInsetsBottom, edgeInsetsRight);
|
|
674
|
+
GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds
|
|
675
|
+
withEdgeInsets:insets];
|
|
676
|
+
|
|
677
|
+
if (duration < 0) {
|
|
678
|
+
[_mapView animateWithCameraUpdate:cameraUpdate];
|
|
679
|
+
} else if (duration > 0) {
|
|
680
|
+
[CATransaction begin];
|
|
681
|
+
[CATransaction setAnimationDuration:duration / 1000.0];
|
|
682
|
+
[_mapView animateWithCameraUpdate:cameraUpdate];
|
|
683
|
+
[CATransaction commit];
|
|
684
|
+
} else {
|
|
685
|
+
[_mapView moveCamera:cameraUpdate];
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
@end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#import "PolylineAnimatorBase.h"
|
|
1
2
|
#import <MapKit/MapKit.h>
|
|
2
3
|
|
|
3
4
|
@interface MKPolylineAnimator : MKOverlayPathRenderer
|
|
@@ -6,7 +7,10 @@
|
|
|
6
7
|
|
|
7
8
|
@property(nonatomic, strong) NSArray<UIColor *> *strokeColors;
|
|
8
9
|
@property(nonatomic, assign) BOOL animated;
|
|
10
|
+
@property(nonatomic, strong) PolylineAnimatedOptions *animatedOptions;
|
|
9
11
|
|
|
10
12
|
- (void)updatePolyline:(MKPolyline *)polyline;
|
|
13
|
+
- (void)pause;
|
|
14
|
+
- (void)resume;
|
|
11
15
|
|
|
12
16
|
@end
|