cubanGuy
cubanGuy

Reputation: 1296

Google Maps shows blank map using google_maps_flutter plugin

I'm working on an app that uses the google_maps_flutter plugin (version 0.5.7) to display a map. It was working just perfectly until yesterday. I didn't do any updates to my app, it just stopped displaying a blank map when I opened it today. Flutter Doctor doesn't show any problem, and the same with Flutter Analyze. The plugin seems to be partially working, because I'm using the GoogleMap onTap property to show the coordinates of the location tapped, and it works just fine (I/flutter (11935): LatLng(25.895589930847475, -80.28307791799307), although the marker is not created.

_handleTap(LatLng point) {
  setState(() {
     print(point);
    _markers.add(Marker(
        markerId: MarkerId(point.toString()),
        position: point,
        infoWindow: InfoWindow(
        title: point.toString(),
        ),
    icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueMagenta),
   ));
  });
}

Any ideas, what could be happening? Has any issue been reported for this plugin that could cause this issue?

enter image description here

Upvotes: 6

Views: 7302

Answers (3)

zakaria
zakaria

Reputation: 173

It might be because of Connectivity problem in Emulator(wifi/internet)

Change the DNS address of your network to 8.8.8.8 (Google's DNS) or another of your preference:

MacOSX:

Open "System Preferences" Click on "Network" Select the network which your computer is connected click on "Advanced" Select "DNS", Select the "+" button, type "8.8.8.8" (Google's DNS) or if you prefer OpenDNS, "208.67.222.222" Select "Ok" and "Apply"

Windows & Linux: https://developers.google.com/speed/public-dns/docs/using

After that close the emulator and start it again.

Upvotes: 3

Mike Dubs
Mike Dubs

Reputation: 729

  1. Log in to the [Google Cloud Platform Console][1].
  2. Click the project drop-down and select or create the project for which you want to add an API key.
  3. Click the menu (top-left hamburger) button and select APIs & Services > Credentials.
  4. On the Credentials page, click Create credentials > API key. Repeat this step to create 2 keys.
  5. In your Flutter project, ensure the following files use an active API key:
    • android/app/src/main/AndroidManifest.xml
    • ios/Runner/AppDelegate.swift
  6. Click the menu (top-left hamburger) button and select APIs & Services > Library
  7. Click on each of the following items and then click 'Enable'
    • Maps SDK for Android
    • Maps SDK for iOS
  8. I would suggest going back to the API keys you created in step 3 and then restricting one to iOS apps and the Maps SDK for iOS and the other to Android and the Maps SDK for Android.

    [1]: https://cloud.google.com/console/google/maps-apis/overview

Upvotes: 6

Abhishek Singh
Abhishek Singh

Reputation: 980

I did have a similar problem in iOS. Make sure you enable both apis in google developers console. maps for iOS and maps for Android. Key can be shared or generate for each platform.

Upvotes: 1

Related Questions