question

JoeW-2266 avatar image
0 Votes"
JoeW-2266 asked JessieZhang-2116 commented

Xamarin.Forms.Maps - How to fire pin click event programmatically - Pin.SendMarkerClick Method

I have a list of map locations when I click one of them I want to zoom to the point on the map and fire a tap event so the pin located there opens its info window. I can zoom to the location on the map without an issue but I can not get the pin to click programmatically. I found the Pin.SendMarkerClick() Method but it appears to not do anything and not be implemented. Does anyone know how I can fire a pin click event without using a custom render? I don't want to have to deal with all the extra overhead of making a custom render for iOS and Android.

using System.ComponentModel;
/// <summary>To be added.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
[EditorBrowsable (EditorBrowsableState.Never)]
public bool SendMarkerClick ();

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JessieZhang-2116 avatar image
0 Votes"
JessieZhang-2116 answered JessieZhang-2116 commented

Hello,


Welcome to our Microsoft Q&A platform!

You can use Map_PinClicked to handle the PinClick event, If you set e.Handled = true, then Pin selection doesn't work automatically. All pin selection operations are delegated to you.

In the Page:

  map.PinClicked += Map_PinClicked;

 // Selected Pin changed
 map.SelectedPinChanged += SelectedPin_Changed;

 map.InfoWindowClicked += InfoWindow_Clicked;

 map.InfoWindowLongClicked += InfoWindow_LongClicked;

And then clickEvent:

 void Map_PinClicked(object sender, PinClickedEventArgs e)
     {
         e.Handled = true;
    
         uri = new Uri("http://maps.google.com/maps?daddr=" + position.Latitude + "," + position.Longitude);
         Device.OpenUri(uri);
    
     }

You can have a look at here for more information.

Best Regards,


Jessie Zhang


If the response is helpful, please click "Accept Answer" and upvote it.



Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JoeW-2266 ,I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.

0 Votes 0 ·

I was able to use the custom map render to do all the things I needed to. Thanks!

0 Votes 0 ·

Congrats, could you please post your solution so that it will help others who have simialr problems? Thanks in advance.

0 Votes 0 ·