How to show info wndow on marker in here map SDK 3.6

穿精又带淫゛_ 提交于 2019-12-23 03:18:17

问题


old version have method showInfoBubble() but deprecated in sdk 3.6 of here map, now how to show info on marker.

Here are the code.

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 = new MapOverlay(view, marker.getCoordinate());

             mMapOverlay.put(c.getId(), mapOverlay);

回答1:


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

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.

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.

Keep a reference to the MapOverlay, since you need to handle on your own when it should appear and disappear.



来源:https://stackoverflow.com/questions/48200066/how-to-show-info-wndow-on-marker-in-here-map-sdk-3-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!