summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps.Android
diff options
context:
space:
mode:
authorjcmanke <jmanke1227@gmail.com>2017-04-11 22:52:04 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-04-11 22:52:04 (GMT)
commitdfda41b0bdc0ea80f548e3c919f14e8094c6cb25 (patch)
tree32dbdc4a31899c3c5e31329ad9d86bca21c4e235 /Xamarin.Forms.Maps.Android
parentb832b67875789f2fccea5077c86238e75cf373ff (diff)
downloadxamarin-forms-dfda41b0bdc0ea80f548e3c919f14e8094c6cb25.zip
xamarin-forms-dfda41b0bdc0ea80f548e3c919f14e8094c6cb25.tar.gz
xamarin-forms-dfda41b0bdc0ea80f548e3c919f14e8094c6cb25.tar.bz2
Map renderer extensibility (#844)
* Added extensibility features to Maps Android MapRenderer: - Moved map initialization to protected virtual method OnMapReady, called by explicit implementation of IOnMapReady - Added protected virtual method CreateMarker for customization of pins iOS MapRenderer: - Added protected virtual method CreateAnnotation for customization of pins Pin: - Unsealed the Pin class - Made Label a bindable property * [Docs] Update docs
Diffstat (limited to 'Xamarin.Forms.Maps.Android')
-rw-r--r--Xamarin.Forms.Maps.Android/MapRenderer.cs48
1 files changed, 30 insertions, 18 deletions
diff --git a/Xamarin.Forms.Maps.Android/MapRenderer.cs b/Xamarin.Forms.Maps.Android/MapRenderer.cs
index 5856dc7..0b426d3 100644
--- a/Xamarin.Forms.Maps.Android/MapRenderer.cs
+++ b/Xamarin.Forms.Maps.Android/MapRenderer.cs
@@ -181,6 +181,33 @@ namespace Xamarin.Forms.Maps.Android
MoveToRegion(Element.LastMoveToRegion, false);
}
}
+
+ protected virtual void OnMapReady(GoogleMap map)
+ {
+ if (map == null)
+ {
+ return;
+ }
+
+ map.SetOnCameraChangeListener(this);
+ map.InfoWindowClick += MapOnMarkerClick;
+
+ map.UiSettings.ZoomControlsEnabled = Map.HasZoomEnabled;
+ map.UiSettings.ZoomGesturesEnabled = Map.HasZoomEnabled;
+ map.UiSettings.ScrollGesturesEnabled = Map.HasScrollEnabled;
+ map.MyLocationEnabled = map.UiSettings.MyLocationButtonEnabled = Map.IsShowingUser;
+ SetMapType();
+ }
+
+ protected virtual MarkerOptions CreateMarker(Pin pin)
+ {
+ var opts = new MarkerOptions();
+ opts.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
+ opts.SetTitle(pin.Label);
+ opts.SetSnippet(pin.Address);
+
+ return opts;
+ }
void AddPins(IList pins)
{
@@ -198,10 +225,7 @@ namespace Xamarin.Forms.Maps.Android
_markers.AddRange(pins.Cast<Pin>().Select(p =>
{
Pin pin = p;
- var opts = new MarkerOptions();
- opts.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
- opts.SetTitle(pin.Label);
- opts.SetSnippet(pin.Address);
+ var opts = CreateMarker(pin);
var marker = map.AddMarker(opts);
// associate pin with marker for later lookup in event handlers
@@ -367,19 +391,7 @@ namespace Xamarin.Forms.Maps.Android
void IOnMapReadyCallback.OnMapReady(GoogleMap map)
{
NativeMap = map;
- if (map == null)
- {
- return;
- }
-
- map.SetOnCameraChangeListener(this);
- map.InfoWindowClick += MapOnMarkerClick;
-
- map.UiSettings.ZoomControlsEnabled = Map.HasZoomEnabled;
- map.UiSettings.ZoomGesturesEnabled = Map.HasZoomEnabled;
- map.UiSettings.ScrollGesturesEnabled = Map.HasScrollEnabled;
- map.MyLocationEnabled = map.UiSettings.MyLocationButtonEnabled = Map.IsShowingUser;
- SetMapType();
+ OnMapReady(map);
}
}
-} \ No newline at end of file
+}