diff options
author | Marcus Lum <marcusl@gmail.com> | 2016-08-30 13:37:07 -0400 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-08-30 10:37:07 -0700 |
commit | 61f34d113c9f6941194a6ed3101f54158de722a3 (patch) | |
tree | b6211a4e1a4dba6ec40aad3823a795387e851815 /Xamarin.Forms.Maps.Android/MapRenderer.cs | |
parent | 5b85aafcd671f5e8745cf52339c20378f91cb748 (diff) | |
download | xamarin-forms-61f34d113c9f6941194a6ed3101f54158de722a3.tar.gz xamarin-forms-61f34d113c9f6941194a6ed3101f54158de722a3.tar.bz2 xamarin-forms-61f34d113c9f6941194a6ed3101f54158de722a3.zip |
Allow Custom Android MapRenderers to override the default MapView options (#285)
* Allow Custom Android MapRenderers to override the default MapView options
* Larger effort to use CreateNativeControl () everywhere instead of just in the Android AppCompat renderers.
Diffstat (limited to 'Xamarin.Forms.Maps.Android/MapRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Maps.Android/MapRenderer.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Xamarin.Forms.Maps.Android/MapRenderer.cs b/Xamarin.Forms.Maps.Android/MapRenderer.cs index a0a3bbc1..29270c0b 100644 --- a/Xamarin.Forms.Maps.Android/MapRenderer.cs +++ b/Xamarin.Forms.Maps.Android/MapRenderer.cs @@ -15,7 +15,7 @@ using System.Collections; namespace Xamarin.Forms.Maps.Android { - public class MapRenderer : ViewRenderer, + public class MapRenderer : ViewRenderer<Map,MapView>, GoogleMap.IOnCameraChangeListener { public MapRenderer () @@ -41,19 +41,24 @@ namespace Xamarin.Forms.Maps.Android return new SizeRequest (new Size (Context.ToPixels (40), Context.ToPixels (40))); } - protected override void OnElementChanged (ElementChangedEventArgs<View> e) + protected override MapView CreateNativeControl() + { + return new MapView(Context); + } + + protected override void OnElementChanged (ElementChangedEventArgs<Map> e) { base.OnElementChanged (e); var oldMapView = (MapView)Control; - var mapView = new MapView (Context); + var mapView = CreateNativeControl(); mapView.OnCreate (s_bundle); mapView.OnResume (); SetNativeControl (mapView); if (e.OldElement != null) { - var oldMapModel = (Map) e.OldElement; + var oldMapModel = e.OldElement; ((ObservableCollection<Pin>)oldMapModel.Pins).CollectionChanged -= OnCollectionChanged; MessagingCenter.Unsubscribe<Map, MapSpan> (this, MoveMessageName); |