Xamarin.Forms.GoogleMaps icon indicating copy to clipboard operation
Xamarin.Forms.GoogleMaps copied to clipboard

Option to Disable Info Window on Pin Selection

Open ravero opened this issue 5 years ago • 11 comments

SUMMARY

I have a project that deals with selected pins on a specific UI the pops in the screen. I need a away to disable the InfoWindow to be presented automatically when the pin is selected.

DETAILS

The use case is when you need to track a Pin selection but doesn't want it to display the Info Window attached to the Pin. I have attached a screenshot with an example of this use case:

Simulator Screen Shot - iPhone 8 - 2019-03-19 at 12 04 39

Notice that my UI provides a panel below the screen where I can get information for the selected Pin and also do some interaction, so the InfoWindow doesn't provide any valuable addition to this specific use case, and also occupy unwanted space on the screen.

Disabling the InfoWindow pin should be implemented like an flag property that could be set directly in XAML.

PLATFORMS

  • [x] Android
  • [x] iOS
  • [ ] UWP

ravero avatar Mar 19 '19 15:03 ravero

You can handling pin behavior when clicked.

https://github.com/amay077/Xamarin.Forms.GoogleMaps/blob/e07feeee9bf49606ed0a532627b1c8f3115a467e/XFGoogleMapSample/XFGoogleMapSample/PinsPage.xaml.cs#L166-L179

Pin selection doesn't work automatically means do not open InfoWindow automatically. But be careful if you hope disable InfoWindow, you can not Map.SelectedPin = xxx always.

amay077 avatar Mar 23 '19 05:03 amay077

This is a way of doing this, but I need to keep the SelectedPin property. I've implemented this as a platform effect. Please tell me if you want to add it as option with a Pull Request.

ravero avatar Apr 01 '19 16:04 ravero

I found Google Maps SDK's behavior.

https://developers.google.com/maps/documentation/ios-sdk/marker#add_an_info_window

Clicking the marker does not display an info window if both the title and snippet properties are blank or nil.

So I have a plan to support "Disable InfoWindow" .

  1. Add UiSettings.InfoWindowEnabled as bool property
  2. In Android/iOS side PinLogic, If UiSettings.InfoWindowEnabled is false then skip update marker's Title and Snippet

https://github.com/amay077/Xamarin.Forms.GoogleMaps/blob/ba855acdd86c35d6478d701d696f61cea30c3695/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/Logics/PinLogic.cs#L78-L90

https://github.com/amay077/Xamarin.Forms.GoogleMaps/blob/ba855acdd86c35d6478d701d696f61cea30c3695/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.iOS/Logics/PinLogic.cs#L74-L84

Could you create Pull request, @ravero ?

amay077 avatar Apr 03 '19 13:04 amay077

Could you create Pull request, @ravero ?

Of course! I'll prepare this.

ravero avatar Apr 08 '19 13:04 ravero

I would also know if there is a way to disable the info window simply.

alexpdaniel avatar Sep 01 '19 07:09 alexpdaniel

I would also know if there is a way to disable the info window simply.

I just put the pin label to null and it doesn't show the InfoWindow

Kingamattack avatar Sep 02 '19 12:09 Kingamattack

I tried null and I get an error: System.ArgumentException: 'Pin must have a Label to be added to a map'

However, using String.Empty works - no error and no info window, thank you!

                Pin pin = new Pin
                {
                    Icon = BitmapDescriptorFactory.DefaultMarker(Color.Red),
                    Position = position,
                    Tag = "whatever",
                    Label = string.Empty
                };

alexpdaniel avatar Sep 03 '19 01:09 alexpdaniel

Don't you have an "Input string was not in a correct format." when you select a pin, unselect and select it again? This is what I get with string.empty

Kingamattack avatar Sep 04 '19 15:09 Kingamattack

@amay077 @ravero Any update about the PR? I'm open to help if needed

Kingamattack avatar Sep 04 '19 15:09 Kingamattack

In order to hide InfoWindow you need to create your own implementation of MapDelegate and override MarkerInfoWindow method, like that ->

        public override UIView MarkerInfoWindow(MapView mapView, Marker marker)
        {
            return new UIView();// base.MarkerInfoWindow(mapView, marker);
        }

Btw. returning null doesn't work ;)

mariuszdybala avatar Sep 18 '19 10:09 mariuszdybala

You can handling pin behavior when clicked.

https://github.com/amay077/Xamarin.Forms.GoogleMaps/blob/e07feeee9bf49606ed0a532627b1c8f3115a467e/XFGoogleMapSample/XFGoogleMapSample/PinsPage.xaml.cs#L166-L179

Pin selection doesn't work automatically means do not open InfoWindow automatically. But be careful if you hope disable InfoWindow, you can not Map.SelectedPin = xxx always.

Thank you! This does exactly what I have been wanting do to for a long time. Though a formal option to disable the info window would make it more discoverable (and preserve pin selection).

AlexKven avatar Jan 01 '20 03:01 AlexKven