Question

I have an Activity where the user must set a location for a POI that he's creating. So, there's an empty map. I want to be able to long press at some point on the map and get that location.

I've seen some other questions regarding this, but using an Overlay to set the locationn (moving it around the map and so). I don't want to have an overlay. I just want to click somewhere on the map and get that location.

I've tried with onTouchEvent in the MapActivity, but it's not being fired when taping on the map.

 @Override
 public boolean onTouchEvent(MotionEvent ev){
     if (ev.getAction() == 1){
         GeoPoint p = mapView.getProjection().fromPixels((int) ev.getX(), (int) ev.getY());
         Toast.makeText(this, p.getLatitudeE6() / 1E6 + "," + p.getLongitudeE6() / 1E6, Toast.LENGTH_LONG).show();
     }
     return false;
 }

Is there any way to do this, or I must use Overlays for it?

Was it helpful?

Solution 2

At the end I used this approach:

https://github.com/commonsguy/cw-android/tree/master/Maps/NooYawk

It draws a marker and lets you move it around the map. You can easily get the coordinates of the markers with the code provided.

OTHER TIPS

http://mobiforge.com/developing/story/using-google-maps-android

See this link, and see the section "Getting the Location that was touched" below figure 9.

it may help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top