diff --git a/src/Controls/Maps/src/HandlerImpl/Map.Impl.cs b/src/Controls/Maps/src/HandlerImpl/Map.Impl.cs index 516a108a5033..fcc1e679b0b2 100644 --- a/src/Controls/Maps/src/HandlerImpl/Map.Impl.cs +++ b/src/Controls/Maps/src/HandlerImpl/Map.Impl.cs @@ -24,6 +24,10 @@ bool IMap.ClusterClicked(IReadOnlyList pins, Location location) void IMap.LongClicked(Location location) => MapLongClicked?.Invoke(this, new MapClickedEventArgs(location)); + void IMap.ShowInfoWindow(IMapPin pin) => Handler?.Invoke(nameof(IMap.ShowInfoWindow), pin); + + void IMap.HideInfoWindow(IMapPin pin) => Handler?.Invoke(nameof(IMap.HideInfoWindow), pin); + MapSpan? IMap.VisibleRegion { get diff --git a/src/Controls/Maps/src/Map.cs b/src/Controls/Maps/src/Map.cs index d7629182d035..7b4beddeb06c 100644 --- a/src/Controls/Maps/src/Map.cs +++ b/src/Controls/Maps/src/Map.cs @@ -285,6 +285,22 @@ void PinsOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) throw new ArgumentException("Pin must have a Label to be added to a map"); } + if (e.NewItems is not null) + { + foreach (Pin pin in e.NewItems) + { + pin.Parent = this; + } + } + + if (e.OldItems is not null) + { + foreach (Pin pin in e.OldItems) + { + pin.Parent = null; + } + } + Handler?.UpdateValue(nameof(IMap.Pins)); } diff --git a/src/Controls/Maps/src/Pin.cs b/src/Controls/Maps/src/Pin.cs index b4b065cb3abd..fafeb2044580 100644 --- a/src/Controls/Maps/src/Pin.cs +++ b/src/Controls/Maps/src/Pin.cs @@ -212,6 +212,30 @@ public bool SendInfoWindowClick() return args.HideInfoWindow; } + /// + /// Shows the info window (callout) for this pin on the map. + /// + /// The pin must be added to a for this method to have an effect. + public void ShowInfoWindow() + { + if (Parent is Map map) + { + map.Handler?.Invoke(nameof(IMap.ShowInfoWindow), this); + } + } + + /// + /// Hides the info window (callout) for this pin on the map. + /// + /// The pin must be added to a for this method to have an effect. + public void HideInfoWindow() + { + if (Parent is Map map) + { + map.Handler?.Invoke(nameof(IMap.HideInfoWindow), this); + } + } + bool Equals(Pin other) { return string.Equals(Label, other.Label, StringComparison.Ordinal) && diff --git a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index f02d8f505b17..d86672f914cc 100644 --- a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -19,8 +19,10 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.HideInfoWindow() -> void Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void +Microsoft.Maui.Controls.Maps.Pin.ShowInfoWindow() -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/InfoWindowGallery.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/InfoWindowGallery.xaml new file mode 100644 index 000000000000..49b5a90b25af --- /dev/null +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/InfoWindowGallery.xaml @@ -0,0 +1,15 @@ + + + + +