OpenLayers 标签问题
我对 OpenLayers.Feature.Vector 上的标签有一个大问题。当我使用 Canvas 渲染器时,所有标签都位于功能的 externalGraphic 下。您可以在这里看到:
不知道如何强制标签涂在标记上。使用 SVG 渲染器在标记上添加标签是否很容易,但在这种情况下,当存在多个标记时,标签看起来很混乱。看起来第一个渲染器绘制了所有图形和所有标签。示例:
我正在寻找解决方案(渲染器没关系)显示带有标签的标记,但没有“标签冲突”,假设我们在一个位置有 5 个标记,但具有不同的标签,我希望看到最后添加的功能 externalGraphic 及其标签,以前的功能(和标签)应该在最后一项之下。
请帮忙!谢谢。
I have a big problem with labels over OpenLayers.Feature.Vector. When I use Canvas renderer all labels are under the externalGraphic of feature. What you can see here:
Do not know how to force labels to be painted over markers. Is it easy to have labels over markers using let say SVG renderer, but in this case labels look messy when there is more than one marker in place. It looks like first renderer paint all graphic and than all labels. Example:
I am looking for a solution (renderer does not matter) to display markers with labels over it but without "labels colisions", let say we have 5 markers in one position but with different labels I am expecting to see last added feature externalGraphic and its label, previous features (and labels) should be under last one.
Please help! Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,OpenLayers 没有任何标签冲突检测功能。我想你必须自己做或者依赖后端的一些地图软件。
OpenLayers don't have any label collision detection that I'm aware of. I suppose you will have to do it yourself or rely on some mapping software in the backend.
很抱歉回答一个非常老的问题,但对于其他遇到这个问题的人来说,另一种解决方案可能是使用集群策略并标记集群。对于具有超过 1 个特征的集群,您可以用逗号分隔或 \n 分隔。例如这里的代码:
改编自:
http://openlayers.org/dev/examples/strategy-cluster.html
Apologies for answering a very old question, but for others coming upon this question, an alternative solution could be to use the Cluster Strategy and label the cluster. for clusters with more than 1 feature, you could comma separate or \n separate. Eg code here:
adaped from:
http://openlayers.org/dev/examples/strategy-cluster.html