Mapquest Map styles often will show a point-of-interest (POI) on the map. You may want to be able to allow the user to click on the POI and do something with that - for example show information about that POI, navigate to the POI, or just show a bubble annotation.
mMapView.getMapAsync(mapboxMap -> {
mMapboxMap = mapboxMap;
mMapboxMapTrafficPresenter = new MapboxMapTrafficPresenter(mMapboxMap, mMapView);
mMapView.setPOIOnMapSelectedListener(poiOnMapList -> {
PoiOnMapData selectedPOI = poiOnMapList.get(0);
showMarkerForPOI(selectedPOI);
});
});
Shows a info panel when a POI is touched
private void showMarkerForPOI(PoiOnMapData selectedPOI) {
//Make a transparent marker
Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
Bitmap transparent = Bitmap.createBitmap(1, 1, conf); // this creates a transparent bitmap
IconFactory iconFactory = IconFactory.getInstance(MainActivity.this);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(MBLatLngUtil.fromMQLatLng(selectedPOI.getLatLng()));
markerOptions.title(selectedPOI.getName());
markerOptions.setIcon(iconFactory.fromBitmap(transparent));
for (Marker marker : mPOIMarkers) {
mMapboxMap.removeMarker(marker);
}
Marker marker = mMapboxMap.addMarker(markerOptions);
mPOIMarkers.add(marker);
mMapboxMap.selectMarker(marker);
}