diego-bf
diego-bf

Reputation: 11

getting marker in current location

I'm a biggener with android app and i'm interested in GeoLocalisation app. so, I developed an application that returns the current location of the user device (Latitude/longitude) and my problem is that I want to get a marker in that location. you can find my source code in this link so please i'l someone knows how to solve this problem i'm gonna be greatfull http://hotfile.com/dl/134520763/75c0f91/current_location.rar.html

Upvotes: 0

Views: 357

Answers (2)

apesa
apesa

Reputation: 12443

Post you code inline. You will need to use something like ItemizedOverLay. Look Here

Upvotes: 0

Arpit Garg
Arpit Garg

Reputation: 8546

class HelloItemizedOverlay extends 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);

Upvotes: 1

Related Questions