Skip to content Skip to sidebar Skip to footer

How To Add Touch Event To Show Latitude And Longitude In A Toast In Osm

How do I add this function below in my code? The url is this: how to add more marker in osm map in android please help me? I want to add feature to print toast message of every

Solution 1:

Use this piece of code and create an object of this class and add it to the mapsOverlay

classMapOverlayextendscom.google.android.maps.Overlay
{
    @Overridepublicbooleandraw(Canvas canvas, MapView mapView, 
    boolean shadow, long when) 
    {
       //...
    }

    @OverridepublicbooleanonTouchEvent(MotionEvent event, MapView mapView) 
    {   
        //---when user lifts his finger---if (event.getAction() == MotionEvent.ACTION_UP) {                
            GeoPointp= mapView.getProjection().fromPixels(
                (int) event.getX(),
                (int) event.getY());
                Toast.makeText(getBaseContext(), 
                    p.getLatitudeE6() / 1E6 + "," + 
                    p.getLongitudeE6() /1E6 , 
                    Toast.LENGTH_SHORT).show();
        }                            
        returnfalse;
    }        
}

add this line

mapView.getOverlays().add(new MapOverlay());

Post a Comment for "How To Add Touch Event To Show Latitude And Longitude In A Toast In Osm"