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!



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.