在图形页面添加多个覆盖动态 [英] Adding multiple overlays on mapview dynamically

查看:156
本文介绍了在图形页面添加多个覆盖动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有哪些我设法得到一个覆盖onLong preSS与GestureListener的帮助下MapView类。我真正想要的是,我想通过一个添加标记(相同的图标)之一。就像我要标记在地图上的位置不同(并不是所有的一次)。任何帮助,这将是巨大的,与图形页面和覆盖是新手。

I've a mapView on which I managed to get an overlay onLongPress with the help of GestureListener. What I actually want is, I want to add markers (with same icon) one by one. Like I want to mark different positions on map (not all at once). Any help with this would be great as am newbie with MapView and Overlays.

推荐答案

使用ItemizedOverlay类就具体经度和纬度添加绘制。

Use ItemizedOverlay class to add drawable on specific longitudes and latitudes.

在您MapActivity写

In your MapActivity write

的GeoPoint your_point =(在这里提供的GeoPoint信息);

GeoPoint your_point = (Provide geopoint information here);

可绘制可绘制=
。this.getResources()getDrawable(R.drawable.your_point_image);

Drawable drawable = this.getResources().getDrawable(R.drawable.your_point_image);

HelloItemizedOverlay itemizedoverlay =新HelloItemizedOverlay(
                        绘制,MapsActivity.this,图形页面);
                的GeoPoint点=新的GeoPoint((INT)(your_point.getLat()* 1E6)
                        (INT)(your_point.getLon()* 1E6));

HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay( drawable, MapsActivity.this, mapView); GeoPoint point = new GeoPoint((int) (your_point.getLat() * 1E6), (int) (your_point.getLon() * 1E6));

OverlayItem overlayitem1 =新OverlayItem(your_point);

OverlayItem overlayitem1 = new OverlayItem(your_point);

itemizedoverlay.addOverlay(overlayitem1);
                。调用MapView.getOverlays()加(itemizedoverlay);

itemizedoverlay.addOverlay(overlayitem1); mapView.getOverlays().add(itemizedoverlay);

其中,

HelloItemizedOverlay延伸ItemizedOverlay {

HelloItemizedOverlay extends ItemizedOverlay{

公共HelloItemizedOverlay(可绘制defaultMarker,活动的背景下,
            MapView类MapView类){
        超(boundCenterBottom(defaultMarker));
        mContext =背景;
        this.mapView =图形页面;

public HelloItemizedOverlay(Drawable defaultMarker, Activity context, MapView mapView) { super(boundCenterBottom(defaultMarker)); mContext = context; this.mapView = mapView;

}

}

我就是这么做的,它的工作原理。

I did it this way and it works.

这篇关于在图形页面添加多个覆盖动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