Pop-up (InfoBubble) on marker click Here maps

1.4k Views Asked by At

I want to configure my map using HERE FREE SDK so when i click on a marker a pop-up shows up with some Texts , i've tried InfoBubble but i think that's not working anymore, also i wanted to try MapOverlay but it seems that it's limited to JS only. so here's my code :

MapMarker myMapMarker =  new MapMarker(new GeoCoordinate(LAT, LNG), myImage);

map.addMapObject(myMapMarker);
MapGesture.OnGestureListener listener = new MapGesture.OnGestureListener.OnGestureListenerAdapter() {
    @Override
    public boolean onMapObjectsSelected(List<ViewObject> objects) {
        for (ViewObject viewObj : objects) {
            if (viewObj.getBaseType() == ViewObject.Type.USER_OBJECT) {
                if (((MapObject)viewObj).getType() == MapObject.Type.MARKER) {
                        map.setInfoBubbleAdapter( new Map.InfoBubbleAdapter() {
                        @Override
                        public View getInfoBubbleContents(MapMarker mapMarker) {
                            return null;
                        }

                        @Override
                        public View getInfoBubble(MapMarker mapMarker) {
                            View Bubble;

                            Bubble =LayoutInflater.from(getActivity()).inflate(R.layout.bubble_layout,       container, false);
                            TextView nom = Bubble.findViewById( R.id.nomecole );
                            nom.setText( "School" );
                            return Bubble;
                        }
                    } );
                    ((MapObject)viewObj).setVisible(false);
                }
            }
        }

        return false;
    }
};

and for my bubble layout : `

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <TextView
        android:id="@+id/nomecole"
        android:layout_width="100dp"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="-4dp"
        android:layout_marginTop="32dp"
        android:gravity="center"
        android:text="@string/nom"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="13sp" />
    </RelativeLayout>

`

1

There are 1 best solutions below

2
NazarK On

You must call MapMarker.showInfoBubble() to show and MapMarker.hideInfoBubble() to hide info bubble.

Also you may need to remove the line that hides MapMarker so the marker stays visible after it was clicked. This line:

((MapObject)viewObj).setVisible(false);