Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Geodesic polylines option #773

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected override NativePolyline CreateNativeItem(Polyline outerItem)
foreach (var p in outerItem.Positions)
opts.Add(new LatLng(p.Latitude, p.Longitude));

opts.Geodesic(outerItem.IsGeodesic);
opts.InvokeWidth(outerItem.StrokeWidth * this.ScaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps)
opts.InvokeColor(outerItem.StrokeColor.ToAndroid());
opts.Clickable(outerItem.IsClickable);
Expand Down Expand Up @@ -105,6 +106,11 @@ internal override void OnUpdateZIndex(Polyline outerItem, NativePolyline nativeI
{
nativeItem.ZIndex = outerItem.ZIndex;
}

internal override void OnUpdateIsGeodesic(Polyline outerItem, NativePolyline nativeItem)
{
nativeItem.Geodesic = outerItem.IsGeodesic;
}
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
Expand Down Expand Up @@ -109,5 +109,9 @@ internal override void OnUpdateZIndex(Polyline outerItem, MapPolyline nativeItem
{
nativeItem.ZIndex = outerItem.ZIndex;
}

internal override void OnUpdateIsGeodesic(Polyline outerItem, MapPolyline nativeItem)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
Expand Down Expand Up @@ -44,6 +44,7 @@ protected override NativePolyline CreateNativeItem(Polyline outerItem)
nativePolyline.StrokeColor = outerItem.StrokeColor.ToUIColor();
nativePolyline.Tappable = outerItem.IsClickable;
nativePolyline.ZIndex = outerItem.ZIndex;
nativePolyline.Geodesic = outerItem.IsGeodesic;

outerItem.NativeObject = nativePolyline;
nativePolyline.Map = NativeMap;
Expand Down Expand Up @@ -90,6 +91,11 @@ internal override void OnUpdateZIndex(Polyline outerItem, NativePolyline nativeI
{
nativeItem.ZIndex = outerItem.ZIndex;
}

internal override void OnUpdateIsGeodesic(Polyline outerItem, NativePolyline nativeItem)
{
nativeItem.Geodesic = outerItem.IsGeodesic;
}
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;

Expand All @@ -21,11 +21,13 @@ protected override void OnItemPropertyChanged(object sender, PropertyChangedEven
else if (e.PropertyName == Polyline.StrokeColorProperty.PropertyName) OnUpdateStrokeColor(outerItem, nativeItem);
else if (e.PropertyName == Polyline.StrokeWidthProperty.PropertyName) OnUpdateStrokeWidth(outerItem, nativeItem);
else if (e.PropertyName == Polyline.ZIndexProperty.PropertyName) OnUpdateZIndex(outerItem, nativeItem);
else if (e.PropertyName == Polyline.IsGeodesicProperty.PropertyName) OnUpdateIsGeodesic(outerItem, nativeItem);
}

internal abstract void OnUpdateIsClickable(Polyline outerItem, TNative nativeItem);
internal abstract void OnUpdateStrokeColor(Polyline outerItem, TNative nativeItem);
internal abstract void OnUpdateStrokeWidth(Polyline outerItem, TNative nativeItem);
internal abstract void OnUpdateZIndex(Polyline outerItem, TNative nativeItem);
internal abstract void OnUpdateIsGeodesic(Polyline outerItem, TNative nativeItem);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
Expand All @@ -16,6 +16,7 @@ void HandleAction(GoogleMaps.Polygon arg1, NotifyCollectionChangedEventArgs arg2
public static readonly BindableProperty StrokeColorProperty = BindableProperty.Create(nameof(StrokeColor), typeof(Color), typeof(Polyline), Color.Blue);
public static readonly BindableProperty IsClickableProperty = BindableProperty.Create(nameof(IsClickable), typeof(bool), typeof(Polyline), false);
public static readonly BindableProperty ZIndexProperty = BindableProperty.Create(nameof(ZIndex), typeof(int), typeof(Polyline), 0);
public static readonly BindableProperty IsGeodesicProperty = BindableProperty.Create(nameof(IsGeodesic), typeof(bool), typeof(Polyline), false);

private readonly ObservableCollection<Position> _positions = new ObservableCollection<Position>();

Expand Down Expand Up @@ -45,6 +46,12 @@ public int ZIndex
set { SetValue(ZIndexProperty, value); }
}

public bool IsGeodesic
{
get { return (bool)GetValue(IsGeodesicProperty); }
set { SetValue(IsGeodesicProperty, value); }
}

public IList<Position> Positions
{
get { return _positions; }
Expand Down