Google offers developers access to a plethora of Google Maps features for active development. Google Maps features 99% coverage of the entire world, including over 200 countries and territories. The information is accurate and is in real-time, with 25 million updates to the data every day.
With a developer account and a Google Maps API key, you can create customized experiences that make use of Street View photos, build routes, discover places, and more.
Creating API keys
The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.
To create an API key:
In the Cloud Console, on the project selector page, select or create a Google Cloud project for which you want to add an API Key.
Go to the APIs & Services > Credentials page.
- On the Credentials page, click Create credentials > API key.
The API key created dialog displays your newly created API key. - Click Close.
The new API key is listed on the Credentials page under API keys.
(Remember to restrict the API key before using it in production.)
How does the API key work?
The API is available for developers that have a free Google Maps API key. Usage of the API is not strictly free, but they do offer $200 of free monthly usage for most users. The pricing scales to fit your particular needs and you are only charged for your API usage. Some features are free for mobile but not for other platforms. There are also volume discounts available for high-use applications.
Once you have an account and a free Google Maps API key, you can start working with the API directly. The key is a unique identifier that authenticates requests for your application.
What you can expect from the Google Map API key?
Google provides excellent documentation for its APIs, including Guides, tutorials, sample projects, a Stack Overflow tag, issue tracker, and more.
For both Android and iOS, there is a Maps and Places SDK.
The following Web APIs are available:
- Maps Embed API
- Maps JavaScript API
- Places Library
- Maps Static API
- Street View Static API
The following Web Service APIs are available:’
- Directions API
- Distance Matrix API
- Elevation API
- Geocoding API
- Geolocation API
- Places API
- Roads API
- Time Zone API
They also offer a cross-platform Maps URL solution for launching Google Maps and initiating actions like search or directions.
Adding the API key to your app
You should not check your API key into your version control system, so we recommend storing it in the local.properties
file, which is located in the root directory of your project. For more information about the local.properties
file, see Gradle properties files. The following Gradle technique shows you how to store an API key in your local.properties
file so that it can be securely referenced by your app.
To add your API key:
- Open the
local.properties
in your project level directory, and then add the following code to the file. ReplaceYOUR_API_KEY
with your API key. - In your app-level
build.gradle
file, add this code in thedefaultConfig
element. This allows Android Studio to read the Maps API key from thelocal.properties
file at build time and then inject themapsApiKey
build variable into your Android manifest. - In your
AndroidManifest.xml
file, add the following code as a child of theapplication
element. - Save the files and sync your project with Gradle.
Adding the API key to your request for Java Script
You must include an API key with every Maps JavaScript API request. In the following example, replace YOUR_API_KEY
with your API key.
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY &callback=initMap"
type="text/javascript"></script>
Thank you! Works perfectly for me :D
ReplyDelete