在地图视图上显示引脚聚类,以显示不同引脚上的自定义和默认标注视图 [英] Show custom and default callout views on different pins with pin clustering on map view

查看:114
本文介绍了在地图视图上显示引脚聚类,以显示不同引脚上的自定义和默认标注视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题,我是iOS的新手. 我正在地图视图上实现图钉聚类,这对于一种类型的图钉可以很好地工作,但是我的要求是在缩小时将不同类型的图钉聚类在其上,即如果一种图钉在地图视图上显示河流细节这些针脚应聚集在一起并对其进行计数,在其他情况下,如果其他针脚在地图视图上显示要分流的细节,则这些针脚应与河流针脚分开聚集在一起并对其进行单独计数.其他4种不同的引脚也遵循相同的情况.

This is my first question, and i am new to iOS. I am implementing pin clustering on map view , which in working fine for one type of pin but my requirement is to cluster different kind of pins with different cluster count on it when zoomed out i.e if one kind of pin shows river details on map view than these pins should cluster together and give a count on it and on other case if other pin is showing details for diversion on map view than these pins should cluster together separately from river pin and give a separate count on it. and this same case is followed for other 4 different kinds of pins.

我还有一个问题,如何在同一地图视图上为上述不同种类的图钉实现不同的标注视图,即假设河图钉具有默认的标注,包括标题,字幕和附件按钮.在另一侧,对于Diversion引脚,我有自己的自定义标注视图.所以现在我想要的是,当我点击河流图钉时,会弹出默认标注;当我点击转向图钉时,会弹出我自己的自定义标注.其他类型的图钉也是如此.

And i have one more issue , how to implement different callout views for these above different kind of pins on same map view i.e suppose river pin have default callout which includes title,subtitle and accessory button. And on other side for Diversion pin i have my own custom call out view . So now i want is when i tap on river pin than default callout should pop out and when i tap on diversion pin than my own custom callout should pop out.And same for other kind of pins too.

请帮帮我.从过去的两周开始,我一直在处理这些问题,但对我而言没有任何解决方法.请帮帮我,我非常想解决这些问题.

Please help me out . I am working on these issues from last 2 weeks but nothing working out for me. Please help me out i want a solution for these problems badly.

注意:自定义标注和默认标注应通过引脚集群实现.

NOTE: The custom callout and default callout should be implemented with pin clustering.

推荐答案

我已经创建了一个演示,它将解决您有关自定义标注和默认标注的问题.

I have created a demo, which will solve your problem about custom call out and default call out.

将指导您如何创建自定义标注并为其添加图钉.

will guide you how to create custom call out and add pins for it.

此代码包含PinAnnotation,它是MKAnnotation的子类,用于显示自定义标注.

This code contains PinAnnotation which is a subclass of MKAnnotation and acts to show custom call out.

对于默认的标注视图,您只需添加MKAnnotation即可映射,它将显示默认的视图.

For the default call out view you just have to add MKAnnotation to map and it will show default one.

如何根据需要自定义它并为其创建另一个子类.

How ever you can customise it if you want and create another sub class for it.

要使用自定义标注视图测试默认标注.从该答案链接或直接从 此处 下载演示项目.

To test default call out with custom call out view. Download demo project from that answer link or directly from here.

viewDidLoad()的末尾添加以下代码,然后运行该应用程序.

Add below code at the end of viewDidLoad() and run the application.

MKPointAnnotation *pin = [[MKPointAnnotation alloc] init];
pin.coordinate = CLLocationCoordinate2DMake(34.65515f, 133.81951f);
pin.title = @"Default Pin";

[self.mapView addAnnotation:pin];

如下所示:

这篇关于在地图视图上显示引脚聚类,以显示不同引脚上的自定义和默认标注视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