Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions TK.CustomMap/TK.CustomMap.Android/TKCustomMapRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,21 @@ private void OnMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
}
}
/// <summary>
/// Show Infowindow when OpenCallout is True
/// </summary>
/// <param name="marker"></param>
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();
}
}
/// <summary>
/// When a drag of a marker ends
/// </summary>
/// <param name="sender">Event Sender</param>
Expand Down Expand Up @@ -515,6 +530,8 @@ private async void AddPin(TKCustomMapPin pin)
}

this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon));

this.OpenCallOut(this._googleMap.AddMarker(markerWithIcon));
}
/// <summary>
/// Remove a pin from the map and the internal dictionary
Expand Down
26 changes: 26 additions & 0 deletions TK.CustomMap/TK.CustomMap.iOSUnified/TKCustomMapRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ private void UpdatePins(bool firstUpdate = true)
{
i.PropertyChanged -= OnPinPropertyChanged;
this.AddPin(i);
this.OpenCallOut(i);
}

if (firstUpdate)
Expand All @@ -533,6 +534,31 @@ private void UpdatePins(bool firstUpdate = true)
this.MapFunctions.RaisePinsReady();
}
/// <summary>
/// Show Infowindow when OpenCallout is True
/// </summary>
/// <param name="pin"></param>
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<TKCustomMapAnnotation>()
.SingleOrDefault(i => i.CustomPin.Equals(pin));

if (selectedAnnotation != null)
{
this._selectedAnnotation = selectedAnnotation;
this.Map.SelectAnnotation(selectedAnnotation, true);
}
}
}
/// <summary>
/// Creates the lines
/// </summary>
private void UpdateLines(bool firstUpdate = true)
Expand Down
9 changes: 9 additions & 0 deletions TK.CustomMap/TK.CustomMap/TKCustomMapPin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,6 +76,14 @@ public bool ShowCallout
set { this.SetField(ref this._showCallout, value); }
}
/// <summary>
/// Gets/Sets open the callout without clicked marker
/// </summary>
public bool OpenShowCallout
{
get { return this._openCallout; }
set { this.SetField(ref this._openCallout, value); }
}
/// <summary>
/// Gets/Sets the position of the pin
/// </summary>
public Position Position
Expand Down