1

i have a set of lat long coordinates. i want to display all of those markers at a time on google map. I know how to display a single marker. But don't know how to display multiples at once. Anybody please help me.

Thank you.

i have lat long points.

like

id = 123 lat = 12.00 lon = 77.00

id = 124 lat = 12.01 lon = 77.01

etc.

VenomVendor
  • 15,064
  • 13
  • 65
  • 96
rubin
  • 271
  • 2
  • 6
  • 14
  • Check This http://wptrafficanalyzer.in/blog/adding-multiple-marker-locations-in-google-maps-android-api-v2-and-save-it-in-shared-preferences/ – Karan Mavadhiya Mar 24 '14 at 05:13
  • i went through that blog. already. it is to ADD markers on map. I want to display markers for my lat long points. – rubin Mar 24 '14 at 05:17

3 Answers3

3

May This Help You

       for(int pin=0; pin<pins.size(); pin++)
       {
             LatLng pinLocation = new LatLng(Float.parseFloat(pins.get(pin).latitude), Float.parseFloat(pins.get(pin).longitude));
             Marker storeMarker = map.addMarker(new MarkerOptions()
              .position(pinLocation)
              .title(pins.get(pin).pinname)
              .snippet(pins.get(pin).address)
           );
       }
Karan Mavadhiya
  • 1,042
  • 8
  • 23
  • 1
    Possible to duplicate: http://stackoverflow.com/questions/18827124/adding-multiple-markers-on-google-map-v2 – Lokesh Mar 24 '14 at 05:24
  • Reference From : http://stackoverflow.com/questions/19972476/how-to-show-multiple-marker-on-google-map-android – Karan Mavadhiya Mar 24 '14 at 05:27
0

Create a LatLng object by using following format:

LatLng location = new LatLng(latitude, longitude);

Then call the method with your LatLng object along with your GoogleMap object:

    private Marker setCurrentLocation(LatLng location, GoogleMap map) {
        BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory
                .fromResource(R.drawable.user_location_pin);

        Marker marker = map.addMarker(new MarkerOptions().position(location)
                .icon(bitmapDescriptor).title(location.toString()));

        return marker;
    }
Sujith Thankachan
  • 3,508
  • 2
  • 20
  • 25
0

Try this:

LatLng one = new LatLng(2.40744, 77.014702);//Latitude and long points
    LatLng two = new LatLng(2.407440, 77.014702);
              .......
        Similarly u can use more lat and long 

     myMarkerOne = gm.addMarker(new MarkerOptions()
    .position(one)//use LatLng obj
    .title("C") 
    .snippet("dsfd")
    .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

    myMarkerTwo = gm.addMarker(new MarkerOptions()
    .position(two)
    .title("C") 
    .snippet("dsfds")
    .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

refer this: How to add multiple marker and overlay in v2 google map?

Also check this link:

Community
  • 1
  • 1
Lokesh
  • 5,180
  • 4
  • 27
  • 42
  • Yes you are right.. but he working with two markers, then I think it's not a problem. If he went for more than two then he must went for loop. – Lokesh Mar 24 '14 at 05:32