Hello, I am using Xamarin.Forms.GoogleMaps.Map. To customize the display of the pin, I assign BitmapDescriptor to the icon property. Example:
pin.Icon = BitmapDescriptorFactory.FromView(new AdressPinWithTextPlus());
AdressPinWithTextPlus is a ContentView, so I tried to configure Binding for individual elements in the view. However, my AdressPinWithTextPlus is converted to Bitmap, so I can not trace the events of clicking on the individual elements of the view (example on the attached image to the question).
What are the methods for solving this problem?
The solution was to place the map in RelativeLayout and separately add pins in the form of View in RelativeLayout. Next, bind events to these Views and, when the map moves, move pins using TranslateTo on RelativeLayout. To move, latitude and longitude are converted to pixels
Answers
Inside class AdressPinWithTextPlus
handle event
This does not work because BitmapDescriptorFactory.FromView (p) returns a BitmapDescriptor and this is a bitmap, and the object "p" I think is deleted by the garbage collector
I was thinking of making a group of three pins:
1. For a circle
2. For button 1
3. For button 2
However, the problem is that I can’t place them fixedly because I place them using coordinates (Lat, Lng) and when scaling the map they will visually move to each other or from each other
I think you could get the click event in custom renderer .
On iOS , customize the Annotation .
On Android , customize the info window
This solution does not fit because even annotation is converted to a bitmap
Note from the documentation at this link https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map/customized-pin
The solution was to place the map in RelativeLayout and separately add pins in the form of View in RelativeLayout. Next, bind events to these Views and, when the map moves, move pins using TranslateTo on RelativeLayout. To move, latitude and longitude are converted to pixels