Facebook
From Reliable Macaque, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 155
  1. public async void OnMapClicked(object sender, MapClickedEventArgs e)
  2.         {
  3.             CustomPin pin = new CustomPin
  4.             {
  5.                 Type = PinType.SavedPin,
  6.                 Position = new Position(e.Position.Latitude, e.Position.Longitude),
  7.                 Label = nazwaEntry.Text,
  8.                 Address = opisEntry.Text,
  9.                 Name = "Xamarin",
  10.                 Url = "http://xamarin.com/about/",
  11.                 Question = zagadkaEntry.Text,
  12.                 Answer = odpowiedzEntry.Text
  13.             };
  14.             pin.MarkerClicked += async (s, args) =>
  15.             {
  16.                 args.HideInfoWindow = true;
  17.                 string pinName = ((CustomPin)s).Label;
  18.                 string pytanie = ((CustomPin)s).Question;
  19.                 string odpowiedz = ((CustomPin)s).Answer;
  20.                 await DisplayAlert("Pin Clicked", $"{pinName} was clicked.", "Ok");
  21.                 string result = await DisplayPromptAsync("Zagadka", $"{pytanie}", initialValue: odpowiedz, maxLength: 2, keyboard: Keyboard.Numeric);
  22.  
  23.             };
  24.             customMap.CustomPins = new List<CustomPin> { pin };
  25.             customMap.Pins.Add(pin);
  26.  
  27.  
  28.             var json = JsonConvert.SerializeObject(new { X =  pin.Position.Latitude, Y = pin.Position.Longitude });
  29.  
  30.             var content = new StringContent(json, Encoding.UTF8, "application/json");
  31.  
  32.             HttpClient client = new HttpClient();
  33.  
  34.             var result = await client.PostAsync("http://dearjean.ddns.net:44201/api/Points", content);
  35.  
  36.             if (result.StatusCode == HttpStatusCode.Created)
  37.             {
  38.                 await DisplayAlert("Komunikat", "Dodanie puntku przebiegło pomyślnie", "Anuluj");
  39.             }
  40.  
  41.  
  42.         }