protected override void OnElementChanged(ElementChangedEventArgs <MapboxView> e) { base.OnElementChanged(e); if (e.OldElement != null) { Element.MarkerAdded -= Element_MarkerAdded; // Unsubscribe from event handlers and cleanup any resources if (Instances.ContainsKey(instanceId)) { Instances.Remove(instanceId); } } if (e.NewElement != null) { if (Control == null) { mapbox = new MapboxWrapper(this.Context as Activity, this); mapbox.Init(Element.AccessToken); mapbox.OnCreate(null, new Java.Lang.Double(Element.InitialLatitude), new Java.Lang.Double(Element.InitialLongitude), new Java.Lang.Integer(Element.InitialZoom)); // Add our instance to the static dictionary for mainactivity lifecycle events Instances[instanceId] = mapbox; SetNativeControl(mapbox.View); } Element.MarkerAdded += Element_MarkerAdded; } }
protected override void OnElementChanged(ElementChangedEventArgs <MapboxView> e) { base.OnElementChanged(e); if (e.OldElement != null) { Element.MarkerAdded -= Element_MarkerAdded; // Unsubscribe from event handlers and cleanup any resources if (Instances.ContainsKey(instanceId)) { Instances.Remove(instanceId); } } if (e.NewElement != null) { if (Control == null) { mapbox = new MapboxWrapper(this.Frame, this); mapbox.Init(); // Add our instance to the static dictionary for mainactivity lifecycle events Instances[instanceId] = mapbox; SetNativeControl(mapbox.View); } Element.MarkerAdded += Element_MarkerAdded; } }