Exemplo n.º 1
0
        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);
        }
        protected override void CreateHeatMapIfNeeded()
        {
            if (_heatMapLayer == null)
            {
                _heatMapLayer = new HeatMapLayer(Xamarin.Forms.Forms.Context, FormsMap)
                {
                    ParentMap = _googleMap,
                    Radius    = FormsMap.Radius,
                    Intensity = FormsMap.Intensity,
                    Locations = FormsMap.Locations?.Select(CoordinateConverter.ConvertToNative)
                };

                FormsMap.PropertyChanged -= FormsMapPropertyChanged;
                FormsMap.PropertyChanged += FormsMapPropertyChanged;

                _nativeMap.AddView(_heatMapLayer);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// When tapped, show a popup bubble
        /// </summary>
        protected override bool OnTap(int index)
        {
            if (mapView != null)
            {
                if (mapView.ChildCount > 0)
                {
                    mapView.RemoveViewAt(0);
                }
                View           bubbleView = null;
                LayoutInflater inflator   = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
                bubbleView = inflator.Inflate(Resource.Layout.MapOverlayLayout, null);
                bubbleView.LayoutParameters = new MapView.LayoutParams(MapView.LayoutParams.WrapContent, MapView.LayoutParams.WrapContent, item.Point, -2, -25, MapView.LayoutParams.BottomCenter);
                var button        = bubbleView.FindViewById <ImageButton> (Resource.Id.mapOverlayGetDirections);
                var address       = bubbleView.FindViewById <TextView> (Resource.Id.mapOverlayAddress);
                var image         = bubbleView.FindViewById <ImageView> (Resource.Id.mapOverlayDivider);
                var overlayLayout = bubbleView.FindViewById <LinearLayout> (Resource.Id.overlayDirectionsLayout);
                address.Text = item.Snippet;

                image.Visibility  = getDirections ? ViewStates.Visible : ViewStates.Gone;
                button.Visibility = getDirections ? ViewStates.Visible : ViewStates.Gone;
                if (getDirections)
                {
                    button.Click += (sender, e) => {
                        var intent = new Intent(Intent.ActionView,
                                                Uri.Parse(string.Format(intentURI, string.Empty, item.Snippet)));
                        context.StartActivity(intent);
                    };
                }

                if (!getDirections)
                {
                    overlayLayout.Click += (sender, e) => {
                        var intent = new Intent(context, typeof(SummaryActivity));
                        assignmentViewModel.SelectedAssignment = assignmentViewModel.Assignments [AssignmentIndex];
                        context.StartActivity(intent);
                    };
                }

                mapView.AddView(bubbleView);
                mapView.Controller.AnimateTo(item.Point);
                mapView.Controller.SetZoom(10);
            }
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Enabling my location and setting active assignment
        /// </summary>
        protected override void OnResume()
        {
            base.OnResume();

            UpdateLocations();
            myLocation.EnableMyLocation();
            var tabActivity = (AssignmentTabActivity)Parent;

            AssignmentTabActivity.MapDataWrapper mapDataWrapper = null;
            if (tabActivity != null)
            {
                mapDataWrapper = tabActivity.MapData;
            }

            if (mapDataWrapper != null)
            {
                mapView.Controller.SetZoom(mapDataWrapper.Zoom);
                mapView.Controller.AnimateTo(mapDataWrapper.OverlayPoint);
                mapView.AddView(mapDataWrapper.OverlayBubble);
            }
            else
            {
                myLocation.RunOnFirstFix(() => {
                    mapView.Controller.AnimateTo(myLocation.MyLocation);
                });
                mapView.Controller.SetZoom(5);
            }

            if (assignmentViewModel.ActiveAssignment != null)
            {
                SetAssignment(true);
            }
            else
            {
                SetAssignment(false);
            }

            var dialog = new AlertDialog.Builder(this)
                         .SetTitle("Google Maps")
                         .SetMessage(Resources.GetString(Resource.String.GoogleMapsKeyIssue))
                         .SetPositiveButton("Ok", (sender, e) => { })
                         .Show();
        }
 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);
        }