I'm using WEB API to retrieve coordinates and display them as polygons on my Map. Now I want to make those Polygons(To be Clickable) when they clicked to display a pop with more information from the API.
My Xaml:
- <StackLayout >
- <maps:Map x:Name="map">
- <x:Arguments>
- <maps:MapSpan>
- <x:Arguments>
- <maps:Position>
- <x:Arguments>
- <x:Double>-30.241943x:Double>
- <x:Double>25.771944x:Double>
- x:Arguments>
- maps:Position>
- <x:Double>
- 20
- x:Double>
- <x:Double>
- 20
- x:Double>
- x:Arguments>
- maps:MapSpan>
- x:Arguments>
- <maps:Map.MapElements>
- maps:Map.MapElements>
- maps:Map>
- StackLayout>
C# code for adding my Polygons to the map:
- foreach (var tempList in warningAlertsList)
- {
- string alertType = tempList.AlertType;
- if (alertType == "Advisory")
- {
- polygon = new Polygon();
- polygon.StrokeColor = Color.FromHex("ffff00");
- polygon.FillColor = Color.FromHex("ffff00");
- polygon.StrokeWidth = 5f;
- foreach (var Poly in tempList.Polygon)
- {
- float Lat = float.Parse(Poly[0]);
- float Long = float.Parse(Poly[1]);
- polygon.Geopath.Add(new Position(Lat, Long));
- }
- // add to map
- map.MapElements.Add(polygon);
Replies
Know the answer? Post it — somebody with the same question will find it here.