void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            if (e.View == null)
            {
                return;
            }
            if (!(e.View is CustomMKAnnotationView))
            {
                return;
            }

            var customView = e.View as CustomMKAnnotationView;

            customPinView = new UIView();

            if (customView.Id == "Xamarin")
            {
                customPinView.Frame = new CGRect(0, 0, 200, 84);
                var image = new UIImageView(new CGRect(0, 0, 200, 84));
                image.Image = UIImage.FromFile("Images/car_on.png");
                customPinView.AddSubview(image);
                customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
                //e.View.AddSubview(customPinView);
            }
        }
        //display the top block
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            customPinView = new UIView();
            customPinView.BackgroundColor = UIColor.White;
            customPinView.Frame           = new CGRect(0, 0, 320, 84);

            // customPins
            var tempLabel = new UILabel(new CGRect(85, 0, 320, 42))
            {
                //    Text = String.Concat("Température : ", 19)
            };

            customPinView.AddSubview(tempLabel);

            var InterestLabel = new UILabel(new CGRect(85, 42, 320, 42));

            //  InterestLabel.Text = "Lieu d'intérêt : Développement";
            // InterestLabel.Font = UIFont.ItalicSystemFontOfSize(14);
            //  customPinView.AddSubview(InterestLabel);

            customPinView.Center = new CGPoint(20, -(e.View.Frame.Height + 75));
            e.View.AddSubview(customPinView);
        }
Example #3
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;
            //customPinView = new UIView();

            //if (customView.Id != "Xamarin")
            //{

            //    //var formsView = new MKAnnotationViewRenderer();
            //    //var child = formsView.Children;
            //    //foreach (var son in child)
            //    //{
            //    //    var b = son.FindByName<View>("PinImage");
            //    //    var img = b as Image;
            //    //    img.Source = customPin.Url;
            //    //}
            //    //var rect = new CGRect(0, 0, 280, 300);
            //    //var iOSView = FormsViewToNativeiOS.ConvertFormsToNative(formsView, rect);

            //    //var viewController = new UIViewController();
            //    //viewController.Add(iOSView);
            //    //viewController.View.Frame = rect;
            //    //var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame;
            //    //customPinView.Frame = new CGRect(0, 0, 280, 300);
            //    //var image = new UIImageView(new CGRect(0, 0, 280, 300));
            //    //var data = NSData.FromUrl(url);
            //    //image.Image = UIImage.LoadFromData(data);
            //    ////image.Image = UIImage.FromFile("xamarin.png");
            //    //customPinView.AddSubview(image);
            //    //customPinView.Center = new CGPoint(0,0);
            //    //e.View.AddSubview(iOSView);
            //    var rec = new CGRect(0, 0, 280, 300);
            //    e.View.DetailCalloutAccessoryView.Frame = rec;
            //}
        }
Example #4
0
        private void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = (IdAnnot)e.View;

            _infoView = new IdView {
                id = customView.TripId
            };

            var trip = MapUtil.GetDefaultTripFile().GetTripWithTripId(customView.TripId);

            if (trip == null)
            {
                Console.WriteLine("Error! Trip not found.");
                return;
            }

            _infoView.Frame = new CGRect(0, -40, 300, 100);
            var label = new UILabel(new CGRect(0, -40, 300, 100))
            {
                Text = trip.Route.Name + " (" + trip.ListStopTimeRangeAsString() + ")"
            };

            _infoView.AddSubview(label);
            _infoView.Center = new CGPoint(0, 0);
            e.View.AddSubview(_infoView);
        }
