Skip to content

Commit

Permalink
Merge pull request #15 from amay077/develop
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
amay077 authored Jun 27, 2016
2 parents b1cea53 + c287039 commit 10be9c7
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 61 deletions.
8 changes: 4 additions & 4 deletions XFGoogleMapSample/Droid/XFGoogleMapSample.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@
<Reference Include="Xamarin.Android.Support.v7.MediaRouter">
<HintPath>..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.0\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<Reference Include="Xamarin.Forms.GoogleMaps, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.1\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps.Android, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.0\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.Android.dll</HintPath>
<Reference Include="Xamarin.Forms.GoogleMaps.Android, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.1\lib\MonoAndroid10\Xamarin.Forms.GoogleMaps.Android.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Platform.Android">
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.1.0" targetFramework="monoandroid60" />
<package id="Xamarin.Forms.GoogleMaps" version="1.1.1" 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
2 changes: 1 addition & 1 deletion XFGoogleMapSample/UWP/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Xamarin.Forms": "2.3.0.49",
"Xamarin.Forms.GoogleMaps": "1.1.0"
"Xamarin.Forms.GoogleMaps": "1.1.1"
},
"frameworks": {
"uap10.0": {}
Expand Down
4 changes: 2 additions & 2 deletions XFGoogleMapSample/XFGoogleMapSample/XFGoogleMapSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<Reference Include="Xamarin.Forms.Core">
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<Reference Include="Xamarin.Forms.GoogleMaps, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Xaml">
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.1.0" targetFramework="portable45-net45+win8+wp8" />
<package id="Xamarin.Forms.GoogleMaps" version="1.1.1" targetFramework="portable45-net45+win8+wp8" />
</packages>
8 changes: 4 additions & 4 deletions XFGoogleMapSample/iOS/XFGoogleMapSample.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Forms.GoogleMaps, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.0\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<Reference Include="Xamarin.Forms.GoogleMaps, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.1\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.GoogleMaps.iOS, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.0\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.iOS.dll</HintPath>
<Reference Include="Xamarin.Forms.GoogleMaps.iOS, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.GoogleMaps.1.1.1\lib\Xamarin.iOS10\Xamarin.Forms.GoogleMaps.iOS.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.iOS" />
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.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Forms.GoogleMaps" version="1.1.1" 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
Expand Up @@ -92,10 +92,11 @@ protected override void OnElementChanged(ElementChangedEventArgs<View> e)
#pragma warning disable 618
oldMapView.Map.SetOnCameraChangeListener(null);
#pragma warning restore 618
NativeMap.InfoWindowClick -= MapOnMarkerClick;
NativeMap.InfoWindowClick -= MapOnInfoWindowClick;
NativeMap.PolylineClick -= MapOnPolylineClick;
NativeMap.PolygonClick -= MapOnPolygonClick;
//NativeMap.CircleClick -= MapOnCircleClick; // Circle click is not supported.
NativeMap.MarkerClick -= MapOnMakerClick;
}

