0

I am working on mapbox android. I need the infowindow to be shown on top of all markers when the activity is loaded, without having to click on the markers to see each info window.How do I acheive this functionality in mapbox?

Here is the code:-

  mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(final MapboxMap map) {

                mapboxMap = map;
  mapboxMap.addMarker(new MarkerOptions()
                        .title("hello")
                        .snippet("I am here")
                .position(new LatLng(33.948,-118.08)));

                mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
                    @Nullable
                    @Override
                    public View getInfoWindow(@NonNull Marker marker) {
                   //What do I give here so that marker click is not at all needed to inflate the Infowindow.
                           return null;
                    }
                });
)
});
Aadhil Ahmed
  • 111
  • 15

2 Answers2

2

Use this code to open infowindow bydefault

Marker marker = myMap.addMarker(new MarkerOptions()
                 .position(latLng)
                 .title("Title")
                 .snippet("Snippet")
                 .icon(BitmapDescriptorFactory
                 .fromResource(R.drawable.marker)));
 marker.showInfoWindow();

but this working only for one marker,fOR multiple marker it opens infowindow for last marker. Source From this Link

Heena M. Patel
  • 144
  • 1
  • 7
  • 1
    showInfoWindow is asking for two parameters- mapboxMap and mapView. Even after giving those two parameters, the info window is not appearing. It appears only on clicking. – Aadhil Ahmed Nov 02 '17 at 11:13
  • put this code in your getmapAsync method. have you done same? – Heena M. Patel Nov 02 '17 at 11:46
  • This shows defualt infoWindow. If I have to inflate a custom infoWindow, how can I do in the same way? – Aadhil Ahmed Nov 02 '17 at 12:13
  • for custom infowindow use this link "http://wptrafficanalyzer.in/blog/customizing-infowindow-contents-in-google-map-android-api-v2-using-infowindowadapter/" – Heena M. Patel Nov 03 '17 at 06:45
0

You can Call View.Performclick() when add marker to Map. Check out this post. Android call onClick method without Clicking

Sardar Khan
  • 845
  • 6
  • 16