Example #5
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            customPinView = new UIView();


            customPinView.Frame = new CoreGraphics.CGRect(0, 0, 200, 84);
            var lb = new UILabel(new CoreGraphics.CGRect(0, 0, 200, 84));

            lb.Text            = "StreetView";
            lb.BackgroundColor = UIColor.White;
            //     UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(TapThat);
            // lb.GestureRecognizers=new UIGestureRecognizer()
            //image.Image = UIImage.FromFile("xamarin.png");
            customPinView.AddSubview(lb);
            customPinView.Center = new CoreGraphics.CGPoint(0, -(e.View.Frame.Height + 75));
            e.View.AddSubview(customPinView);

            //if (customView.Id == "Xamarin")
            //{
            //customPinView.Frame = new CoreGraphics.CGRect(0, 0, 200, 84);
            //var image = new UIImageView(new CoreGraphics.CGRect(0, 0, 200, 84));
            //image.Image = UIImage.FromFile("xamarin.png");
            //customPinView.AddSubview(image);
            //customPinView.Center = new CoreGraphics.CGPoint(0, -(e.View.Frame.Height + 75));
            //e.View.AddSubview(customPinView);
            //}
        }
Example #6
0
 void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (e.View is WCalloutView)
     {
         MapView.RemoveAnnotation((e.View as WCalloutView).Annotation);
     }
 }
Example #7
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            customPinView = new UIView();
            // TODO Do something if you want to add extra information on the annotation view. Example: a logo or URL image
        }
Example #8
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            // centralise map and freeze map updates
            MapPage.CentraliseMap(new Position(e.View.Annotation.Coordinate.Latitude,
                                               e.View.Annotation.Coordinate.Longitude));
            MapPage.SetFreezeMap(true);

            // create custom callout with bus info
            // set background for callout
            var frame = new CGRect(0, 0, 200, 84);

            customPinView = new UIView {
                Frame           = frame,
                BackgroundColor = new UIColor(0.8f, 0.8f, 0.8f, 0.3f),
                Center          = new CGPoint(0, -(e.View.Frame.Height + 20))
            };
            customPinView.Layer.BorderColor  = new CGColor(0, 0, 0, 50);
            customPinView.Layer.BorderWidth  = 1f;
            customPinView.Layer.CornerRadius = 2f;

            // add text info
            customPinView.Add(new UILabel {
                Frame = frame,
                // title - label, subtitle - address (in xamarin.forms.maps)
                Text                      = e.View.Annotation.GetTitle() + "\n" + e.View.Annotation.GetSubtitle(),
                Font                      = UIFont.FromName("Helvetica", 12f),
                TextAlignment             = UITextAlignment.Left,
                AdjustsFontSizeToFitWidth = true,
                LineBreakMode             = UILineBreakMode.WordWrap,
                Lines                     = 0
            });
            e.View.AddSubview(customPinView);
        }
 private void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     //CustomMKAnnotationView customView = e.View as CustomMKAnnotationView;
     //if (!string.IsNullOrWhiteSpace(customView.Url))
     //{
     //    UIApplication.SharedApplication.OpenUrl(new Foundation.NSUrl(customView.Url));
     //}
 }
Example #10
0
        private void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            _customPinView = new UIView();
            e.View.AddSubview(_customPinView);

            var anotation = customView.Annotation as MKAnnotation;

            var selectedPin = GetCustomPin(anotation);

            if (!_customPins.Any(p => p.Type == AnnotationType.From))
            {
                var fromPin = _customPins.FirstOrDefault((p => p.Id == selectedPin.Id));
                fromPin.Type           = AnnotationType.From;
                _customMap.From        = fromPin;
                customView.Image       = FromImage;
                _customMap.SelectedPin = fromPin;
            }
            else
            {
                var fromPin = _customPins.FirstOrDefault((p => p.Type == AnnotationType.From));

                if (fromPin != null &&
                    !_customPins.Any(p => p.Type == AnnotationType.To) &&
                    fromPin.Id == selectedPin.Id)
                {
                    fromPin.Type           = AnnotationType.Normal;
                    _customMap.From        = null;
                    customView.Image       = NormalImage;
                    _customMap.SelectedPin = null;
                }
                else
                {
                    if (_customPins.Any(p => p.Type == AnnotationType.From) &&
                        !_customPins.Any(p => p.Type == AnnotationType.To))
                    {
                        var toPin = _customPins.FirstOrDefault((p => p.Id == selectedPin.Id));
                        toPin.Type             = AnnotationType.To;
                        _customMap.To          = toPin;
                        customView.Image       = ToImage;
                        _customMap.SelectedPin = toPin;
                    }
                    else
                    {
                        var to = _customPins.FirstOrDefault(p => p.Type == AnnotationType.To);

                        if (to != null)
                        {
                            to.Type                = AnnotationType.Normal;
                            _customMap.To          = null;
                            customView.Image       = NormalImage;
                            _customMap.SelectedPin = null;
                        }
                    }
                }
            }
        }
