@lugg/maps 1.0.0-beta.1 → 1.0.0-beta.2
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.
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
@property(nonatomic, copy, nullable) NSString *subtitle;
|
|
14
14
|
@property(nonatomic, strong) LuggMarkerView *markerView;
|
|
15
15
|
@property(nonatomic, weak) MKAnnotationView *annotationView;
|
|
16
|
+
@property(nonatomic, copy, nullable) dispatch_block_t pendingScaleAnimation;
|
|
16
17
|
@end
|
|
17
18
|
|
|
18
19
|
@implementation AppleMarkerAnnotation
|
|
@@ -572,6 +573,7 @@
|
|
|
572
573
|
[contentView removeFromSuperview];
|
|
573
574
|
|
|
574
575
|
contentView.userInteractionEnabled = YES;
|
|
576
|
+
contentView.hidden = YES;
|
|
575
577
|
calloutView.delegate = self;
|
|
576
578
|
|
|
577
579
|
AppleMarkerAnnotation *annotation =
|
|
@@ -585,7 +587,10 @@
|
|
|
585
587
|
}
|
|
586
588
|
|
|
587
589
|
_activeNonBubbledMarker = markerView;
|
|
588
|
-
|
|
590
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
591
|
+
[self positionNonBubbledCallout];
|
|
592
|
+
contentView.hidden = NO;
|
|
593
|
+
});
|
|
589
594
|
}
|
|
590
595
|
|
|
591
596
|
- (void)calloutViewDidUpdate:(LuggCalloutView *)calloutView {
|
|
@@ -784,6 +789,10 @@
|
|
|
784
789
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
785
790
|
|
|
786
791
|
if (annotation) {
|
|
792
|
+
if (annotation.pendingScaleAnimation) {
|
|
793
|
+
dispatch_block_cancel(annotation.pendingScaleAnimation);
|
|
794
|
+
annotation.pendingScaleAnimation = nil;
|
|
795
|
+
}
|
|
787
796
|
annotation.annotationView.transform = CGAffineTransformIdentity;
|
|
788
797
|
annotation.markerView = nil;
|
|
789
798
|
annotation.annotationView = nil;
|
|
@@ -802,31 +811,65 @@
|
|
|
802
811
|
annotationView.transform = CGAffineTransformIdentity;
|
|
803
812
|
|
|
804
813
|
UIView *iconView = markerView.iconView;
|
|
805
|
-
|
|
806
|
-
|
|
814
|
+
iconView.transform = CGAffineTransformIdentity;
|
|
815
|
+
|
|
816
|
+
// Clean up iconView from in-progress rasterize animation
|
|
817
|
+
if (markerView.rasterize && [iconView superview] == annotationView) {
|
|
818
|
+
[iconView removeFromSuperview];
|
|
819
|
+
iconView.layer.anchorPoint = CGPointMake(0.5, 0.5);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
CGSize size = iconView.bounds.size;
|
|
823
|
+
if (size.width <= 0 || size.height <= 0)
|
|
807
824
|
return;
|
|
808
825
|
|
|
809
826
|
CGFloat scale = markerView.scale;
|
|
810
827
|
CGPoint anchor = markerView.anchor;
|
|
828
|
+
CGFloat scaledWidth = size.width * scale;
|
|
829
|
+
CGFloat scaledHeight = size.height * scale;
|
|
811
830
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
831
|
+
AppleMarkerAnnotation *annotation =
|
|
832
|
+
(AppleMarkerAnnotation *)markerView.marker;
|
|
833
|
+
|
|
834
|
+
// Cancel any pending rasterize
|
|
835
|
+
if (annotation.pendingScaleAnimation) {
|
|
836
|
+
dispatch_block_cancel(annotation.pendingScaleAnimation);
|
|
837
|
+
annotation.pendingScaleAnimation = nil;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// Use live iconView during rapid updates (skip expensive rasterize per frame)
|
|
841
|
+
if (markerView.rasterize && [iconView superview] != annotationView) {
|
|
842
|
+
annotationView.image = nil;
|
|
843
|
+
[annotationView addSubview:iconView];
|
|
821
844
|
}
|
|
822
845
|
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
CGPointMake(
|
|
827
|
-
|
|
846
|
+
iconView.layer.anchorPoint = anchor;
|
|
847
|
+
iconView.bounds = CGRectMake(0, 0, size.width, size.height);
|
|
848
|
+
iconView.center =
|
|
849
|
+
CGPointMake(scaledWidth * anchor.x, scaledHeight * anchor.y);
|
|
850
|
+
iconView.transform = CGAffineTransformMakeScale(scale, scale);
|
|
851
|
+
|
|
852
|
+
annotationView.bounds = CGRectMake(0, 0, scaledWidth, scaledHeight);
|
|
853
|
+
annotationView.centerOffset = CGPointMake(scaledWidth * (0.5 - anchor.x),
|
|
854
|
+
scaledHeight * (0.5 - anchor.y));
|
|
828
855
|
annotationView.transform =
|
|
829
856
|
CGAffineTransformMakeRotation(markerView.rotate * M_PI / 180.0);
|
|
857
|
+
|
|
858
|
+
// Debounce: rasterize once updates settle
|
|
859
|
+
if (markerView.rasterize) {
|
|
860
|
+
dispatch_block_t rasterizeBlock =
|
|
861
|
+
dispatch_block_create((dispatch_block_flags_t)0, ^{
|
|
862
|
+
annotation.pendingScaleAnimation = nil;
|
|
863
|
+
annotationView.image = [markerView createScaledIconImage];
|
|
864
|
+
[iconView removeFromSuperview];
|
|
865
|
+
[markerView resetIconViewTransform];
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
annotation.pendingScaleAnimation = rasterizeBlock;
|
|
869
|
+
dispatch_after(
|
|
870
|
+
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(150 * NSEC_PER_MSEC)),
|
|
871
|
+
dispatch_get_main_queue(), rasterizeBlock);
|
|
872
|
+
}
|
|
830
873
|
}
|
|
831
874
|
|
|
832
875
|
- (void)updateAnnotationViewFrame:(AppleMarkerAnnotation *)annotation {
|
|
@@ -311,9 +311,16 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
311
311
|
[markerView emitPressEventWithPoint:point];
|
|
312
312
|
|
|
313
313
|
LuggCalloutView *calloutView = markerView.calloutView;
|
|
314
|
-
if (calloutView &&
|
|
314
|
+
if (calloutView && calloutView.hasCustomContent) {
|
|
315
315
|
[mapView animateToLocation:marker.position];
|
|
316
|
-
|
|
316
|
+
|
|
317
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
318
|
+
if (calloutView.bubbled) {
|
|
319
|
+
mapView.selectedMarker = marker;
|
|
320
|
+
} else {
|
|
321
|
+
[self showNonBubbledCallout:markerView];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
317
324
|
return YES;
|
|
318
325
|
}
|
|
319
326
|
}
|
|
@@ -397,11 +404,15 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
397
404
|
[contentView removeFromSuperview];
|
|
398
405
|
|
|
399
406
|
contentView.userInteractionEnabled = YES;
|
|
407
|
+
contentView.hidden = YES;
|
|
400
408
|
calloutView.delegate = self;
|
|
401
409
|
[_wrapperView addSubview:contentView];
|
|
402
410
|
|
|
403
411
|
_activeNonBubbledMarker = markerView;
|
|
404
|
-
|
|
412
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
413
|
+
[self positionNonBubbledCallout];
|
|
414
|
+
contentView.hidden = NO;
|
|
415
|
+
});
|
|
405
416
|
}
|
|
406
417
|
|
|
407
418
|
- (void)calloutViewDidUpdate:(LuggCalloutView *)calloutView {
|