Reputation: 23
i am successfully displaying marker on a google map but problem is if i have more marker than application respond slowly.
public void setMarkerToPoint(ArrayList<BinForLocation> list)
{
for(int i = 0;i<list.size();i++)
{
Log.v("log",""+list.get(i).getLongitude());
Log.v("log",""+list.get(i).getLatitude());
try
{
point = new GeoPoint((int) (Double.parseDouble(list.get(i).getLatitude()) * 1e6),(int) (Double.parseDouble(list.get(i).getLongitude()) * 1e6));
overlayitem = new OverlayItem(point, list.get(i).getLocationName()+"_@_"+list.get(i).getLatitude()+"_@_"+list.get(i).getLongitude(), list.get(i).getAddress());
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
catch (Exception e)
{
Log.v("log",""+e.toString());
e.printStackTrace();
}
point = new GeoPoint((int) (Double.parseDouble(list.get(i).getLatitude()) * 1e6),(int) (Double.parseDouble(list.get(i).getLongitude()) * 1e6));
CenterLocation(point);
myMapController.setZoom(14);
}
}
this function i am calling in oncreate()
Upvotes: 0
Views: 260
Reputation: 28152
If you've made your own customoverlay make sure that your addOverlay methode don't populate. Populate should first happen when all overlays has been added. If you populate each time you add you'll end up with many overlays on top of each other.
Make sure it uses 2 methods:
public void addOverlay(CustomOverlayItem overlay) {
mOverlays.add(overlay);
}
public void populateOverlay() {
populate();
}
Upvotes: 1