Thanks but if I have to go to that much effort, I'd just replace the whole thing with something more full featured.
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.
1 additional answer
Sort by: Most helpful
-
Kyle Wang 5,531 Reputation points Microsoft Vendor
2021-07-29T05:33:37.123+00:00 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.