标签:
在地图上,我们可以观察到开发者留下了一个公司水印,在我们的开发过程中不希望使用人员看到这个图标,现在要去掉他。
在MapWidget类中我们找到了地图绘画的方法。
@Override
protected void onDraw(Canvas canvas) {
this.getDrawingRect(drawingRect);
if (config != null) {
if (prevGrid != null) {
prevGrid.draw(canvas, paint, drawingRect);
}
if (grid != null) {
grid.draw(canvas, paint, drawingRect);
}
drawLayers(canvas, drawingRect);
if (logo != null) {
canvas.drawBitmap(logo,
getWidth() + getScrollX() - logo.getWidth() - 10,
getHeight() + getScrollY() - logo.getHeight() - 10,
null);
}
} else {
scrollTo(0, 0);
drawMissingDataErrorMessage(canvas);
}
}
我们可以看到如下代码绘制了log图标
if (logo != null) {
canvas.drawBitmap(logo,
getWidth() + getScrollX() - logo.getWidth() - 10,
getHeight() + getScrollY() - logo.getHeight() - 10,
null);
}
在包含有原作者代码时,不建议粗暴删除代码,最好创建一个继承自MapWidget的子类,在其上进行删减
创建RoadWayMapWidget
public class RoadWayMapWidget extends MapWidget{
/**
*
* @param context
* -context
* @param rootMapFolder
* -地图资源文件名
* @param initialZoomLevel
* -初始化缩放等级
* @date 2016年4月1日上午9:11:39
*/
public RoadWayMapWidget(Context context, String rootMapFolder,int initialZoomLevel) {
super(context, rootMapFolder, initialZoomLevel);
// TODO Auto-generated constructor stub
}
}
重写onDraw方法,但是删除了绘制图标的代码,如下:
@Override
protected void onDraw(Canvas canvas) {
this.getDrawingRect(drawingRect);
if (config != null) {
if (prevGrid != null) {
prevGrid.draw(canvas, paint, drawingRect);
}
if (grid != null) {
grid.draw(canvas, paint, drawingRect);
}
drawLayers(canvas, drawingRect);
} else {
scrollTo(0, 0);
drawMissingDataErrorMessage(canvas);
}
}
修改MainActivity 如下所示:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RoadWayMapWidget map = new RoadWayMapWidget(this, "map23",15);
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
map.getConfig().setZoomBtnsVisible(false);
layout.addView(map);
}
}
在这里,我们已经去掉了水印图标
标签:
原文地址:http://blog.csdn.net/u012812482/article/details/51336090