NAXAM / mapbox-xamarin-forms

Mapbox on Xamarin.Forms
Apache License 2.0
73 stars 41 forks source link

Specified cast is not valid #69

Open tmk907 opened 4 years ago

tmk907 commented 4 years ago

Sometimes i got error

System.InvalidCastException: Specified cast is not valid. at Naxam.Controls.Mapbox.Platform.Droid.MapViewRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00076] in D:\Github\Xamarin\mapbox-xamarin-forms\Naxam.Mapbox.Platform.Droid\MapViewRenderer.cs:45

This can be fixed by changing var activity = (AppCompatActivity) Context; to var activity = (AppCompatActivity) Context.GetActivity(); https://github.com/NAXAM/mapbox-xamarin-forms/blob/3f9fed5dea3c2e70a6f220f34ce1fba12d7909fc/Naxam.Mapbox.Platform.Droid/MapViewRenderer.cs#L45

nakulLukan commented 4 years ago

Hi, I experienced the exact issue. My mapview was a child of ScrollView. Removing the scroll view fixed the issue.

tuyen-vuduc commented 4 years ago

@tmk907 , could you create a PR for this?