Skip to content

Commit

Permalink
Merge pull request #47 from amay077/develop
Browse files Browse the repository at this point in the history
v1.5.0
  • Loading branch information
amay077 authored Jul 21, 2016
2 parents d41ecb0 + be8dfd6 commit b0a62ff
Show file tree
Hide file tree
Showing 28 changed files with 377 additions and 65 deletions.
4 changes: 2 additions & 2 deletions XFGoogleMapSample/Droid/XFGoogleMapSample.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
<HintPath>..\packages\Xamarin.GooglePlayServices.Maps.29.0.0.1\lib\MonoAndroid41\Xamarin.GooglePlayServices.Maps.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps.Android">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.4.1\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.Android.dll</HintPath>
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.5.0\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.Android.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.4.1\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.5.0\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion XFGoogleMapSample/Droid/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Forms" version="2.3.0.49" targetFramework="MonoAndroid60" />
<package id="Xamarin.Forms.GoogleMaps" version="1.4.1" targetFramework="MonoAndroid60" />
<package id="Xamarin.Forms.GoogleMaps" version="1.5.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0.1" targetFramework="MonoAndroid60" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0.1" targetFramework="MonoAndroid60" />
<package id="Xamarin.GooglePlayServices.Maps" version="29.0.0.1" targetFramework="MonoAndroid60" />
Expand Down
16 changes: 16 additions & 0 deletions XFGoogleMapSample/XFGoogleMapSample/BasicMapPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ public BasicMapPage()
};
switchIsShowingUser.IsToggled = map.IsShowingUser;

// Map Clicked
map.MapClicked += (sender, e) =>
{
var lat = e.Point.Latitude.ToString("0.000");
var lng = e.Point.Longitude.ToString("0.000");
this.DisplayAlert("MapClicked", $"{lat}/{lng}", "CLOSE");
};

// Map Long clicked
map.MapLongClicked += (sender, e) =>
{
var lat = e.Point.Latitude.ToString("0.000");
var lng = e.Point.Longitude.ToString("0.000");
this.DisplayAlert("MapLongClicked", $"{lat}/{lng}", "CLOSE");
};

