我想显示自定义标记使用GMUClusterManager.我在这里遵循标记聚类的所有步骤.
但是,当我放大该地图时,它只显示红色标记,但我不希望这样.
有实例方法,我已经实现了我的逻辑,但没有用.
- (instancetype)initWithMapView:(GMSMapView *)mapView clusterIconGenerator:(id<GMUClusterIconGenerator>)iconGenerator
{
if ((self = [super init])) {
GMSMarker *marker= [GMSMarker markerWithPosition:CLLocationCoordinate2DMake(24.0, 75.30)];
UIView *customMarker =[[UIView alloc] initWithFrame:CGRectMake(0, 0, 63, 40)];
customMarker.backgroundColor = [UIColor blueColor];
marker.iconView = [self EmployeeMarker:0] ;
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.map = mapView;
}
return self;
}
-(UIView *)EmployeeMarker:(int)labelTextInt{
UIView *customMarker =[[UIView alloc] initWithFrame:CGRectMake(0, 0, 63, 40)];
UIImageView *imgViewCustomMarker = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, 24, 25)];
imgViewCustomMarker.image = [UIImage imageNamed:@"iconMapUser.png"];
[customMarker addSubview:imgViewCustomMarker];
UIView *viewRatingCustom = [[UIView alloc] …Run Code Online (Sandbox Code Playgroud) 我想设置我的文字已售完 在UIImage的中心.但它不在中心.
func textToImage(drawText text: NSString, inImage image: UIImage, atPoint point: CGPoint) -> UIImage {
let textColor = UIColor.white
let textFont = UIFont(name: "Helvetica Bold", size: 32)!
let scale = UIScreen.main.scale
UIGraphicsBeginImageContextWithOptions(image.size, false, scale)
let textFontAttributes = [
NSFontAttributeName: textFont,
NSForegroundColorAttributeName: textColor,
] as [String : Any]
image.draw(in: CGRect(origin: CGPoint.zero, size: image.size))
// let rect = CGRect(origin: point , size: image.size)
let rect = CGRect(origin: CGPoint(x:(image.size.width/2), y: (image.size.height/2)), size: image.size)
text.draw(in: rect, withAttributes: textFontAttributes)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext() …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,我想在该应用程序上在地图上显示很多事件。用户可以单击一个事件并查看有关它的大量信息。在另一个视图中,用户可以创建一个新事件,然后将位置和标题存储在 Firebase 数据库中。然后当其他用户在我的应用程序上观看 GoogleMaps 时,他们能够看到在地图中作为标记的所有事件。当用户在地图上缩小时,我想从 Firebase 中聚类标记,但它无法工作,可能是因为我在 Firebase 上加载数据标记的方式。有 3 个问题: - 我无法将我的自定义标记与橙色聚集在一起。- 地图加载时不会出现标记和集群图标,我需要先放大或缩小 - 我希望标记的数据显示在信息窗口中,但我必须为 GoogleMap 和 Firebase 上对应的标记使用正确的数据。- 当我点击集群图标时,它也会显示 alertController,但我只想在用户点击不在集群图标上的标记时看到 alertController。
这是我当前的代码:
class POIItem: NSObject, GMUClusterItem {
var position: CLLocationCoordinate2D
var name: String!
init(position: CLLocationCoordinate2D, name: String) {
self.position = position
self.name = name
}
}
class NewCarteViewController: UIViewController, GMSMapViewDelegate, CLLocationManagerDelegate, GMUClusterManagerDelegate {
var locationManager = CLLocationManager()
var positionActuelle = CLLocation() // Another current position
var currentPosition = CLLocationCoordinate2D()
var latiti: CLLocationDegrees!
var longiti: CLLocationDegrees!
private var clusterManager: …Run Code Online (Sandbox Code Playgroud)