private void GuideMap_MouseUp(object sender, MouseButtonEventArgs e) { try { if (mAdd) { e.Handled = true; Point mousePosition = e.GetPosition(this); Location pinLocation = GuideMap.ViewportPointToLocation(mousePosition); Pushpin pin = new Pushpin { Location = pinLocation }; var sight = new Sight(mUser) .SetLocation(mUser, pinLocation) .SetAddress(mUser, AddressTextBox.Text) .SetName(mUser, NameTextBox.Text); mUser.Add(sight).Commit(); GuideMap.Children.Add(pin); } } catch (AccessDeniedException) { // Обработать!!! } catch { throw; } }
private void SetMap() { Content = null; CustomMap = null; CustomMap = new GuideMap( MapSpan.FromCenterAndRadius( new Xamarin.Forms.Maps.Position(Latitude, Longitude), Distance.FromMiles(1))) { //IsShowingUser = false, HeightRequest = 100, WidthRequest = 960, VerticalOptions = LayoutOptions.FillAndExpand, MapType = MapType.Hybrid }; var pin = new ActivityPin { Pin = new Pin { Type = PinType.Place, Position = new Position(Latitude, Longitude), Label = "Xamarin San Francisco Office", Address = "394 Pacific Ave, San Francisco CA" //Label = "Photo zona", //Address = "Take photo here!" }, Url = "http://xamarin.com/about/", Image = "Markers/map_markers_z2.png", Icon = "Icons/icons_colored_z2.png" }; //pin.SelectPin += SelectPin; //CustomMap.CustomPins = new List<CustomPin> { pin, pin2, pin3, pin4, pin5 }; CustomMap.GuidePin = pin; CustomMap.Pins.Add(pin.Pin); Content = CustomMap; }