Google maps api key for mobile - google-maps

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.

Related

How to get Google API key in Flutter Application

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

Can we use single google map api key for both xamarin form android and xamarin form ios?

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.

Geocoding API key should be server-restricted

On the notes of this page, there is a mention that the Geocoding API key should be server-restricted
During development and testing, you can register a project for testing
purposes in the Google API Console and use a generic, unrestricted API
key. When you are ready to move your app or website into production,
register a separate project for production, create a server-restricted
API key, and add the key to your application.
Is the geocoding API only meant to be used on a server type instance?
Can I put the Geocoding API key on a mobile device by bundling it within the app using restriction for android/ios? I'm concerned that I will violate the said "server-restricted API key" clause.
PS. I'm aware that Google API keys can be restricted to android/ios/ip etc.
In order to make Google Maps Web Service requests from a mobile device (without using the Google Maps SDK), you have to use an unrestricted key. Each mobile device has its own IP address and it is not feasible to set IP address restrictions to all the mobile devices that use your app.
Android or iOS API key application restrictions only work for requests made through the Android or iOS SDK.
If you want to use a restricted key for web service requests from mobile devices, you have to use a proxy server that makes the requests on behalf of the mobile app.
I’ve been reading the documentation and it seems that the Geocoding Web Service API is not fit for my use case. There is a “Javascript Google Maps API” that I can use.

Cannot Locate Google Maps Static Map API Key

How do I obtain an API Key to embed static Google Maps images in my website?
So I want to embed Google Maps images on my site for locations I have the lat and long for. Building the URL is easy enough, but I'm having a world op trouble locating my API Key.
I've enabled the Static Maps API in the console, but the documentation I can find (https://developers.google.com/maps/documentation/embed/guide) specifies that I should proceed to the Services item in the left-hand menu. However, there is no such Services item in the left-hand menu in the Console. And the screen captures included with the documentation seem to refer to earlier versions of the Console (mine is more modern and responsive--unfortunately, I cannot include a screen capture).
How do I obtain an API Key to embed static Google Maps images in my website?
First of all, the document you have linked is a different API altogether.
Here's the link for Static Map API key documentation.
Now with regard to locating the API key, you're probably looking at an updated version of Developers Console. On Left go to APIs & auth instead.
Choose the API(s) you want for your application. Activate them.
Then go to Credentials on left. This is where you'll find the key.

Google Maps API for Work and phonegap / cordova

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).