I've built a Flutter app using https://pub.dev/packages/google_maps_flutter for maps and I want to add directions as per https://medium.com/#shubham.narkhede8/flutter-google-map-with-direction-6a26ad875083, but I need to get the Google API key, which is injected into the app at build time in different ways depending whether it's Android or IoS.
I've spent about an hour googling, but I can't find a Flutter or native way of getting at the API key in the app. Is there a way?
If I understand rightly that you're trying to access the Google Maps API key from your native iOS and Android projects from within Flutter, this should work:
Use this: https://pub.dev/packages/flutter_native_config to read the Android manifest and the iOS Info.plist.
On Android the key will already be there as per the Google Maps docs.
You'll then need to move your API key in iOS to the info.plist then read it in instead of having it hardcoded: https://www.hackingwithswift.com/example-code/system/how-to-read-your-apps-version-from-your-infoplist-file
Related
I have rendered google map in xamarin form iso but it is not working in android. I don't know if I am doing something wrong in my android setup or not.
My question is: can we use single google map api key in both application?
In google console I see:
Application restrictions specify which web sites, IP addresses, or apps
can use this key. You can set one restriction type per key.
Where i can choose only one option among http, ip, android and ios.
If tutorial link for google map in xamarinform would also be appreciated. I am using googlemaps nuget package.
According to Google, you should be using a different API key for Android and iOS for a better understanding I would suggest you read this document.
In your case, I would recommend you create an API key for your iOS app and another client API key for your Android app (different than the iOS one).
On your Developer console select create a new API key, you can see that Google gives you different choices: server key, browser key, iOS key, Android key, etc. Each different key serves different purposes and should be limited to the corresponding platform only (e.g.: do not put a server key in a client app like an iOS app, and vice versa).
As of an example, you can check this out.
The answer is Yes. You can use the same Google map api key in both application (Android/iOS), just use Xamarin.Forms.GoogleMaps NuGet
You can found a tutorial for GoogleMaps in Xamarin Forms in this answer.
I am trying to build a google maps app. The app runs but I am unable to retrieve the map UI.
Logs shows :Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
06-16 22:45:50.480 13860-14718/com.mapsapi.vatsan.googlemapsapidemo E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: **************************************
Android Application (;): 24:85:5A:C0:F8:0D:36:4C:1A:B9:45:B6:21:92:B0:6E:7D:71:55:08;com.mapsapi.vatsan.googlemapsapidemo
I have used the correct API Key.
What exactly i have to do?
I know there are diferent keys for debug and released apps.
i recomend API v3 too.
Try this to register your api key.
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=24:85:5A:C0:F8:0D:36:4C:1A:B9:45:B6:21:92:B0:6E:7D:71:55:08%3Bcom.mapsapi.vatsan.googlemapsapidemo
It can take some minutes. Then you have to set your google_maps_key in your android app Manifiest.
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSDSSDDDAAD...Your API KEY" />
If doesnt work and if you are using android studio, try creating a new Map Activity(It's V3), complete res/values/google_maps_api.xml with the key and the map gonna work.
How to create google map
We are building hybrid app which will be on ios and android.
Our app is using google static map api. I'm not sure if we need ios key or web key for that.
right now I just generated web key, but then how authentication of key will work on it, since its not ios SDK map.
Google Static Maps API needs a web api key.
Pass your API KEY with 'key' parameter like below.
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap
&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
&markers=color:red%7Clabel:C%7C40.718217,-73.998284
&key=YOUR_API_KEY
https://developers.google.com/maps/documentation/static-maps/intro
Static Maps API has nothing to do with iOS and Android Maps SDKs. It is a separate API so you need the Static Maps API enabled on the project and generate a key for this API.
It simply allows you to embed a map image in your app, but the downside is that it cannot be made interactive.
A very useful tip on using the Static Maps API on a mobile device is to look at screen resolution of the target device and adjust the scale parameters.
I bought an API key for Google Map. I tried to implement the client key in a PhoneGap application.
<script src="http://maps.googleapis.com/maps/api/js?client=YOUR_CLIENT_ID&v=3.17"></script>
However, it doesn't work. I have an alert with the message: "your domain is not permitted."
I can't put a domain in the admin console, because it's a phonegap app and the file protocol doesn't work well too.
How can I use the client key with a phonegap app ?
Many thanks
I think Google Maps Javascript API v3 for work does not work on PhoneGap/Cordova, because the API refers the domain of the page.
You can still use Google Maps Web APIs (direction APIs, geocoding APIs ... etc) with your key.
Ask your Google Maps reseller (or directly Google support team).
I want to implement autocomplete feature for google places.
I have created a project on google with places api service enabled.I am using iOS key for getting json data but getting following JSON response
{
"predictions" : [],
"status" : "REQUEST_DENIED"
}
I am also trying same request in safari with browser key, but still I am getting same response.
Please help.
Though this question has been answered by the creator itself, but I would like to tell few more points in detail as many people face this issue.
If you are using Google Pods / SDK then create iOS Key / Android Key whichever you want depending on your implementation.
If you are planning to use places API for autocomplete,
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Amoeba&types=establishment&location=21.76999,-122.44696&radius=500&key=[YOUR_API_KEY]
then the API Keys for iOS / Android will not work, for this case you would need to create a Browser Key from google console.
NOTE: If you want to use places API in your project don't forget to enable
from
Google Developer Console as shown below:
After this run your project / API you will get JSON response.
solved it..every parameter was OK but I sent sensor=false in the URL when I was using laptop.