如何在此处地图SDK 3.6中的标记上显示信息窗口 [英] How to show info wndow on marker in here map SDK 3.6
问题描述
旧版本具有方法showInfoBubble(),但在此地图的sdk 3.6中已弃用,现在该如何在标记上显示信息.
old version have method showInfoBubble() but deprecated in sdk 3.6 of here map, now how to show info on marker.
这是代码.
MapMarker marker = new MapMarker();
GeoCoordinate geoCoordinate = new GeoCoordinate(c.getLat(), c.getLng());
marker.setCoordinate(geoCoordinate);
marker.setTitle(c.getTicket());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Name : " + (TextUtils.isEmpty(c.getName()) ? "N/A" : c.getName().trim()) + "\n");
stringBuilder.append("Address : " + (TextUtils.isEmpty(c.getStreetAddress()) ? "N/A" : c.getStreetAddress().trim()) + "\n");
stringBuilder.append("Telephone : " + (TextUtils.isEmpty(c.getTelephone()) ? "N/A" : c.getTelephone().trim()));
marker.setDescription(stringBuilder.toString());
mMap.addMapObject(marker);
MapOverlay mapOverlay =新的MapOverlay(view,marker.getCoordinate());
MapOverlay mapOverlay = new MapOverlay(view, marker.getCoordinate());
mMapOverlay.put(c.getId(), mapOverlay);
推荐答案
HEREMobileSDK中的infoBubble已被弃用很长时间了.在弃用消息中,建议切换到MapOverlay: https://developer.here.com/documentation/android-premium/api_reference_java/com/here/android/mpa/mapping/MapOverlay.html
The infoBubble in the HEREMobileSDK was deprecated for quite a long time already. In the deprecation message it was suggested to switch over to MapOverlay: https://developer.here.com/documentation/android-premium/api_reference_java/com/here/android/mpa/mapping/MapOverlay.html
那么,这是什么意思: 您应该使用MapOverlay,而不是从HERE mSDK中显示非常静态/预定义的信息气泡,而是让您将完整的View对象(Android View)添加为地图上固定位置的叠加层.
So, what does this mean: Instead of showing a quite static/predefined infobubble from the HERE mSDK, you should use MapOverlay, that let you add complete View objects (Android Views) as an overlay to a pinned position on the map.
在您的情况下,您可能想监听标记单击事件,如果发生这种情况,则可以添加一个Android View,它看起来像您希望的样子,作为MapOverlay进入地图. 地图叠加层的构建方式如下:MapOverlay(视图视图,GeoCoordinate坐标),并将其固定在该给定位置.
In your case, you might want to listen for the marker click event, and if this happens, then you add a Android View that looks how you want it as a MapOverlay to the map. The Map overlay is constructed like this: MapOverlay (View view, GeoCoordinate coordinate) and will be pinned to that given position.
保留对MapOverlay的引用,因为您需要自行处理何时应该显示和消失.
Keep a reference to the MapOverlay, since you need to handle on your own when it should appear and disappear.
这篇关于如何在此处地图SDK 3.6中的标记上显示信息窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!