我想使用 HERE FREE SDK 配置我的地图,所以当我点击一个标记时会弹出一个带有一些文本的弹出窗口,我已经尝试过 InfoBubble 但我认为这不再起作用了,我也想尝试 MapOverlay 但似乎它仅限于JS。所以这是我的代码:
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;
}
};
对于我的气泡布局:`
<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>
`