private void DrawPolygon(Feature feature) { if (Preferences.Get(Constants.MapDrawPolygonsKey, true)) { XFMPolygon xfmpolygon = new XFMPolygon { StrokeWidth = 4, StrokeColor = Color.OrangeRed, FillColor = Color.OrangeRed.AddLuminosity(.1).MultiplyAlpha(0.6), }; Polygon polygon = (Polygon)feature.Geometry; foreach (LineString lineString in polygon.Coordinates) { foreach (Position pos in lineString.Coordinates) { xfmpolygon.Geopath.Add(new XFMPosition(pos.Latitude, pos.Longitude)); } } Map.MapElements.Add(xfmpolygon); } }
/// <summary> /// When map is clicked, iterates through all features in the feature list and shows the feature info menu if feature has been tapped /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnMapClicked(object sender, MapClickedEventArgs e) { FeatureList.ForEach((Feature feature) => { bool ItemHit = false; if (feature.Geometry.Type == GeoJSONType.Polygon && Preferences.Get(Constants.MapDrawPolygonsKey, true)) { Polygon polygon = (Polygon)feature.Geometry; ItemHit |= polygon.ContainsPosition(new Position(e.Position.Longitude, e.Position.Latitude)); } else if (feature.Geometry.Type == GeoJSONType.LineString && Preferences.Get(Constants.MapDrawLinesKey, true)) { LineString lineString = (LineString)feature.Geometry; ItemHit |= lineString.ContainsPosition(new Position(e.Position.Longitude, e.Position.Latitude, 0)); } if (ItemHit) { _ = DisplayFeatureActionMenuAsync(feature); } }); }