amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 346 forks source link

Custom Callout/InfoWindow #699

Open mdmota opened 4 years ago

mdmota commented 4 years ago

With this plugin is it possible to customize the Callout/InfoWindow? I need to create a custom callout with a button that triggers an event when it is clicked.

I got it on android, but not on ios work.

See reference:

stefancvetkovic commented 4 years ago

hey @mdmota did you solve this? I have the same question

mdmota commented 4 years ago

hey @mdmota did you solve this? I have the same question

Yes, In the On DidSelectAnnotationView method I have replaced the image of the marke with a larger image with a white area. So I managed to get the click in that area.

mdmota commented 4 years ago

`void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e) { try { CustomMKAnnotationView customView = e.View as CustomMKAnnotationView; customView.Image = UIImage.FromFile("markerIconClicked.png"); customPinView = new UIView();

            CustomPin customPin = customPins.FirstOrDefault(p => p.Label.Equals(customView.ReuseIdentifier));

            Action action = () => {
                NavegaParaUnidade(customPin);
                if (customPinView != null)
                {
                    customPinView.RemoveFromSuperview();
                    customPinView.Dispose();
                    customPinView = null;
                }

            };

            ges = new UITapGestureRecognizer(action);

            customPinView.Frame = new CGRect(0, 0, 200, 100);
            customPinView.AddSubview(CriaView(customPin));
            customPinView.Center = new CGPoint(90, -8);
            customView.AddGestureRecognizer(ges);
            customView.AddSubview(customPinView);

        }
        catch (Exception)
        {
            //TODO
        }

    }`