Boost Your Business with Expert Software Solutions : Book a Consultation

Google Maps Integration in Android

2 decades experience software company

15+ Years of Experience

Trusted small-scale to enterprise software development company

800+ Projects Completed

Flexible Software Solutions: Your Choice, Your Project

Flexible Engagement Models

Scalable Software Solutions, Personalized to Your Needs: 100% Client Satisfaction Guaranteed

100% client Satisfaction

We welcome you to the right article to know how to build the latest google maps version in android applications. With the Maps SDK for Android, you can integrate Google Maps based on Google Maps data to Android mobile applications. Android Google Maps helps you to find out the location easily with lat long. It also provides you a lot of stuff like placing markers, zooming controls, etc.

Before going into the project creation, first things first should be done is Android Google Maps API integration. We need the SHA-1 key and the package name in order to get our application ID from Google Console.

Generate SHA-1 key on Windows

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Generate SHA-1 key on Linux/Mac

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

You can create an SHA-1 key using the above commands or else there is another way to release debug SHA-1 key. Go to Android Studio and click on Gradle which is located on the right side under that you need to click on “app->android->signingReport”. Now automatically one of the bottom tabs will open and list you the details of your application. Copy the SHA-1 key and we are ready now to generate our API key in Google Console.

API Key Management in Google Console

How to generate API key in Google Console

Google Cloud Platform, Redirect to that URL and log in with your Google account. If you are new here then you need to create a project first. If the project already exists then you can go inside it.

Google Services Integration

Click on the side menu and you’ll be shown with a sidebar with some options where you can click on “APIs & Services->Credentials”, which will redirect you to the credentials page where we can create our API keys inside it.

On top there will be a label called “create credentials”. When you click on it, it’ll drop you options where you can create different keys for different integrations. As of now we need to click on the API key. Inside the API key creation, we need to paste our package name and SHA-1 key which we generated a second ago.

You can find out your package name in Manifest or Gradle file. But make sure we need to restrict to Android inside the API key creation in order to make work on only android apps.

Google Maps API Key Overview

Once we are done with all those above steps click on save. We are done with the generating API key. Copy the API key and keep it aside for a minute.

Google Maps API Key Access

All the way to coding

Now come back to Android Studio and it's time for coding. Add dependency of google map in order to access all the functionalities into our application.

dependencies { Implementation 'com.google.android.gms:play-services-maps:16.1.0' } 

After adding it now it’s time to do some code in the Manifest file. Go to Manifest file and place this code. Replace your API key inside the value which you’ve recently generated in Google Console.

Add permissions which are used in maps

ACCESS_NETWORK_STATE INTERNET ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION 

Add all these permissions inside the Manifest file.

Coming back to the MapActivity you need to design your map using fragments. Place this fragment in your MapActivity XML file.

fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/map" tools:context=".MapsActivity" android:name="com.google.android.gms.maps.SupportMapFragment" 

Fragment is also known as 360 degree activity where we can use it for maps and normal screens too.

In MapActivity you need to call the Support Map Fragment which you’ve declared in the xml file. You need to initialize it inside the onCreate method.

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); 

Everything inside the OnMapReady Method

When you initialize it, It’ll ask you to implement the method of maps which is known as “onMapReady()”. Simplest way to implement the method is: Place your cursor on “getMapAsync(this)” and press “Alt+Enter”. It’ll ask you to implement the method automatically.

Now you can see a method name called “onMapReady()”.

 @Override public void onMapReady(GoogleMap googleMap) { } 

Inside this method you can place your markers on a map wherever you want, You can animate your camera, Markers can be customized and a lot more.

For placing markers you need lat lon of any place where you wanted to show. Market Options class is used to do that thing.

 double latitude = ; double longitude = ; MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps "); googleMap.addMarker(marker); 

Wanted to change the color of the marker which you’ve created? Then use the below code.

marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)); 

By creating a marker you’ll always get the default marker icon. You can just change colors from it. If you want to place your own marker then we need to do like this. Place your image inside the drawable/mipmap folder and use it like below.

marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.my_marker_icon)));

When we load maps we always want to zoom to a particular location without user interference. We can animate our map using the Animate Camera class in it.

CameraPosition cameraPosition = new CameraPosition.Builder().target( new LatLng(17.385044, 78.486671)).zoom(12).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 

We can Change our Map Type

As we all know that map has different types in it. We all are well known to google maps on our mobile devices.

googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); googleMap.setMapType(GoogleMap.MAP_TYPE_NONE); 

Note - By default google maps are set to NORMAL.

Some of the controls which we can handle in Maps

 googleMap.setMyLocationEnabled(true); googleMap.getUiSettings().setZoomControlsEnabled(false); googleMap.getUiSettings().setZoomGesturesEnabled(false); googleMap.getUiSettings().setCompassEnabled(true); googleMap.getUiSettings().setMyLocationButtonEnabled(true); googleMap.getUiSettings().setRotateGesturesEnabled(true); 

