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
Firebasefirestoreswift Won't Install (Cocoapods)
Function That Takes a Protocol and a Conforming Class (!) Instance as Parameters
Swiftui: How to Make a Button Open a Url in Safari
Swift Protocol to Require Properties as Protocol
Playing a Sound in a Swift Playground
Uipickerview Selectrow Doesn't Works
Scenekit - Custom Geometry Does Not Show Up
Declare Array of Classes That Conform to a Protocol
Why Does the Following Code Crash on an iPhone 5 But Not an iPhone 5S
For-In Loop and Type Casting Only for Objects Which Match Type
Is There a Daylight Savings Check in Swift
Extend Generic Array<T> to Adopt Protocol
Using Applescript with Apple Events in MACos - Script Not Working
How to Implement iOServicematchingcallback in Swift
Instance Member Cannot Be Used on Type Class
Swift/Firebase - Sort Posts in Tableview by Date