Journal 128 — Unity App Development, Add Google Geo Location Services

Objective: To add option to show user location in map automatically

In the previous article, I put together the Google Maps static map on one of the app screens. In this article, I will add an option to use LocationServices to get the user location to generate the static map.

In one of the previous articles, I put together an option to type in an address or city and state or even landmark on the location screen. I have commented out these game objects and code so that they can be used later.

We can update the LocationPanel script with this example script from Unity documentation to check if the user has location services enabled, and if so, start retrieving the location.

As you can see, we can pull the last data latitude and longitude, which we can then use in the Google static map request.

Now we can test this functionality.

However, in order for location services to work, you need to test on a mobile device, and also make sure you allow location services on your device.

After creating a build, I used Dropbox to transfer the apk file to my device. Before starting, I checked the permissions to allow location.

Now let’s test out the app. I’m using Vysor to screen share my phone.

I have some plans to later add markers, and make the zoom adjustable, but this is a good basis for now.

Thank you for your time!

--

--

--

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Setup Your Git Repository Init

Flutter — Tests

Install PostgreSQL extension pglogical on macos

Ways to stream audio & video between devices

Database Migration: What You Need to Know

The Top 6 JavaScript frameworks for 2020

My Experiences at Developer Conference Zambia 2019

Using GitHub with GameDevHQ Certification in Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Nielsen

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

More from Medium

Journal 135 — Unity App Development, Interactive Map Info Cards with Scriptable Objects

A Series On Creating Immersive Audio in Unity with Custom Wwise Scripts

Unity Animation Event Explained

Gamedev Log: “The Escape” #9 (Unity/C#)