Example #11
0
 void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (!e.View.Selected)
     {
         stack.RemoveFromSuperview();
         stack.Dispose();
         stack = null;
     }
 }
Example #12
0
 void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (!e.View.Selected)
     {
         customPinView.RemoveFromSuperview();
         customPinView.Dispose();
         customPinView = null;
     }
 }
Example #13
0
 public virtual void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     _lalitude  = e.View.Annotation.Coordinate.Latitude;
     _longitude = e.View.Annotation.Coordinate.Longitude;
     MapViewIOS.AddAnnotations(new MKPointAnnotation()
     {
         Coordinate = new CLLocationCoordinate2D(_lalitude, _longitude)
     });
 }
Example #14
0
 private void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (e.View.Selected)
     {
         return;
     }
     _infoView.RemoveFromSuperview();
     _infoView.Dispose();
     _infoView = null;
 }
Example #15
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            customMap.OnSelect = true;
            var pintoadd = new PinModel();

            var customView = e.View as CustomMKAnnotationView;

            foreach (X.Models.PinModel pin in customMap.Pins)
            {
                if (pin.Id.Equals(customView.Id))
                {
                    pintoadd = pin;
                }
            }
            //var newPin = new Xamarin.Forms.Maps.Position(pintoadd.Position.Latitude, pintoadd.Position.Longitude);
            var dMeters = 0.3 * customMap.VisibleRegion.Radius.Kilometers;
            var dLat    = dMeters / 111.11;

            Console.WriteLine("delta latitude: {0}", dLat);
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(pintoadd.Position.Latitude - dLat, pintoadd.Position.Longitude), customMap.VisibleRegion.Radius));
            customPinView = new UIView();
            customMap.Pins.Clear();
            if (pintoadd.Label == null)
            {
                pintoadd.Label = "Scuttle";
            }
            customMap.Pins.Add(pintoadd);
            customMap.CustomPin.Clear();
            customMap.CustomPin.Add(pintoadd);
            customMap.showInfoBox(customView.Id);
            //if (customView.emojis != null)
            //{
            //    customPinView.Frame = new CGRect(0, -100, 40, 40);
            //    var image = new UIImageView(new CGRect(0, 0, 20, 20));
            //    image.Image = UIImage.FromFile(customView.emojis[0]);
            //    var image2 = new UIImageView(new CGRect(30, 30, 25, 25));
            //    image2.Image = UIImage.FromFile(customView.emojis[1]);
            //    var image3 = new UIImageView(new CGRect(0, 60, 30, 30));
            //    image3.Image = UIImage.FromFile(customView.emojis[2]);
            //    var image4 = new UIImageView(new CGRect(15, 90, 35, 35));
            //    image4.Image = UIImage.FromFile(customView.emojis[3]);
            //    customPinView.AddSubview(image);
            //    customPinView.AddSubview(image2);
            //    customPinView.AddSubview(image3);
            //    customPinView.AddSubview(image4);
            //    customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
            //    e.View.AddSubview(customPinView);
            //}
            //else
            //{
            //    Console.WriteLine("No emojis");
            //}
        }
        private void DidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var pushpinAnnotation = e.View as CustomPinAnnotationView;

            if (pushpinAnnotation == null)
            {
                // We only care about Incident annotations
                return;
            }

            OnPushpinSelected(pushpinAnnotation.Pushpin);
        }
        void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKPinAnnotationView;

            if (!e.View.Selected)
            {
                //customPinView.RemoveFromSuperview();
                customView.Selected = false;
                customView.Dispose();
                customView = null;
            }
        }
Example #18
0
        private void DidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var incidentAnnotation = e.View as IncidentAnnotationView;

            if (incidentAnnotation == null)
            {
                // We only care about Incident annotations
                return;
            }

            OnIncidentSelected(incidentAnnotation.Incident);
        }
