Thamsanqa Ngcongwane

Thamsanqa Ngcongwane

  • NA
  • 184
  • 23.5k

How to Display Pop Up when the Polygon is clicked in Xamarin

Feb 4 2020 8:28 AM
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:
  1. <StackLayout >  
  2. <maps:Map x:Name="map">  
  3. <x:Arguments>  
  4. <maps:MapSpan>  
  5. <x:Arguments>  
  6. <maps:Position>  
  7. <x:Arguments>  
  8. <x:Double>-30.241943</x:Double>  
  9. <x:Double>25.771944</x:Double>  
  10. </x:Arguments>  
  11. </maps:Position>  
  12. <x:Double>  
  13. 20  
  14. </x:Double>  
  15. <x:Double>  
  16. 20  
  17. </x:Double>  
  18. </x:Arguments>  
  19. </maps:MapSpan>  
  20. </x:Arguments>  
  21. <maps:Map.MapElements>  
  22. </maps:Map.MapElements>  
  23. </maps:Map>  
  24. </StackLayout>  
C# code for adding my Polygons to the map:
  1. foreach (var tempList in warningAlertsList)  
  2. {  
  3. string alertType = tempList.AlertType;  
  4. if (alertType == "Advisory")  
  5. {  
  6. polygon = new Polygon();  
  7. polygon.StrokeColor = Color.FromHex("ffff00");  
  8. polygon.FillColor = Color.FromHex("ffff00");  
  9. polygon.StrokeWidth = 5f;  
  10. foreach (var Poly in tempList.Polygon)  
  11. {  
  12. float Lat = float.Parse(Poly[0]);  
  13. float Long = float.Parse(Poly[1]);  
  14. polygon.Geopath.Add(new Position(Lat, Long));  
  15. }  
  16. // add to map  
  17. map.MapElements.Add(polygon);