release 1.0.7, Close Issue #10 , 添加Logo位置设置

This commit is contained in:
Kuloud
2024-07-29 00:28:45 +08:00
parent 7e3759b638
commit 064bb77cf1
14 changed files with 274 additions and 33 deletions

View File

@ -3,6 +3,7 @@
// amap_map
//
// Created by lly on 2020/10/30.
// Updated by kuloud on 2024/07/29.
//
#import "MAMapView+Flutter.h"
@ -217,6 +218,50 @@
if (rotateCameraEnable) {
self.rotateCameraEnabled = [rotateCameraEnable boolValue];
}
NSNumber *logoPosition = dict[@"logoPosition"];
NSNumber *logoBottomMargin = dict[@"logoBottomMargin"];
NSNumber *logoLeftMargin = dict[@"logoLeftMargin"];
CGSize mapSize = self.bounds.size;
CGSize logoSize = CGSizeMake(110, 40); // _mapView.logoCenter = CGPointMake(CGRectGetWidth(self.view.bounds)-55, 450);logo110x40
CGPoint logoCenter = CGPointZero;
if (logoBottomMargin || logoLeftMargin) {
CGFloat bottomMargin = logoBottomMargin ? [logoBottomMargin floatValue] : 0;
CGFloat leftMargin = logoLeftMargin ? [logoLeftMargin floatValue] : 0;
logoCenter.x = leftMargin + logoSize.width / 2;
logoCenter.y = mapSize.height - bottomMargin - logoSize.height / 2;
} else if (logoPosition) {
NSInteger position = [logoPosition integerValue];
switch (position) {
case 0: // LOGO_POSITION_BOTTOM_LEFT
logoCenter = CGPointMake(logoSize.width / 2, mapSize.height - logoSize.height / 2);
break;
case 1: // LOGO_POSITION_BOTTOM_CENTER
logoCenter = CGPointMake(mapSize.width / 2, mapSize.height - logoSize.height / 2);
break;
case 2: // LOGO_POSITION_BOTTOM_RIGHT
logoCenter = CGPointMake(mapSize.width - logoSize.width / 2, mapSize.height - logoSize.height / 2);
break;
default:
//
logoCenter = CGPointMake(logoSize.width / 2, mapSize.height - logoSize.height / 2);
break;
}
} else {
logoCenter = CGPointMake(logoSize.width / 2, mapSize.height - logoSize.height / 2);
}
// logoCentermapView.bounds
logoCenter.x = MAX(logoSize.width / 2, MIN(logoCenter.x, mapSize.width - logoSize.width / 2));
logoCenter.y = MAX(logoSize.height / 2, MIN(logoCenter.y, mapSize.height - logoSize.height / 2));
// logo
self.logoCenter = logoCenter;
}
@end