question

BrianErickson-9266 avatar image
0 Votes"
BrianErickson-9266 asked BrianErickson-9266 answered

Map Pins information window

Trying to use Xamarin Forms maps with mixed results. I get the map shown and the pins. However, none of the pins have an information window...Clicking, long clicks, touches, etc...do nothing.

Below is the xaml.

 <?xml version="1.0" encoding="utf-8" ?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
              x:Class="MapsExample.MainPage"
              Title="Shot Map">
     <ContentPage.Content>
         <StackLayout Margin="10">
             <maps:Map x:Name="map">
                 <x:Arguments>
                     <maps:MapSpan>
                         <x:Arguments>
                             <maps:Position>
                                 <x:Arguments>
                                     <x:Double>36.9628066</x:Double>
                                     <x:Double>-122.0194722</x:Double>
                                 </x:Arguments>
                             </maps:Position>
                             <x:Double>0.01</x:Double>
                             <x:Double>0.01</x:Double>
                         </x:Arguments>
                     </maps:MapSpan>
                 </x:Arguments>
                 <maps:Map.Pins>
                     <maps:Pin Label="Santa Cruz"
                           Address="The city with a boardwalk"
                           Type="Place">
                         <maps:Pin.Position>
                             <maps:Position>
                                 <x:Arguments>
                                     <x:Double>36.9628066</x:Double>
                                     <x:Double>-122.0194722</x:Double>
                                 </x:Arguments>
                             </maps:Position>
                         </maps:Pin.Position>
                     </maps:Pin>
                 </maps:Map.Pins>
             </maps:Map>
             <Button Text="Add more pins"></Button>
         </StackLayout>
     </ContentPage.Content>
 </ContentPage>

If it looks familiar, that's because it's straight from the example. My reading of the documentation leads me to believe that the info window should open when the pin is clicked on but I can't get it to work. I'm UWP only for this as doing it anywhere else would cost some money.


dotnet-xamarinwindows-uwp
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.

BrianErickson-9266 avatar image
0 Votes"
BrianErickson-9266 answered

Thanks but if I have to go to that much effort, I'd just replace the whole thing with something more full featured.

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.

KyleWang-MSFT avatar image
0 Votes"
KyleWang-MSFT answered KyleWang-MSFT commented

Hi BrianErickson-9266,

Welcome to our Microsoft Q&A platform!

It's true that Pin doesn't work as well in UWP as it does in Android or iOS. For this "Pin issue", you can submit an issue on Github.

As a workaround you can subscribe to the MarkerClicked of Pin, and obtain Address, Position and other information programmatically.

xaml:

 <Label x:Name="paddress" />
 <Label x:Name="pposition"/>
 <Label x:Name="plabel"/>
 <Label x:Name="ptype"/>
  ....
 <maps:Pin Label="Santa Cruz"
     Address="The city with a boardwalk"
     Type="Place" MarkerClicked="Pin_MarkerClicked">

xaml.cs:

 private void Pin_MarkerClicked(object sender, Xamarin.Forms.Maps.PinClickedEventArgs e)
 {
     paddress.Text = (sender as Pin).Address;
     pposition.Text = (sender as Pin).Position.Latitude.ToString() + (sender as Pin).Position.Longitude.ToString();
     plabel.Text = (sender as Pin).Label;
     ptype.Text = (sender as Pin).Type.ToString();
 }

Regards,
Kyle


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.

· 2
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.

Issue submitted. Unfortunately, your workaround doesn't help me. I already have in information programmatically, I wanted the user to be able to see it...

0 Votes 0 ·

@BrianErickson-9266 If you want to show the info in an "infowindow" rather than the labels, you can try to use AbsoluteLayout and dynamically create the "infowindow" based on the cursor position. You can refer to The Touch-Tracking Effect Implementations to get the cursor position.

0 Votes 0 ·