In my Xamarin.Forms (PCL project) I want to get the coordinate (lat & long) when a user taps on map but I can't find any tap event in the Map class. I think using TapGestureRecognizer class's object will not help in this case.
So is there any technique that we can perform in native platform for recognizing tap and getting coordinate of that tapped area/point?
Any blog post or technique will be helpful.
Thanks.
I implemented simple extended map control to provide tap location for all three platforms. You can have a look here. It's pure sample code, not for production, works fine for me but if you have any problems please tell me.
At this point I do not believe any of the nugets out there for dealing with a Xamarin abstraction of maps is going to handle this kind of very specific thing. You will probably have to do native implementations and use a dependency injection pattern to make the appropriate calls.
Interface in PCL
interface IMaps
{
public GetLatLong();
}
Native Android Implementation
see How to get the Latitude and Longitude on Map in Android?
Native iOS Implementation
see Ios Map: Getting latitude and longitude
Calling Your Implementations in PCL
public point HandleMapOnClick()
{
return DependencyService.Get<IMaps>().GetLatLong();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With