diff --git a/TK.CustomMap/TK.CustomMap.Android/TKCustomMapRenderer.cs b/TK.CustomMap/TK.CustomMap.Android/TKCustomMapRenderer.cs index 13ea8d0..ce06a1c 100644 --- a/TK.CustomMap/TK.CustomMap.Android/TKCustomMapRenderer.cs +++ b/TK.CustomMap/TK.CustomMap.Android/TKCustomMapRenderer.cs @@ -261,6 +261,21 @@ private void OnMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e) } } /// + /// Show Infowindow when OpenCallout is True + /// + /// + private void OpenCallOut(Marker marker) + { + if (this.FormsMap == null) return; + var item = this._markers.SingleOrDefault(i => i.Value.Id.Equals(marker.Id)); + if (item.Key == null) return; + + if (item.Key.ShowCallout) + { + item.Value.ShowInfoWindow(); + } + } + /// /// When a drag of a marker ends /// /// Event Sender @@ -515,6 +530,8 @@ private async void AddPin(TKCustomMapPin pin) } this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon)); + + this.OpenCallOut(this._googleMap.AddMarker(markerWithIcon)); } /// /// Remove a pin from the map and the internal dictionary diff --git a/TK.CustomMap/TK.CustomMap.iOSUnified/TKCustomMapRenderer.cs b/TK.CustomMap/TK.CustomMap.iOSUnified/TKCustomMapRenderer.cs index 6aadc3a..bf14d2b 100644 --- a/TK.CustomMap/TK.CustomMap.iOSUnified/TKCustomMapRenderer.cs +++ b/TK.CustomMap/TK.CustomMap.iOSUnified/TKCustomMapRenderer.cs @@ -520,6 +520,7 @@ private void UpdatePins(bool firstUpdate = true) { i.PropertyChanged -= OnPinPropertyChanged; this.AddPin(i); + this.OpenCallOut(i); } if (firstUpdate) @@ -533,6 +534,31 @@ private void UpdatePins(bool firstUpdate = true) this.MapFunctions.RaisePinsReady(); } /// + /// Show Infowindow when OpenCallout is True + /// + /// + private void OpenCallOut(TKCustomMapPin pin) + { + MKAnnotationViewEventArgs e; + if (pin == null) return; + + this._selectedAnnotation = new TKCustomMapAnnotation(pin); + this.FormsMap.SelectedPin = pin; + + if (pin.OpenCallout) + { + var selectedAnnotation = this.Map.Annotations + .OfType() + .SingleOrDefault(i => i.CustomPin.Equals(pin)); + + if (selectedAnnotation != null) + { + this._selectedAnnotation = selectedAnnotation; + this.Map.SelectAnnotation(selectedAnnotation, true); + } + } + } + /// /// Creates the lines /// private void UpdateLines(bool firstUpdate = true) diff --git a/TK.CustomMap/TK.CustomMap/TKCustomMapPin.cs b/TK.CustomMap/TK.CustomMap/TKCustomMapPin.cs index ead3779..2d0bd40 100644 --- a/TK.CustomMap/TK.CustomMap/TKCustomMapPin.cs +++ b/TK.CustomMap/TK.CustomMap/TKCustomMapPin.cs @@ -13,6 +13,7 @@ public class TKCustomMapPin : TKBase private string _title; private string _subtitle; private bool _showCallout; + private bool _openCallout; private Position _position; private ImageSource _image; private bool _isDraggable; @@ -75,6 +76,14 @@ public bool ShowCallout set { this.SetField(ref this._showCallout, value); } } /// + /// Gets/Sets open the callout without clicked marker + /// + public bool OpenShowCallout + { + get { return this._openCallout; } + set { this.SetField(ref this._openCallout, value); } + } + /// /// Gets/Sets the position of the pin /// public Position Position