Example #1
0
        /// <summary>
        /// Shows given callout
        /// </summary>
        /// <param name="callout">Callout to show</param>
        public void ShowCallout(Callout callout)
        {
            if (callout == null)
            {
                return;
            }

            // Set absolute layout constrains
            AbsoluteLayout.SetLayoutFlags(callout, AbsoluteLayoutFlags.None);

            // Add it to MapView
            if (!((AbsoluteLayout)Content).Children.Contains(callout))
            {
                Device.BeginInvokeOnMainThread(() => ((AbsoluteLayout)Content).Children.Add(callout));
            }

            // Add it to list of active Callouts
            _callouts.Add(callout);

            // When Callout is closed by close button
            callout.CalloutClosed += (s, e) => HideCallout((Callout)s);

            // Inform Callout
            callout.Show();
        }
 internal CalloutClickedEventArgs(Callout callout, Position point, Point screenPoint, int numOfTaps)
 {
     Callout     = callout;
     Point       = point;
     ScreenPoint = screenPoint;
     NumOfTaps   = numOfTaps;
 }
Example #3
0
        /// <summary>
        /// Creates a callout at the given position
        /// </summary>
        /// <returns>The callout</returns>
        /// <param name="position">Position of callout</param>
        public Callout CreateCallout(Position position)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                _callout = new Callout(_mapControl)
                {
                    Anchor = position
                };
            });

            // My interpretation (PDD): This while keeps looping until the asynchronous call
            // above has created a callout.
            // An alternative might be to avoid CreateCallout from a non-ui thread by throwing
            // early.
            while (_callout == null)
            {
                ;
            }

            var result = _callout;

            _callout = null;

            return(result);
        }
Example #4
0
        /// <summary>
        /// Creates a callout at the given position
        /// </summary>
        /// <returns>The callout</returns>
        /// <param name="position">Position of callout</param>
        public Callout CreateCallout(Position position)
        {
            if (position == null)
            {
                return(null);
            }

            Device.BeginInvokeOnMainThread(() => {
                callout = new Callout(_mapControl)
                {
                    Anchor = position,
                };
            });

            while (callout == null)
            {
                ;
            }

            var result = callout;

            callout = null;

            return(result);
        }
Example #5
0
        /// <summary>
        /// Hides given callout
        /// </summary>
        /// <param name="callout">Callout to hide</param>
        public void HideCallout(Callout callout)
        {
            if (callout == null)
            {
                return;
            }

            // Inform Callout
            callout.Hide();

            // Remove it from list of active Callouts
            _callouts.Remove(callout);

            // Remove it from MapView
            if (((AbsoluteLayout)Content).Children.Contains(callout))
            {
                Device.BeginInvokeOnMainThread(() => ((AbsoluteLayout)Content).Children.Remove(callout));
            }
        }