Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Unable to render ContentPage when it has a Map on android

JOAOSerraJOAOSerra PTMember ✭✭
edited June 2014 in Xamarin.Forms

Please help me out, I've been wasting my afternoon around this.

When I add a Map to the page, im not able to navigate to that page.
I know the click is working because it shows an alert, and if I remove the Map component everything goes back to normal.
On IOS seems to work fine.

this is how I create the map

        StackLayout mapLayout = new StackLayout
            Orientation = StackOrientation.Vertical,
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand

        Label GPS = new Label
            Text = "GPS: 41.174423,-8.645270",
            TextColor = Color.Black,

        Map myMap = new Map(
                new Position(37,-122), Distance.FromMiles(0.3))) {
            IsShowingUser = true,
            IsEnabled = true,
            IsVisible = true,
            MapType = Xamarin.Forms.Maps.MapType.Street,
            VerticalOptions = LayoutOptions.FillAndExpand


        return mapLayout;

Im working on a physical device android 4.0.3 and Im using the component for ICS with Xamarin.Forms.Maps
I initialize the maps on android with this order

        Xamarin.Forms.Forms.Init (this, bundle);
        FormsMaps.Init(this, bundle);

        SetPage (UI.GetMainPage ());

I also know its not the google maps api key, because usually when a key is invalid it shows gray tiles right?

I believe Google play and maps are well installed in the application, as I've been working with the device before in other projects that also used maps.


  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    Your code at first glance looks just fine, have you looked at the existing MapDemoPage.cs in the FormsGallery sample in the repo?

    Does your iOS/Windows applications work fine for maps?

  • CraigDunnCraigDunn USXamarin Team Xamurai

    What exactly are you referring to when you say "Im using the component for ICS"? Xamarin.Forms Maps support does not require any Xamarin Components, instead it relies upon a Xamarin Google Play Services NuGet package which should be automatically added (as a dependency) when you add the Xamarin.Forms.Maps NuGet package.

    Also, what happens when "im not able to navigate to that page." - does it just stay on the same page? Is anything written to the log? If you just take the Map off that page but leave the Label, does it work?

    Did you see the Maps doc and were you able to use our MobileCRM sample successfully? Were the permissions set correctly in AndroidManifest.xml?

  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    Actually, I think that if your API key is bad you will have problems navigating to the map page. I ran into this a week or two ago. Look at the application output and you should see a message about "contacting google map server"

  • JOAOSerraJOAOSerra PTMember ✭✭

    Thank you for the reply. And sorry my haste but the schedule is getting tight.
    Some more information.

    I am importing both Xamarin.Forms.Maps and Google Play Services (ICS) just to make sure I have everything I need. But I've removed the component after your comment and I still get the same behavior.

    On target Android I'm using 4.4 instead 4.0.3 but I keep Min version as 4.0.3.
    I do this because when I set the target to 4.0.3 I get a "No resource identifier found for attribute 'paddingStart' in package 'android' and this was the solution I've found on the forums.

    When I comment the "myMap" element, I can see the page without any problem.

    When I uncomment the "myMap" code, on debug, I get to enter the constructor build every component (Labels, layouts, map) and exit without any problem. But in the end I only see the previous page, like the page was fully transparent.

    I've also set my Java Max Heap Size to 1G.

    On android manifest I've added the following permissions:

    ACCESS_Location extra
    ACCESS_mock location
    ACCESS_network state
    write external storage
    write gservices

    The thing with MOBILEORM example is that it was not using forms if I can recall. But I'll try to check the FormsGallery.

    How could I test my GMaps API Key?

  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    Have you looked at the application output for messages from the Google Maps component?

  • JOAOSerraJOAOSerra PTMember ✭✭

    My output tab from visual studio 2012 doesn't seems to show anything about google maps.
    I do see GooglePlayServices dll getting loaded as well xamarin.forms.maps and

    I forgot to mention that I'm able to click on the navigation bar back button.
    And once I do it, I go to a black page.
    Clicking a second time goes back to the page PREVIOUS TO THE PREVIOUS PAGE

  • JOAOSerraJOAOSerra PTMember ✭✭

    I've found out that the api key was added in the wrong section of the manifest outside of the
    after the permissions.

    As Jason said this was cause by a bad API KEY. In this case empty.

    Thank you very much. :)

    You wont believe how much time i wasted with this problem.

    I guess this should be more explicit at

Sign In or Register to comment.