Example #19
0
 void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (e.View is WPinAnnotationView)
     {
         var calloutAnnotation = new WCalloutAnnotation {
             Coordinate         = e.View.Annotation.Coordinate,
             OriginalAnnotation = e.View.Annotation
         };
         MapView.AddAnnotation(calloutAnnotation);
         MapView.SelectAnnotation(calloutAnnotation, true);
         CurrentCalloutView = null;
     }
 }
Example #20
0
        private void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            if (e.View is CustomMKAnnotationView customView)
            {
                var customPin = _customPins.FirstOrDefault(p => p.Identifier.ToString() == customView.Id);
                if (customPin == null)
                {
                    return;
                }

                _formsMap.SelectPin(customPin);
            }
        }
Example #21
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            _customPinView = new UIView();

            if (customView.Id == "Xamarin")
            {
                _customPinView.Frame  = new CGRect(0, 0, 200, 84);
                _customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
                e.View.AddSubview(_customPinView);
            }
        }
Example #22
0
 void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (!e.View.Selected)
     {
         if (CustomPinView == null)
         {
             return;
         }
         CustomPinView.RemoveFromSuperview();
         CustomPinView.Dispose();
         ExecuteCommand();
         CustomPinView = null;
     }
 }
		void OnDidSelectAnnotationView (object sender, MKAnnotationViewEventArgs e)
		{
			var customView = e.View as CustomMKPinAnnotationView;
			customPinView = new UIView ();

			if (customView.Id == "Xamarin") {
				customPinView.Frame = new CGRect (0, 0, 200, 84);
				var image = new UIImageView (new CGRect (0, 0, 200, 84));
				image.Image = UIImage.FromFile ("xamarin.png");
				customPinView.AddSubview (image);
				customPinView.Center = new CGPoint (0, -(e.View.Frame.Height + 75));
				e.View.AddSubview (customPinView);
			}
		}
Example #24
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            customPinView       = new UIView();
            customPinView.Frame = new CGRect(0, 0, 200, 100);
            var label = new UILabel();

            label.Frame = new CGRect(0, 0, 200, 100);
            label.Text  = String.Format(customView.Name + "\n" + customView.PinDescription + "\nRating: " + customView.Rating);
            customPinView.AddSubview(label);
            customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 10));
            e.View.AddSubview(customPinView);
        }
Example #25
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            customPinView = new UIView();

            var customPin = GetCustomPin(e.View.Annotation);

            customPinView.Frame = new CGRect(0, 0, 200, 84);
            var image = new UIImageView(new CGRect(0, 0, 200, 84));

            image.Image = FromUrl(customPin.Url);
            customPinView.AddSubview(image);
            customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
            e.View.AddSubview(customPinView);
        }
Example #26
0
        async void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            if (!e.View.Selected)
            {
                //Handle Helicopters and Hospitals
                var customView = e.View as CustomMKAnnotationView;
                if (customView.Url == null)
                {
                    return;
                }

                string[] customViewUrl = customView.Url.Split(',');
                if (customViewUrl[0].Equals("Heli"))
                {
                    return;
                }

                customPinView.RemoveFromSuperview();
                customPinView.Dispose();
                customPinView = null;

                removeOverlays();
                ClearAllReceivers();


                var window = UIApplication.SharedApplication.KeyWindow;
                var rootVC = window.RootViewController;
                if (rootVC is BottomSheetViewController)
                {
                    BottomSheetViewController bottomSheet = (BottomSheetViewController)rootVC;
                    await bottomSheet.closeMenu();

                    bottomSheet.StopTimers();
                    bottomSheet.Dispose();
                    bottomSheet = null;
                    window.RootViewController = rootVC.ChildViewControllers[0];
                }
                else
                {
                    PotentialMatchesBottomSheetViewController matchesSheet = (PotentialMatchesBottomSheetViewController)rootVC;
                    await matchesSheet.closeMenu();

                    matchesSheet.StopTimers();
                    matchesSheet.Dispose();
                    matchesSheet = null;
                    window.RootViewController = rootVC.ChildViewControllers[0];
                }
            }
        }
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            customPinView = new UIView( );

            customPinView.Frame = new CGRect(0, 0, 300, 200);
            var image = new UIImageView(new CGRect(0, 0, 300, 200));

            image.Image       = ImageFromUrl(customView.Residence.ImageUrls[0]);
            image.ContentMode = UIViewContentMode.ScaleAspectFit;
            customPinView.AddSubview(image);
            customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 145));
            e.View.AddSubview(customPinView);
        }
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var customView = e.View as CustomMKAnnotationView;

            customPinView = new UIView();
            if (customView.Id == "xamarin")
            {
                customPinView.Frame = new CGRect(0, 0, 200, 84);
                //var image = new UIImageView(new CGRect(0, 0, 200, 84));
                //image.Image = UIImage.FromFile("xamarin.png");
                //customPinView.AddSubview(image);
                customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
                e.View.AddSubview(customPinView);
            }
        }
        private void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            CustomMKAnnotationView customView = e.View as CustomMKAnnotationView;
            //customPinView = new UIView();

            //if (customView.Name.Equals("Xamarin"))
            //{
            //    customPinView.Frame = new CGRect(0, 0, 200, 84);
            //    var image = new UIImageView(new CGRect(0, 0, 200, 84));
            //    image.Image = UIImage.FromFile("xamarin.png");
            //    customPinView.AddSubview(image);
            //    customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
            //    e.View.AddSubview(customPinView);
            //}
        }
