I want to show something like
I am able to show all the markers on the map but I want to show info window on every markers whenever all the markers are populated. I've tried this so far but it shows all the markers with only one markers info window.
for (int i = 0; i < jobsDtoList.size(); i++) { Double latitude = Double.parseDouble(jobsDtoList.get(i).getSiteLatitude()); Double longitude = Double.parseDouble(jobsDtoList.get(i).getSiteLongitude()); LatLng latLng = new LatLng(latitude, longitude); MarkerOptions TP = new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.mipmap.job_marker)); googleMap.addMarker(TP).showInfoWindow(); }
An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map.
You can modify the whole InfoWindow using jquery alone... var popup = new google. maps. InfoWindow({ content:'<p id="hook">Hello World!
An InfoWindow can be placed on a map at a particular position or above a marker, depending on what is specified in the options. Unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened. After constructing an InfoWindow, you must call open to display it on the map.
It is not possible to show more than one info window at a time. From the documentation:
An info window allows you to display information to the user when they tap on a marker. Only one info window is displayed at a time. If a user clicks on another marker, the current info window will be hidden and the new info window will be displayed.
You may want to take a look at bubble icons from the Google Maps Android API Utility Library. Bubble icons adds more powerful rendering options for the markers, but does not change their behaviour. It means that you still won't be able to show more than one info window at a time, but bubble icons will allow you to show more info on each marker:
Add a IconGenerator to display snippets of information on your markers. This utility provides a way of making your marker icons look a bit like info windows, in that the marker itself can contain text and other content. The advantage is that you can keep more than one marker open at the same time, whereas only one info window can be open at once. You can also style the markers, change the orientation of the marker and/or content, and change the marker's background image/nine-patch.
UPDATE: An example using bubble icons (take into account that you will need to add the Google Maps Android API utility library to your project following this instructions):
LatLng latLng = new LatLng(latitude, longitude); TextView text = new TextView(context); text.setText("Your text here"); IconGenerator generator = new IconGenerator(context); generator.setBackground(context.getDrawable(R.drawable.bubble_mask)); generator.setContentView(text); Bitmap icon = generator.makeIcon(); MarkerOptions tp = new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(icon)); googleMap.addMarker(tp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With