Search code examples
google-mapsxamarin.iosgoogle-maps-sdk-ios

Google Maps SDK Xamarin.iOS show MapView in UIView via Storyboard


I'm using Google Maps SDK for my Xamarin.iOS app and i got an problem.

I want to put MapView into specific UIView(that was created on Storyboard) and that is no so easy as expected.

At current moment i have tried to put MapView class into my UIView class(in native iOS Development its an solution),but it didn't worked.

Also i have tried to do something like this:

//init google SDK stuff
MyViewWhereIWantToPutGoogleMaps.AddSubview(MapView); // and the same,no effect  

Any ideas? Thanks.


Solution

  • Remember you need to indicate the CGRect for the MapView object.

    If you want it to cover the whole space in MyViewWhereIWantToPutGoogleMaps you just do:

    var frame = MyViewWhereIWantToPutGoogleMaps.Frame;
    var googleMaps = new Google.Maps.MapView (new CoreGraphics.CGRect(0, 0, frame.Width, frame.Height));
    
    MyViewWhereIWantToPutGoogleMaps.AddSubview (googleMaps);
    

    Hope this helps.-