I want to display "androidmarker" at where I click on the screen..
My code is above. It is Hello Map View tutorial
http://developer.android.com/resources/tutorials/views/hello-mapview.html

I think I should do it with "onTouchEvent " and try to add it as you
can see at the code. But I don't know how to do it like
 GeoPoint point = new GeoPoint(19240000,-99120000);

Can anyone help me please?
Thanks
Ece

package com.android.test;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;

public class HelloGoogleMapsActivity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

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

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable =
this.getResources().getDrawable(R.drawable.androidmarker);
        HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);

        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, null,null);

        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }


    public boolean onTouchEvent(MotionEvent event, MapView mapView)
    {
        //---when user lifts his finger---
        if (event.getAction() == 1) {
            GeoPoint p = mapView.getProjection().fromPixels(  (int)
event.getX(),(int) event.getY());
            //Geocoder geoCoder = new Geocoder(Context context,
Locale.getDefault());
            // ...
            return true;
        }
        else
            return false;
    }
}




package com.android.test;

import java.util.ArrayList;
import java.util.Locale;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Geocoder;
import android.view.MotionEvent;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay {

        private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();
        private Context mContext;
        private Context context;
         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;
        }
        /*
    @Override
    public boolean onTouchEvent(MotionEvent event, MapView mapView)
    {
        //---when user lifts his finger---
        if (event.getAction() == 1) {
            GeoPoint p = mapView.getProjection().fromPixels(  (int)
event.getX(),(int) event.getY());
            Geocoder geoCoder = new Geocoder(context,
Locale.getDefault());
            // ...
            return true;
        }
        else
            return false;
    } */
}

-- 
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