Example #30
0
        void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            if (!e.View.Selected && !touchOnCustonPinView)
            {
                customPinView.RemoveFromSuperview();
                customPinView.Dispose();
                customPinView = null;
            }
            else if (touchOnCustonPinView && !e.View.Selected)
            {
                nativeMap.SelectAnnotation(e.View.Annotation, false);
            }

            touchOnCustonPinView = false;
        }
Example #31
0
        void MkMapViewOnAnnotationViewSelected(object sender, MKAnnotationViewEventArgs e)
        {
            var annotation = e.View.Annotation;
            var pin        = GetPinForAnnotation(annotation);

            if (pin != null)
            {
                // SendMarkerClick() returns the value of PinClickedEventArgs.HideInfoWindow
                // Hide the info window by deselecting the annotation
                bool deselect = pin.SendMarkerClick();
                if (deselect)
                {
                    ((MKMapView)Control).DeselectAnnotation(annotation, false);
                }
            }
        }
        /// <summary>
        /// Purpose: Change the zoom factor of the map when the user clicks on the annotation and center teh camera on the annotation
        /// Example: *50000 -> *5000
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">EventArgs.</param>
        private void MapView_DidSelectAnnotationView (object sender, MKAnnotationViewEventArgs e) 
        {

            var sampleAnnotation = e.View.Annotation as MKPointAnnotation;

            if (sampleAnnotation != null) 
            {              

                //demo accessing the coordinate of the selected annotation to zoom in on it
                if (_zoomFactor == 100000)
                    _zoomFactor = 50000;
                else if(_zoomFactor == 50000)
                    _zoomFactor = 5000;
                else if (_zoomFactor == 5000)
                    _zoomFactor = 500;
                else
                    _zoomFactor = 50000;

                MapView.Region = MKCoordinateRegion.FromDistance (sampleAnnotation.Coordinate, _zoomFactor, _zoomFactor);                    

            }

        }
		void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e)
		{
			if (!e.View.Selected)
			{
				customPinView.RemoveFromSuperview();
				customPinView.Dispose();
				customPinView = null;
			}
		}
        /// <summary>
        /// When an annotation view got selected
        /// </summary>
        /// <param name="sender">Event Sender</param>
        /// <param name="e">Event Arguments</param>
        private void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            var pin = e.View.Annotation as TKCustomMapAnnotation;
            if(pin == null) return;

            this._selectedAnnotation = e.View.Annotation;
            this.FormsMap.SelectedPin = pin.CustomPin;
            
            if (this.FormsMap.PinSelectedCommand != null && this.FormsMap.PinSelectedCommand.CanExecute(pin.CustomPin))
            {
                this.FormsMap.PinSelectedCommand.Execute(pin.CustomPin);
            }
        }