Forum Xamarin.Forms

GoogleMaps custom renderer in iOS -> NPE

AndreaBellittoAndreaBellitto ITMember
edited March 2017 in Xamarin.Forms

I'm writing a project with a pcl and ios components. I'm following this sample:

Using it in conjunction with Xamarin.Forms.GoogleMaps NuGet package.

I'm facing a problem inside iOS renderer, because on row number 37 i will get always

var nativeMap = null

I can't understand what I'm missing

Debugging I get some more information. The problem seems to be Control as MKMapView casting, infact that casting returns null, Control seems to be GMSMapView type instead of MKMapView.

How to go ahead of this problem???


  • RyanSmith.9175RyanSmith.9175 USMember ✭✭

    Have you figured out this issue? I am also trying to implement custom renderer for maps in iOS with google maps

  • You could try smth like this. I wont go into details how pass Pins or other data.

    public class GMapRenderer : ViewRenderer<ObjectsGMap, MapView>
            private MapView mapView;
            protected override void OnElementChanged(ElementChangedEventArgs<ObjectsGMap> e)
                if (e.OldElement != null || Element == null)
                var formsElement = Element as ObjectsGMap;
                if (Control == null)
                    mapView = new MapView();
Sign In or Register to comment.