As I’ve shown the basic functionalities used in map, Google provides a lot more things in it.

Note - After all this stuff you need to enable Google Maps API in Google console in order to run your application.

Tips to Hire a Mobile app development Company that can grab your vision.

Develop your first android mobile application using google maps integration with Amar Infotech. In case any of your questions remain unanswered, you can directly talk to us, or leave us an email at sales@amarinfotech.com.

Voice Of Customers

Understand what drives customer satisfaction and loyalty through their genuine feedback and insights.

Happy Client Recommends Top Phoenix App DevelopersPhoenix Mobile App Development Company Client Testimonial

We've been working with Amar Infotech since 2014 on our project, Lyrics Guru. Their team provided top-notch Flutter Mobile App development along with a Laravel admin panel, perfectly meeting our needs.

Over the years, their consistent support and expertise have been invaluable to us.

We highly recommend Amar Infotech for their exceptional service and dedication to client success.

Happy Customer Recommends Top Sri Lanka Travel and Tour CMS Website Development CompanySatisfied Customer Reviews Best Travel and Tour CMS Websites in Sri Lanka

Hi, I'm Philipp Müller, CEO of a Tour and Travel Agency in Sri Lanka. We chose Amar Infotech to bring our website to life with their Tour Package Extranet Services.

hey delivered excellent service, developing a Laravel-based backend that allows us to create and customize our own tour packages easily.

I highly recommend Amar Infotech for their professionalism and expertise in web development.

Client Testimonial - Best Travel App in the USA - Goeasyaviation and GoeasyticketPositive Feedback on Goeasyaviation and Goeasyticket Air Shipping, Flight, and Hotel Booking

Hello, my name is Tito. We would like to extend our gratitude to Amar Infotech for their invaluable assistance in developing our website and app.

They were extremely helpful throughout the entire journey, guiding us every step of the way. Their professionalism is second to none.

Thanks to them, we now have a fully functional Flight Booking website that perfectly meets our needs.

Professional Travel Website Development: Amar Infotech - Sammy Tours Positive ReviewTop-Rated Travel Website Agency: Sammy Tours Client Testimonial for Amar Infotech

I am the owner of Sammy Tours Sri Lanka, and I am thrilled with Amar Infotech for designing and developing my travel and tourism website.

They created a custom website that perfectly showcases our tour packages for Sri Lanka. Their expertise and dedication have significantly impacted our business.

I highly recommend Amar Infotech for their exceptional service and commitment to excellence.

Why Amar Infotech ?

Flexible IT Solutions Provider

On-demand, Flexible

Select the ideal remote team tailored to your business needs.

Affordable IT Services

Cost Benefit

Enjoy up to 30% savings with our competitive solutions.

Experienced IT Consulting Team

Experts Talent

Leverage the expertise of over 100 skilled IT professionals.

Compliance and Security Standards

Risk Free Delivery

Ensure success with agile project management and consistent, reliable outcomes.

Why Choose Amar InfoTech - Trusted IT Partner

Innovative Solutions

Benefit from cutting-edge technology and creative approaches that drive your business forward.

Amar InfoTech - IT Services Brochure for Download

Download Our Brochure for Exclusive Insights!

Discover how we drive success with innovative solutions tailored for your needs. Get a comprehensive overview of our expertise and achievements in just one click.

Download Now

Awards & Recognitions

Celebrating our journey of excellence with accolades that inspire us to reach new heights.

Amar Infotech Top Software Developers - Clutch
Top Software Development Company Amar Infotech - Goodfirms
Amar Infotech Best Company to Work with - GoofFirms
Top 10 Custom Software Development Company - Amar Infotech
Amar Infotech Top Rated Software Development Company
Top Web Development Company - Amar Infotech

Global Presence & Representative

Expanding horizons with a global network of representatives dedicated to delivering excellence across borders.

Amar Infotech Web Development Office in India

India (HQ)

4th Floor, Sunrise Avenue, Stadium - Commerce Six Road, Ahmedabad, INDIA

sales@amarinfotech.com
Amar Infotech Mobile App Development Office in the USA

USA

AI Jones (Account Executive), Phoenix, AZ 85013, 1.623.205.2415

ajones@amarinfotech.com
Amar Infotech Software Consulting Office in Canada

Canada

Ronak Patel (Sales Person), 64 caranci crescent Brampton ON Canada

ronak@amarinfotech.com
Amar Infotech Graphic Design and IT Services Office in Australia

Australia

Jessica (Sales Person), 9 nirimba drive quackers hill nsw 2763

jessica@amarinfotech.com
Amar Infotech Digital Solutions Office in the Netherlands

Netherlands

Adam (Sales Person) in Breda, Netherlands

adam@amarinfotech.com