I'm really novice in flutter and i encounter an issue with google maps widget. I tried to follow the tutorial of medium: https://medium.com/flutter-io/google-maps-and-flutter-cfb330f9a245
Unfortunately, when i'm running the app i have a blank image.
Screenshot of the app
Does somebody have ever encountered this problem ? Do you have a suggestion in which direction i can try to investigate?
Your API key is invalid. Or you haven't turned on Google Maps API.
The map feature showing up without maps is a clear question about your google map setup in Flutter. Make sure you have the following configurations.
Get an API Key at cloud.google.com/maps-platform/ and make sure to select the right map features you want. If you are not sure, select them all.
In Android:
Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:
Next: Go to Android manifest and insert the meta-data needed to attached your google maps account to the Flutter App.
Make sure you add your API-Key where it shows in the code.
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR KEY HERE"/>
Then: go into your iOS setting in ios/Runner/AppDelegate.m add add the required google codes.
#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
Additional information can be found within the Dart package here
Related
Google's documentation for using react-native-maps calls for placing your API_KEY in the AndroidManifest.xml file. Sharing that project on Github would expose your key for the entire world.
Is there a preferred way to configure the system so that the API_KEY can be kept locally?
And since the entire point of using react-native is to be cross-platform, is there also a way to configure this for iOS?
On Android, the answer turns out to be:
In the AndroidManifest.xml:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${googleMapsApiKey}"/>
Then in the android/build.gradle, add to defaultConfig:
manifestPlaceholders = [googleMapsApiKey:googleMapApiKey]
and above that, at the top level:
def googleMapApiKey = System.getenv("googleMapsApiKey")
Set the environment variable in your shell:
export googleMapApiKey = AI.......
In a comment above I found an article. It turns out to be slightly incorrect; it omits the necessary line about manifestPlaceholders.
Is Google Map street view available in Flutter? I know there is a plugin of Google Map but I couldn't find out if I can use Street view functionality.
I am the owner of flutter_google_street_view.
Flutter plugin flutter_google_street_view provides street view and support web, Android and iOS.
Try it! The usage steps shown below.
Usage Steps:
Get an API key at https://cloud.google.com/maps-platform/.
Specify your API key to your code.(Web, Android, iOS)
Create FlutterGoogleStreetView widget and the sample code show below.
StreetViewController? streetViewController;
FlutterGoogleStreetView(
initPos: LatLng(25.0780892, 121.5753234),
onStreetViewCreated: (StreetViewController controller) async {
//save controller for late using
streetViewController = controller;
//change position by controller
controller.setPosition(position: LatLng(37.769263, -122.450727))
}
)
Done and control FlutterGoogleStreetView by streetViewController.
The newest release version of the Google Maps JavaScript (3.32.13) is conflicting with Prototype.js version 1.7.3.
When I have Prototype included on the page, the Street View of Google Maps will not handle mouse drags to "look around"
Is this a known issue? Any workarounds?
So the problem is that PrototypeJS is overwriting Array.from as an alias to $A() which creates an extended Array object.
IF (big IF) you are not using Array.from to create a shallow copy of an array and expecting the Prototype extended methods, you can remove/comment out the line in prototype.js that is only
Array.from = $A;
In my copy of 1.7.3 it is line 1114
I also struggled with the conflict between Prototype.js and Google API. Removing Prototype.js was not an option as it is deeply engrained in the project. I decided to replace
Array.from = $A;
by
Array.from = Array.from || $A;
in the prototype.js file. It keeps the support for older browsers which do not have Array.from implemented natively. This does not solve the conflict between Prototype.js and Google API on older browsers though!
This site overrides Array.from() with an implementation that doesn't support iterables, which could cause Google Maps JavaScript API v3 to not work correctly.
I also have the same issue. So, I reopened a relevant GM API tkt: https://issuetracker.google.com/issues/72690631
I tried to rename the function collect into prototype.js but it didn't work.
I'm working with GoogleMaps an GooglePlaces API but I always obtain de same error.
"The operation couldn’t be completed. An internal error occurred in the Places API library. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/support)"
I've tried to run pod try GoogleMaps and when I launch de project any map is loaded, only a tableView with different options.
This is my code, I only want to obtain the user position:
-(IBAction)getCurrentPlace:(UIButton *)sender {
[placesClient currentPlaceWithCallback:^(GMSPlaceLikelihoodList *placeLikelihoodList, NSError *error){
if (error != nil) {
NSLog(#"Pick Place error %#", [error localizedDescription]);
return;
}
self.nameLabel.text = #"No current place";
self.addressLabel.text = #"";
if (placeLikelihoodList != nil) {
GMSPlace *place = [[[placeLikelihoodList likelihoods] firstObject] place];
if (place != nil) {
self.nameLabel.text = place.name;
self.addressLabel.text = [[place.formattedAddress componentsSeparatedByString:#", "]
componentsJoinedByString:#"\n"];
}
}
}];
}
I have imported mi APIKEY in didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[GMSServices provideAPIKey:#"MY_APIKEY"];
return YES;
}
And this is my Podfile
platform :ios, '7.0'
source 'https://github.com/CocoaPods/Specs.git'
target ‘googlePlace’ do
pod 'GoogleMaps'
pod 'GooglePlaces'
end
Finally, my apikey is configured to iOS application in Google Console.
What's the problem??
This looks like your API key is either invalid or out of quota.
Can you check that you are passing the correct API key to GMSPlacesClient.provideAPIKey(_:).
If you are sure that you are passing the correct API key check the Google API Console (https://console.developers.google.com/) to ensure you have not run over your daily quota limit.
This issue can be tracked here: https://issuetracker.google.com/issues/35830792
Answer my own question
https://developers.google.com/places/migrate-to-v2?hl=es-419
This fixed the problem
Migrating to Google Places API for iOS, version 2
With the version 2 release of the Google Maps SDK for iOS, the Google Places API for iOS has been split from the Google Maps SDK for iOS and is now distributed as a seperate CocoaPod.
Take the following steps to update your existing apps:
Update your Podfile to reference the GooglePlaces CocoaPod in addition to the GoogleMaps CocoaPod. If you are not using the Google Maps SDK for iOS, you can remove GoogleMaps.
If you are using the place picker, update your Podfile to reference the GooglePlacePicker CocoaPod in addition to GooglePlaces.
Rename GoogleMaps to GooglePlaces in all imports where you are using the Places API.
Specify your API key using GMSPlacesClient.provideAPIKey(:) instead of GMSServices.provideAPIKey(:).
Get the required open source license text using GMSPlacesClient.openSourceLicenseInfo() as well as GMSServices.openSourceLicenseInfo() if you are using the Google Maps SDK for iOS or the Place Picker.
After doing 8 to 12 hours R&D Found below solution. I am sure it will work.
Just add the key in AppDelegate.swift file, not any other class. It will solve your problem.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
GMSPlacesClient.provideAPIKey("KEY")
GMSServices.provideAPIKey("KEY")
}
Note: It is compulsory to initialize GMSPlacesClient in AppDelegate Because it will take some time for initialization.
2018 answer, well in my new job, we're having a hard time about this. My own Places key works but not my new company's Places key. After a few hours, I remember the time when I was setting my own keys, I HAD TO REFRESH or REGENERATE NEW KEYS for the Places API before I got it to work. Now back to my current situation, I told this to my colleagues and boom, we just had to refresh the key, and it worked! :)
In my drupal site, I have installed the gmap module. But that is in version 2.115. Now I got a mail from google that update the google API version. I have generated the API key version 3. But no idea about implementing them to the module files.
drupal_set_html_head(' $query))) .'" type="text/javascript">');
This I changed to
drupal_set_html_head('');
Also in gmap.js
obj.map = new GMap2(elem, obj.opts); changed to obj.map = new google.maps.Map(elem, obj.opts);
But after adding this, Javascript is required to view this map. is showing.
Please help me
See this thread on d.org. There are several patches and solutions.