在当前位置获得标记

时间:2011-11-08 17:54:23

标签: android android-maps android-location

我是Android应用程序的重要人物,我对GeoLocalisation应用感兴趣。 所以,我开发了一个应用程序,它返回用户设备的当前位置(纬度/经度),我的问题是我想在该位置获得一个标记。 你可以在这个链接中找到我的源代码,所以请问我有人知道如何解决这个问题我会很棒 http://hotfile.com/dl/134520763/75c0f91/current_location.rar.html

2 个答案:

答案 0 :(得分:1)

类HelloItemizedOverlay扩展ItemizedOverlay {         private ArrayList mOverlays = new ArrayList();         private Context mContext;

    public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
        super(boundCenterBottom(defaultMarker));
        mContext = context;
    }

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

    @Override
    protected OverlayItem createItem(int i) {
        return mOverlays.get(i);
    }

    @Override
    public int size() {
        return mOverlays.size();
    }

    @Override
    protected boolean onTap(int index) {
        OverlayItem item = mOverlays.get(index);
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();
        return true;
    }
}



GeoPoint    geoPoint = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));

        mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.pin);
        itemizedOverlay = new HelloItemizedOverlay(drawable, this);
overlayItem = new OverlayItem(geoPoint, "Starting Location", "any text");
                                    itemizedOverlay.addOverlay(overlayItem);
                        mapOverlays.add(itemizedOverlay);

            MapController mapController = mapView.getController();
            mapController.animateTo(geoPoint);

答案 1 :(得分:0)

发布内联代码。您需要使用ItemizedOverLay之类的东西。看Here