今天测试了一下地图加载多个不同overlay,结果溢出 其实也不大16*16 总过18个
结果内存移除"out of memory".搜索了一下 有个人也遇到过 他的解决办法就是 捕获溢出的异常
mapView.setBuiltInZoomControls(true);
ZoomButtonsController zoomctrl = mapView.getZoomButtonsController();
zoomctrl.setAutoDismissed(false);//自动隐藏关闭
zoomctrl.setVisible(true);
zoomctrl.setOnZoomListener(new ZoomButtonsController.OnZoomListener() {
public void onZoom(boolean zoomIn) {
// TODO Auto-generated method stub
try{
Log.i(TAG, "OnZoomListener");
System.gc();
if(zoomIn)
{
mc.zoomIn();
}
else
{
mc.zoomOut();
}
System.gc();
}
catch(OutOfMemoryError e)
{
e.printStackTrace();
Log.e(TAG, e.toString());
Toast.makeText(GoogleMap.this, e.toString(), Toast.LENGTH_LONG);
}
catch (Exception e)
{
Log.w(TAG, e.toString());
Toast.makeText(GoogleMap.this, e.toString(), Toast.LENGTH_LONG);
}
}
public void onVisibilityChanged(boolean visible) {
// TODO Auto-generated method stub
}
});
private boolean myDoubleTouch(float x, float y, MapView mapView)
{
Log.i(mParent.TAG, "myDoubleTouch: " + x +","+y);
try
{
mapView.getController().zoomInFixing((int)x, (int)y);
}
catch(OutOfMemoryError e)
{
System.gc();
e.printStackTrace();
Log.e(mParent.TAG, e.toString());
Toast.makeText(m_mapview.getContext(), e.toString(), Toast.LENGTH_LONG);
}
catch (Exception e)
{
Log.w(mParent.TAG, e.toString());
Toast.makeText(m_mapview.getContext(), e.toString(), Toast.LENGTH_LONG);
}
return true;
}