void AddButtonToMap (MapView map) { var mapButton = new Button (this){Text = "Go to Maui"}; var layoutParams = new MapView.LayoutParams (100, 50, new GeoPoint ((int)42.374260E6, (int)-71.120824E6), MapView.LayoutParams.TopLeft); mapButton.Click += (sender, e) => { map.Controller.SetCenter (new GeoPoint ((int)20.866667E6, (int)-156.500556E6)); }; map.AddView (mapButton, layoutParams); }
void AddButtonToMap(MapView map) { var mapButton = new Button(this) { Text = "Go to Maui" }; var layoutParams = new MapView.LayoutParams(100, 50, new GeoPoint((int)42.374260E6, (int)-71.120824E6), MapView.LayoutParams.TopLeft); mapButton.Click += (sender, e) => { map.Controller.SetCenter(new GeoPoint((int)20.866667E6, (int)-156.500556E6)); }; map.AddView(mapButton, layoutParams); }
/** * Creates and displays the balloon overlay by recycling the current * balloon or by inflating it from xml. * @return true if the balloon was recycled false otherwise */ private bool CreateAndDisplayBalloonOverlay() { bool isRecycled; if (_balloonView == null) { _balloonView = CreateBalloonOverlayView(); _clickRegion = (View)_balloonView.FindViewById(Resource.Id.balloon_inner_layout); _clickRegion.SetOnTouchListener(this); _closeRegion = (View)_balloonView.FindViewById(Resource.Id.balloon_close); if (_closeRegion != null) { if (!_showClose) { _closeRegion.Visibility = ViewStates.Gone; } else { _closeRegion.SetOnClickListener(this); } } if (_showDisclosure && !_showClose) { View v = _balloonView.FindViewById(Resource.Id.balloon_disclosure); if (v != null) { v.Visibility = ViewStates.Visible; } } isRecycled = false; } else { isRecycled = true; } _balloonView.Visibility = ViewStates.Gone; List <Overlay> mapOverlays = _mapView.Overlays.ToList(); if (mapOverlays.Count > 1) { HideOtherBalloons(mapOverlays); } if (_currentFocusedItem != null) { _balloonView.SetData(_currentFocusedItem); } GeoPoint point = _currentFocusedItem.Point; MapView.LayoutParams layoutParams = new MapView.LayoutParams( MapView.LayoutParams.WrapContent, MapView.LayoutParams.WrapContent, point, MapView.LayoutParams.BottomCenter); layoutParams.Mode = MapView.LayoutParams.ModeMap; _balloonView.Visibility = ViewStates.Visible; if (isRecycled) { _balloonView.LayoutParameters = layoutParams; } else { _mapView.AddView(_balloonView, layoutParams); } return(isRecycled); }