简体   繁体   English

如何用不同的图像(图标)聚类点? 地图框

[英]How to cluster points with different images (icons)? MapBox

Friends, I need to cluster points with different pictures (icons). 朋友,我需要用不同的图片(图标)对点进行聚类。 Could you tell me by what means I can do it? 你能告诉我我可以做什么吗? How do this with the mapbox iOS SDK. 如何使用mapbox iOS SDK。

Task: From the server I receive around 2000 images, each image corresponds to a certain coordinate. 任务:我从服务器收到大约2000张图像,每个图像对应一个特定的坐标。 When I got their point data with an image, I'm adding a cluster to the map. 当我获得带有图像的点数据时,我正在向地图添加聚类。

I want to see something like this on my map: enter image description here 我想在地图上看到类似的图像在此处输入图像描述

SymbolStyleLayers can only have one image for all points. SymbolStyleLayers的所有点只能有一张图像。

Do you need to be able to tap these to perform an action? 您是否需要能够点击这些按钮来执行操作? That only works with features added to a MGLSymbolStyleLayer, and you'll want to add them as features, not regular PointAnnotations. 这仅适用于添加到MGLSymbolStyleLayer的要素,并且您需要将其添加为要素,而不是常规的PointAnnotations。

If not, I would just subclass MGLPointAnnotationFeature and have an attributes item for the UIImage, and use the delegate method imageForAnnotation to see if the annotation is of your subclass, and, if so, return the UIImage packaged into an MGLAnnotationImage. 如果不是,我将为MGLPointAnnotationFeature子类,并为UIImage提供一个属性项,并使用委托方法imageForAnnotation来查看注释是否属于您的子类,如果是,则返回打包为MGLAnnotationImage的UIImage。

In order to cluster points with different icons - there is a library. 为了使点具有不同的图标聚类-有一个图书馆。

https://github.com/hulab/ClusterKit https://github.com/hulab/ClusterKit

This proved to be the solution to my problem. 事实证明这是解决我的问题的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM