0
我想在Android中为myLocation添加覆盖图。地图显示,但覆盖图不显示。我确实使用扩展了ItemizedOverlay的单独类来显示叠加层。我想知道有没有办法显示这个单独的点,而不创建一个单独的类?Android MapView
附件是活动类的源代码。
public class WalkAbout extends MapActivity {
//for Hello_mapview
List<Overlay> mapOverlays;
Drawable drawable;
private MapView m_vwMap;
private MapController m_mapController;
private PathOverlay m_pathOverlay;
private MyLocationOverlay m_locationOverlay;
private ArrayList<GeoPoint> m_arrPathPoints;
private ArrayList<OverlayItem> m_arrPicturePoints;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initLocationData();
initLayout();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
private void initLocationData() {
// TODO
}
private void initLayout() {
//instantiate XML File into corresponding view objects.
//Then inflate new view from XML resource.
setContentView(R.layout.map_layout);
MapView m_vwMap = (MapView)findViewById(R.id.mapview);
m_vwMap.setBuiltInZoomControls(true);
m_vwMap.setSatellite(true);
//retrieve list of overlay objects
mapOverlays=m_vwMap.getOverlays();
//set market for overlays
drawable=this.getResources().getDrawable(R.drawable.item);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight());
//create OverlayItem with my location
m_locationOverlay= new MyLocationOverlay(this, m_vwMap);
//enable market to set location and direction
m_locationOverlay.enableCompass();
m_locationOverlay.enableMyLocation();
mapOverlays.add(m_locationOverlay);
}
}
我没有看到你实际使用'Drawable`的地方。你创建了一个覆盖层,但你实际上并没有放入任何东西,或者将它的标记设置为你的drawable。我也不明白你为什么不愿意创建另一个班级。它看起来像你已经有一个名为`MyLocationOverlay`。 – 2011-02-09 01:27:28