// Geocode
buttonGeocode.Clicked += async (sender, e) =>
{
Expand Down
59 changes: 39 additions & 20 deletions XFGoogleMapSample/XFGoogleMapSample/CustomPinsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,84 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>


<Switch x:Name="switchPinColor"
VerticalOptions="Center"
Grid.Row="1"
Grid.Column="1"/>
Grid.Row="0"
Grid.Column="0"/>

<Label Text="Default:"
VerticalTextAlignment="Center"
HorizontalTextAlignment="End"
Grid.Row="1"
Grid.Column="2"/>
Grid.Row="0"
Grid.Column="1"/>

<Picker x:Name="buttonPinColor"
Grid.Row="1"
Grid.Column="3"/>
Grid.Row="0"
Grid.Column="2"/>

<Switch x:Name="switchPinBundle"
VerticalOptions="Center"
Grid.Row="2"
Grid.Column="1"/>
Grid.Row="1"
Grid.Column="0"/>

<Label Text="Bundle:"
VerticalTextAlignment="Center"
HorizontalTextAlignment="End"
Grid.Row="2"
Grid.Column="2"/>
Grid.Row="1"
Grid.Column="1"/>

<Picker x:Name="buttonPinBundle"
Grid.Row="2"
Grid.Column="3"/>
Grid.Row="1"
Grid.Column="2"/>

<Switch x:Name="switchPinStream"
VerticalOptions="Center"
Grid.Row="3"
Grid.Column="1"/>
Grid.Row="2"
Grid.Column="0"/>

<Label Text="Stream:"
VerticalTextAlignment="Center"
HorizontalTextAlignment="End"
Grid.Row="3"
Grid.Column="2"/>
Grid.Row="2"
Grid.Column="1"/>

<Picker x:Name="buttonPinStream"
Grid.Row="3"
Grid.Column="3"/>
Grid.Row="2"
Grid.Column="2"/>

<Button x:Name="buttonPinSetToNull"
Text="Set to null"
Grid.Row="3"
Grid.Column="0"
Grid.ColumnSpan="2"/>

<StackLayout
Orientation="Horizontal"
Grid.Row="3"
Grid.Column="2">
<Switch x:Name="switchIsDraggable"
VerticalOptions="Center"/>
<Label Text="IsDraggable"
VerticalOptions="Center"
HorizontalTextAlignment="Start"/>
</StackLayout>

<Label x:Name="labelDragStatus"
Text="Show status when Pin drag."
Grid.Row="4"
Grid.Column="1"
Grid.Column="0"
Grid.ColumnSpan="3"/>

</Grid>
<maps:Map x:Name="map"
VerticalOptions="FillAndExpand"/>
Expand Down
25 changes: 21 additions & 4 deletions XFGoogleMapSample/XFGoogleMapSample/CustomPinsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public CustomPinsPage()
var switches = new Switch[] { switchPinColor, switchPinBundle, switchPinStream };
foreach (var sw in switches)
{
sw.Toggled += (sender, e) =>
sw.Toggled += (sender, e) =>
{
if (!e.Value || _dirty)
return;
Expand All @@ -75,7 +75,7 @@ public CustomPinsPage()
buttonPinColor.Items.Add(c.Item1);
}

buttonPinColor.SelectedIndexChanged += (_, e) =>
buttonPinColor.SelectedIndexChanged += (_, e) =>
{
buttonPinColor.BackgroundColor = _colors[buttonPinColor.SelectedIndex].Item2;
UpdatePinIcon();
Expand Down Expand Up @@ -107,7 +107,7 @@ public CustomPinsPage()
buttonPinStream.SelectedIndex = 0;

// Set to null
buttonPinSetToNull.Clicked += (sender, e) =>
buttonPinSetToNull.Clicked += (sender, e) =>
{
_pinTokyo.Icon = null;
foreach (var sw in switches)
Expand All @@ -116,6 +116,23 @@ public CustomPinsPage()
}
};

// Pin Draggable
switchIsDraggable.Toggled += (sender, e) =>
{
_pinTokyo.IsDraggable = switchIsDraggable.IsToggled;
};

map.PinDragStart += (_, e) => labelDragStatus.Text = $"DragStart - {PrintPin(e.Pin)}";
map.PinDragging += (_, e) => labelDragStatus.Text = $"Dragging - {PrintPin(e.Pin)}";
map.PinDragEnd += (_, e) => labelDragStatus.Text = $"DragEnd - {PrintPin(e.Pin)}";

switchIsDraggable.IsToggled = true;

}

private string PrintPin(Pin pin)
{
return $"{pin.Label}({pin.Position.Latitude.ToString("0.000")},{pin.Position.Longitude.ToString("0.000")})";
}

protected override async void OnAppearing()
Expand All @@ -126,9 +143,9 @@ protected override async void OnAppearing()

await Task.Delay(1000); // workaround for #30 [Android]Map.Pins.Add doesn't work when page OnAppearing

_pinTokyo.IsDraggable = true;
map.Pins.Add(_pinTokyo);
map.MoveToRegion(MapSpan.FromCenterAndRadius(_pinTokyo.Position, Distance.FromMeters(5000)));

}

void UpdatePinIcon()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.4.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.5.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Xamarin.Forms.GoogleMaps.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion XFGoogleMapSample/XFGoogleMapSample/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Forms" version="2.3.0.49" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10" />
<package id="Xamarin.Forms.GoogleMaps" version="1.4.1" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10" />
<package id="Xamarin.Forms.GoogleMaps" version="1.5.0" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10" />
</packages>
4 changes: 2 additions & 2 deletions XFGoogleMapSample/iOS/XFGoogleMapSample.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
<HintPath>..\packages\Xamarin.Google.iOS.Maps.1.13.1.0\lib\Xamarin.iOS10\Google.Maps.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps.iOS">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.4.1\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.iOS.dll</HintPath>
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.5.0\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.iOS.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.4.1\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.5.0\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion XFGoogleMapSample/iOS/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<packages>
<package id="Xamarin.Build.Download" version="0.2.1" targetFramework="xamarinios10" />
<package id="Xamarin.Forms" version="2.3.0.49" targetFramework="xamarinios10" />
<package id="Xamarin.Forms.GoogleMaps" version="1.4.1" targetFramework="xamarinios10" />
<package id="Xamarin.Forms.GoogleMaps" version="1.5.0" targetFramework="xamarinios10" />
<package id="Xamarin.Google.iOS.Maps" version="1.13.1.0" targetFramework="xamarinios10" />
</packages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Android.Gms.Maps.Model;
namespace Xamarin.Forms.GoogleMaps.Android.Extensions
{
internal static class LatLngExtensions
{
public static Position ToPosition(this LatLng self)
{
return new Position(self.Latitude, self.Longitude);
}
}
}

Loading

0 comments on commit b0a62ff

Please sign in to comment.