简体   繁体   English

Android MapBox - 添加带有信息 window 的标记的最佳方法是什么?

[英]Android MapBox - What is the best way to add markers with info window?

As mapbox.addMarker() is depracated I am wondering what is the best way to add marker with simple info window that is associated with the instance of the object and has click listener?由于 mapbox.addMarker() 已弃用,我想知道使用与 object 的实例相关联并具有点击监听器的简单信息 window 添加标记的最佳方法是什么? I tried to use the code from Mapbox documentation: https://docs.mapbox.com/android/maps/examples/symbol-layer-info-window/我尝试使用 Mapbox 文档中的代码: https://docs.mapbox.com/android/maps/examples/symbol-layer-info-window/

But it seems a bit too complicated though.. Is this the only way to add markers with info window?但这似乎有点太复杂了。这是添加带有信息 window 的标记的唯一方法吗?

Does anyone has any idea or link to example other than the one above?除了上述示例之外,是否有人对示例有任何想法或链接?

The preferred way to add annotations to the map in Android is to use the Annotation Plugin:在 Android 中向 map 添加注释的首选方法是使用注释插件:

https://docs.mapbox.com/android/plugins/guides/annotation/ https://docs.mapbox.com/android/plugins/guides/annotation/

I would recommend to take a look at this example:我建议看一下这个例子:

https://docs.mapbox.com/android/plugins/examples/marker-view-plugin/ https://docs.mapbox.com/android/plugins/examples/marker-view-plugin/

To get the same experience as in the example you have provided, you would have to add a click listener similar to how it is done in this example and only set the visibility of the customView that represents the text box when the symbol has been clicked.要获得与您提供的示例相同的体验,您必须添加一个类似于在此示例中完成的单击侦听器,并且仅在单击符号时设置表示文本框的customView的可见性。

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

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