Get coordinates on tapping map in android

前端 未结 6 1767
北海茫月
北海茫月 2020-12-01 12:49

I\'m trying to make something like this: I have a mapactivity and when the user taps the map it shows the coordinates of that location. I already overrided the onclick metho

6条回答
  •  不思量自难忘°
    2020-12-01 13:19

    Try this:

    private class OverlayMapa extends Overlay {
    
     @Override
     public void draw(Canvas canvas, MapView mapView, boolean shadow) 
     {
       ...
     }
    
     @Override
     public boolean onTap(GeoPoint point, MapView mapView) 
     {
       Context contexto = mapView.getContext();
       String msg = "Lat: " + point.getLatitudeE6()/1E6 + " - " + 
                    "Lon: " + point.getLongitudeE6()/1E6;
    
       Toast toast = Toast.makeText(contexto, msg, Toast.LENGTH_SHORT);
       toast.show();
    
      return true;
     }
    }
    

提交回复
热议问题