Adding multiple markers in Google Maps API v2 Android -
i want add multiple markers in map, don't know way.
at moment, im using this, , works correctly:
marker m1 = googlemap.addmarker(new markeroptions()                 .position(new latlng(38.609556, -1.139637))                 .anchor(0.5f, 0.5f)                 .title("title1")                 .snippet("snippet1")                 .icon(bitmapdescriptorfactory.fromresource(r.drawable.logo1)));   marker m2 = googlemap.addmarker(new markeroptions()                 .position(new latlng(40.4272414,-3.7020037))                 .anchor(0.5f, 0.5f)                 .title("title2")                 .snippet("snippet2")                 .icon(bitmapdescriptorfactory.fromresource(r.drawable.logo2)));   marker m3 = googlemap.addmarker(new markeroptions()                 .position(new latlng(43.2568193,-2.9225534))                 .anchor(0.5f, 0.5f)                 .title("title3")                 .snippet("snippet3")                 .icon(bitmapdescriptorfactory.fromresource(r.drawable.logo3)));   but problem comes when want add 300 markers in map. , doing 1 one annoying.
is there way read markers array or anything?
another question: read markers external file, can add or update markers without touching app code?
thanks.
arraylist<markerdata> markersarray = new arraylist<markerdata>();  for(int = 0 ; < markersarray.size() ; i++ ) {      createmarker(markersarray.get(i).getlatitude(), markersarray.get(i).getlongitude(), markersarray.get(i).gettitle(), markersarray.get(i).getsnippet(), markersarray.get(i).geticonresid()); }  ...  protected marker createmarker(double latitude, double longitude, string title, string snippet, int iconresid) {      return googlemap.addmarker(new markeroptions()             .position(new latlng(latitude, longitude))             .anchor(0.5f, 0.5f)             .title(title)             .snippet(snippet);             .icon(bitmapdescriptorfactory.fromresource(iconresid))); }      
Comments
Post a Comment