在地图视图上使用绘画添加标记图像
我使用下面的代码在地图视图上添加了多个椭圆形,但我想添加气泡标记图像(或任何任何标记),如何在这种情况下使用图像。 在覆盖类中:
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
try{
Projection projection = mapView.getProjection();
super.draw(canvas, mapView, shadow);
// Create and setup your paint brush
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
if (shadow == false) {
for (GeoPoint point : array_Locations) {
Point myPoint = new Point();
projection.toPixels(point, myPoint);
RectF oval = new RectF(myPoint.x-rad,
myPoint.y-rad, myPoint.x+rad, myPoint.y+rad);
canvas.drawOval(oval, paint);
canvas.drawText( "place of interest", myPoint.x, myPoint.y, paint);
}
}
}
catch (Exception ex) {
ex.toString();
}
在地图活动中:
mapView.getOverlays().add(new HelloItemizedOverlay(cursor));
I have added multiple ovals on map view by using below code but I want to add bubble mark image (or any any marker) how I can use image in this case.
in overlay class:
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
try{
Projection projection = mapView.getProjection();
super.draw(canvas, mapView, shadow);
// Create and setup your paint brush
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
if (shadow == false) {
for (GeoPoint point : array_Locations) {
Point myPoint = new Point();
projection.toPixels(point, myPoint);
RectF oval = new RectF(myPoint.x-rad,
myPoint.y-rad, myPoint.x+rad, myPoint.y+rad);
canvas.drawOval(oval, paint);
canvas.drawText( "place of interest", myPoint.x, myPoint.y, paint);
}
}
}
catch (Exception ex) {
ex.toString();
}
in map activity :
mapView.getOverlays().add(new HelloItemizedOverlay(cursor));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在覆盖类构造函数中添加气泡,而不是在 onDraw() 中添加气泡(在您的情况下为 HelloItemizedOverlay)。
例如,请参阅此处的代码带有气球的MapView。
Instead of adding bubble in onDraw() you can do it in your overlay class constructor (in your case HelloItemizedOverlay).
For example see code from here MapView with balloons.