I am using google map v2 api. In that i need to show multiple markers and multiple overlays. I don't have any idea about this. If anybody knows answer kindly share your thoughts. Thank you.
For single marker and overlay i use this code
hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
Use like this
LatLng one = new LatLng(2.40744, 77.014702);//Latitude and long points
LatLng two = new LatLng(2.407440, 77.014702);
LatLng three = new LatLng(2.4013, 76.951340000000002);
.......
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)));
myMarkerThree = gm.addMarker(new MarkerOptions()
.position(three)
.title("A")
.snippet("dfd")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
and so on..
Try this one.It will be better
String values[]={"2.40744, 77.014702","6.407440, 77.014702","10.4013, 76.951340000000002"};
GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment supportMapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
// Getting a reference to the map
googleMap = supportMapFragment.getMap();
for(int i=0;i<values.length;i++)
{
String s[] = values[i].split(",");
String v1 = s[0];
String v2 = s[1];
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(Double.valueOf(v1),Double.valueOf(v2)))
.title("Hi")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
}
}