I have problem about google maps.I want to add pin when i touch the
maps .I used this post when i do project.(
http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/)

My problem is i can add pin just one time.But i want to add a lot of
time.I dont understand what is problem.Can anybody help me?

my code is here:

package com.example;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import com.google.android.maps.*;

import java.util.List;

public class HelloGoogleMaps2 extends MapActivity
{
    MapView mapView;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(true);
        mapView.isClickable();


        mapView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent)
{
                 return onTouch2(view,motionEvent);

            }
        });

    }


    public boolean onTouch2(View view, MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            GeoPoint p = mapView.getProjection().fromPixels(
                    (int) motionEvent.getX(),
                    (int) motionEvent.getY());


            AddMyPin(p);

        }

       return  false;

    }

    @Override
    protected boolean isRouteDisplayed()
    {
        return false;
    }

    public void AddMyPin(GeoPoint point)
    {
        List<Overlay> mapOverlays = mapView.getOverlays();

        Drawable drawable =
this.getResources().getDrawable(R.drawable.bubble);
        HelloItemizedOverlays itemizedoverlay = new
HelloItemizedOverlays(drawable,this);

        OverlayItem overlayitem = new OverlayItem(point,null,null);


        itemizedoverlay.addOverlay(overlayitem);

        mapOverlays.add(itemizedoverlay);


    }

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to