protected virtual void OnTap(TapEventArgs e) { var handler = Tap; if (handler != null) { handler(this, e); } }
private async void Map_OnTap(object sender, TapEventArgs e) { Position _position = new Position(); _position = e.Position; var pin = new Pin { Type = PinType.Place, Position = e.Position, Label = " Cliked ", Address = e.Position.Latitude + " X " + e.Position.Latitude, }; // Get Coordinates Polygon as json string then Deserialize it var jsonCoordinates = new Geojson().ReadGeoJson(pin); Polygons = JsonConvert.DeserializeObject <FeatureCollection>(jsonCoordinates); if (Polygons == null) { DependencyService.Get <SnackBar>().ShowSnackBar("There is no detected area"); return; } map.Pins.Add(pin); DrawPolygon(); string result = await DisplayPromptAsync("Info", "if you want to save this area ? enter name it", "OK", "CANCEL", keyboard : Keyboard.Text); if (result != null) { Models.Polygon polygon = new Models.Polygon(); polygon.PolygonName = result; polygon.Coordinates = jsonCoordinates; polygon.Latitude = _position.Latitude; polygon.Longitude = _position.Longitude; polygonViewModel.AddPolygon(polygon); listPolygon.ItemsSource = null; listPolygon.ItemsSource = polygonViewModel.Polygons; } }