oldMapView.Dispose();
Expand All @@ -105,10 +106,11 @@ protected override void OnElementChanged(ElementChangedEventArgs<View> e)
if (map != null)
{
map.SetOnCameraChangeListener(this);
NativeMap.InfoWindowClick += MapOnMarkerClick;
NativeMap.InfoWindowClick += MapOnInfoWindowClick;
NativeMap.PolylineClick += MapOnPolylineClick;
NativeMap.PolygonClick += MapOnPolygonClick;
//NativeMap.CircleClick += MapOnCircleClick; // Circle click is not supported.
NativeMap.MarkerClick += MapOnMakerClick;

map.UiSettings.ZoomControlsEnabled = Map.HasZoomEnabled;
map.UiSettings.ZoomGesturesEnabled = Map.HasZoomEnabled;
Expand Down Expand Up @@ -154,6 +156,7 @@ void OnPinCollectionChanged(object sender, NotifyCollectionChangedEventArgs noti
case NotifyCollectionChangedAction.Reset:
_markers?.ForEach(m => m.Remove());
_markers = null;
((Map)Element).SelectedPin = null;
AddPins((IList)(Element as Map).Pins);
break;
case NotifyCollectionChangedAction.Move:
Expand Down Expand Up @@ -394,18 +397,17 @@ void UpdateSelectedPin(Pin pin)
{
if (pin == null)
{
foreach (var marker in _markers)
{
marker.HideInfoWindow();
}
if (_markers != null)
foreach (var marker in _markers)
marker.HideInfoWindow();
}
else
{
// lookup pin
Marker targetMarker = null;
foreach (var marker in _markers)
{
if (((Marker)pin.Id).Id != marker.Id)
if (((Marker)pin.Id).Id != marker.Id)
continue;

targetMarker = marker;
Expand All @@ -419,6 +421,7 @@ void UpdateSelectedPin(Pin pin)

void RemovePins(IList pins)
{
var gmap = (Map)Element;
var map = NativeMap;
if (map == null)
return;
Expand All @@ -427,15 +430,19 @@ void RemovePins(IList pins)

foreach (Pin p in pins)
{
var marker = _markers.FirstOrDefault(m => object.ReferenceEquals(m, p.Id));
var marker = _markers.FirstOrDefault(m => ((Marker)p.Id).Id == m.Id);
if (marker == null)
continue;
marker.Remove();
_markers.Remove(marker);

if (object.ReferenceEquals(gmap.SelectedPin, p))
gmap.SelectedPin = null;

}
}

void MapOnMarkerClick(object sender, GoogleMap.InfoWindowClickEventArgs eventArgs)
void MapOnInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs eventArgs)
{
// clicked marker
var marker = eventArgs.Marker;
Expand All @@ -445,7 +452,7 @@ void MapOnMarkerClick(object sender, GoogleMap.InfoWindowClickEventArgs eventArg
for (var i = 0; i < Map.Pins.Count; i++)
{
var pin = Map.Pins[i];
if ((string)pin.Id != marker.Id)
if (((Marker)pin.Id).Id != marker.Id)
continue;

targetPin = pin;
Expand All @@ -457,6 +464,36 @@ void MapOnMarkerClick(object sender, GoogleMap.InfoWindowClickEventArgs eventArg
targetPin?.SendTap();
}

void MapOnMakerClick(object sender, GoogleMap.MarkerClickEventArgs eventArgs)
{
var map = (Map)Element;

// clicked marker
var marker = eventArgs.Marker;

// lookup pin
Pin targetPin = null;
for (var i = 0; i < Map.Pins.Count; i++)
{
var pin = Map.Pins[i];
if (((Marker)pin.Id).Id != marker.Id)
continue;

targetPin = pin;
break;
}

if (targetPin != null)
{
if (targetPin.Equals(map.SelectedPin))
map.SelectedPin = null;
else
map.SelectedPin = targetPin;
}

eventArgs.Handled = true;
}

void MapOnPolylineClick(object sender, GoogleMap.PolylineClickEventArgs eventArgs)
{
// clicked polyline
Expand All @@ -467,7 +504,7 @@ void MapOnPolylineClick(object sender, GoogleMap.PolylineClickEventArgs eventArg
for (var i = 0; i < Map.Polylines.Count; i++)
{
var line = Map.Polylines[i];
if ((string)line.Id != clickedPolyline.Id)
if (((APolyline)line.Id).Id != clickedPolyline.Id)
continue;

targetPolyline = line;
Expand All @@ -488,7 +525,7 @@ void MapOnPolygonClick (object sender, GoogleMap.PolygonClickEventArgs eventArgs
Polygon targetPolygon = null;
for (var i = 0; i < Map.Polygons.Count; i++) {
var polygon = Map.Polygons [i];
if ((string)polygon.Id != clickedPolygon.Id)
if (((APolygon)polygon.Id).Id != clickedPolygon.Id)
continue;

targetPolygon = polygon;
Expand All @@ -500,28 +537,6 @@ void MapOnPolygonClick (object sender, GoogleMap.PolygonClickEventArgs eventArgs
targetPolygon?.SendTap();
}

//void MapOnCircleClick(object sender, GoogleMap.CircleClickEventArgs eventArgs)
//{
// // clicked polygon
// var clickedCircle = eventArgs.Circle;

// // lookup pin
// Circle targetCircle = null;
// for (var i = 0; i < Map.Circles.Count; i++)
// {
// var circle = Map.Circles[i];
// if ((string)circle.Id != clickedCircle.Id)
// continue;

// targetCircle = circle;
// break;
// }

// // only consider event handled if a handler is present.
// // Else allow default behavior of displaying an info window.
// targetCircle?.SendTap();
//}

void AddPolylines(IList polylines)
{
var map = NativeMap;
Expand Down Expand Up @@ -561,7 +576,7 @@ void RemovePolylines(IList polylines)

foreach (Polyline polyline in polylines)
{
var apolyline = _polylines.FirstOrDefault(m => object.ReferenceEquals(m, polyline.Id));
var apolyline = _polylines.FirstOrDefault(m => ((APolyline)polyline.Id).Id == m.Id);
if (apolyline == null)
continue;
apolyline.Remove();
Expand Down Expand Up @@ -606,7 +621,7 @@ void RemovePolygons (IList polygons)
return;

foreach (Polygon polygon in polygons) {
var apolygon = _polygons.FirstOrDefault (m => object.ReferenceEquals(m, polygon.Id));
var apolygon = _polygons.FirstOrDefault (m => ((APolygon)polygon.Id).Id == m.Id);
if (apolygon == null)
continue;
apolygon.Remove();
Expand Down Expand Up @@ -652,7 +667,7 @@ void RemoveCircles(IList circles)

foreach (Circle circle in circles)
{
var acircle = _circles.FirstOrDefault(m => object.ReferenceEquals(m, circle.Id));
var acircle = _circles.FirstOrDefault(m => ((ACircle)circle.Id).Id == m.Id);
if (acircle == null)
continue;
acircle.Remove();
Expand Down Expand Up @@ -681,7 +696,7 @@ protected override void Dispose(bool disposing)
if (gmap == null)
return;
gmap.MyLocationEnabled = false;
gmap.InfoWindowClick -= MapOnMarkerClick;
gmap.InfoWindowClick -= MapOnInfoWindowClick;
gmap.PolylineClick -= MapOnPolylineClick;
gmap.PolygonClick -= MapOnPolygonClick;
//gmap.CircleClick -= MapOnCircleClick;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
[assembly: AssemblyProduct("Xamarin.Forms.GoogleMaps")]
[assembly: AssemblyCopyright("Copyright © amay077. 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyFileVersion("1.1.0.1")]
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyFileVersion("1.1.0.1")]
[assembly: ComVisible(false)]
[assembly: ExportRenderer(typeof(Map), typeof(MapRenderer))]
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected override void Dispose(bool disposing)
mkMapView.InfoTapped -= InfoWindowTapped;
mkMapView.OverlayTapped -= OverlayTapped;
mkMapView.CameraPositionChanged -= CameraPositionChanged;
mkMapView.TappedMarker = null;
}

base.Dispose(disposing);
Expand Down Expand Up @@ -73,6 +74,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<View> e)
mkMapView.CameraPositionChanged += CameraPositionChanged;
mkMapView.InfoTapped += InfoWindowTapped;
mkMapView.OverlayTapped += OverlayTapped;
mkMapView.TappedMarker = HandleGMSTappedMarker;
}

MessagingCenter.Subscribe<Map, MoveToRegionMessage>(this, MoveMessageName, (s, a) => MoveToRegion(a.Span, a.Animate), mapModel);
Expand Down Expand Up @@ -184,6 +186,30 @@ void OverlayTapped(object sender, GMSOverlayEventEventArgs e)
}
}

bool HandleGMSTappedMarker(MapView mapView, Marker marker)
{
var map = (Map)Element;

// lookup pin
Pin targetPin = null;
for (var i = 0; i < map.Pins.Count; i++)
{
var pin = map.Pins[i];
if (!Object.ReferenceEquals(pin.Id, marker))
continue;

targetPin = pin;
break;
}

if (object.ReferenceEquals(map.SelectedPin, targetPin))
map.SelectedPin = null;
else
map.SelectedPin = targetPin;

return true;
}

void UpdateSelectedPin(Pin pin)
{
var mapView = (MapView)Control;
Expand Down Expand Up @@ -283,6 +309,7 @@ void OnPinCollectionChanged(object sender, NotifyCollectionChangedEventArgs noti
case NotifyCollectionChangedAction.Reset:
var mapView = (MapView)Control;
mapView.Clear();
(Element as Map).SelectedPin = null;
AddPins((IList)(Element as Map).Pins);
break;
case NotifyCollectionChangedAction.Move:
Expand Down Expand Up @@ -368,8 +395,14 @@ void OnCircleCollectionChanged(object sender, NotifyCollectionChangedEventArgs n

void RemovePins(IList pins)
{
var map = (Map)Element;
foreach (object pin in pins)
{
((Marker)((Pin)pin).Id).Map = null;

if (object.ReferenceEquals(map.SelectedPin, pin))
map.SelectedPin = null;
}
}

void AddPolylines(IList polylines)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
[assembly: AssemblyProduct("Xamarin.Forms.GoogleMaps")]
[assembly: AssemblyCopyright("Copyright © amay077. 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyFileVersion("1.1.0.1")]
Loading

0 comments on commit 10be9c7

Please sign in to comment.