Get Lat and Long from Tapped Overlay in Google Maps

How to get the latitude and longitude of location where user taps on the map in android

An example of what i use. Change it accordingly for your needs. I use it with long press.

map.setOnMapLongClickListener(new OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng point) {
map.addMarker(new MarkerOptions().position(point).title("Custom location").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));enter code here
}
});

the LatLng point contains the coordinated of the longpress

Get coordinates on tapping map in android

Try the following.

Write a class which derives from the Overlay class and override the onTap() method. Then you can add your overlay to the your MapView. A GeoPoint object, which represents the position of you tap, is passed to the onTap() method when you tab somewhere on the map.

Add markers to wherever the user taps on Google Maps iOS app?

You can use the delegate method below to know when user tap on your GMSMapView.

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate;

If you want to make your marker draggable, just set:
marker.draggable = YES;

Polyline Tap in Google Maps

You can use isTappable property of GMSPolyline.

isTappable

If this overlay should cause tap notifications.

polyline.isTappable = true

Whenever the polyline is tapped, the GMSMapViewDelegate method didTapOverlay is called

func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
//Write your code here
}

For further information refer https://developers.google.com/maps/documentation/ios-sdk/reference/protocol_g_m_s_map_view_delegate-p.html#a3a2bf2ff4481528f931183cb364c0f4b

how to get lat and long on touch event from google map?

You can get the location from most of the touch events, e.g.

public boolean onTouchEvent(MotionEvent event)
{
int X = (int)event.getX();
int Y = (int)event.getY();

GeoPoint geoPoint = mapView.getProjection().fromPixels(X, Y);
}


Related Topics



Leave a reply



Submit