Add multiple markers to Google Maps Api v2

I managed to show google map api v2. I want to add markers for my positions on it.

According to the documentation, I can only add one marker at a time or use a loop to add several.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo_v2);


        googleMap = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

        googleMap.setMyLocationEnabled(true);

        Marker marker = googleMap.addMarker(new MarkerOptions().position(ROMA).title("Hello").snippet("Nice Place").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
}

My question is: if I have a set of 10 LatLon values ​​and custom images, how can I show multiple markers in API v2.

thank

+5
source share
2 answers

Try Link . This is best used and it will help you add some text markers on Android Google Maps API v2

+8
source
for (int i = 0; i < yourArrayList.size(); i++) {
    double lati=Double.parseDouble(pins.get(i).latitude);
    double longLat=Double.parseDouble(pins.get(i).longitude);
    MAP.addMarker(new MarkerOptions().position(
       new LatLng(lati,longLat))
                  .title(pins.get(i)
                  .pinname)
                  .snippet(pins.get(i).address));
}
+2
source

All Articles