Durdu
Durdu

Reputation: 4849

Flutter google_maps_flutter into existing project

I am trying to integrate google_maps_flutter into an existing project.

The maps component works only when running directly the "my_flutter" project on the device (the same code).

When I try to run the flutter module from an existing app, the maps component is empty and no logs are available (or usable).

(Flutter doctor does not output any errors).

I've followed the steps for both the my_flutter/.iOS and my_flutter/.android projects and I also followed them for the projects that integrate my_flutter.

Source:

Android
Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="YOUR KEY HERE"/>

iOS Specify your API key in the application delegate ios/Runner/AppDelegate.m:

include "AppDelegate.h"
include "GeneratedPluginRegistrant.h"        
import "GoogleMaps/GoogleMaps.h" 

@implementation AppDelegate

    - (BOOL)application:(UIApplication *)application   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
           [GMSServices provideAPIKey:@"YOUR KEY HERE"];   
           [GeneratedPluginRegistrant registerWithRegistry:self];   
           return [super application:application didFinishLaunchingWithOptions:launchOptions];  
     }   
@End

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.


I suspect that I what I am trying is not possible yet with the current version on the library and it may come as a new feature when the library is not in "developer preview".

Upvotes: 0

Views: 596

Answers (2)

Durdu
Durdu

Reputation: 4849

Found that I had to:

GeneratedPluginRegistrant.register(with: flutterViewController.pluginRegistry());

Upvotes: 1

Fellipe Malta
Fellipe Malta

Reputation: 3510

Did you set a latitude and longitude in the Google Maps param?

If you're setting your API key and doing what it said, it should work fine

Upvotes: 0

Related Questions