Constructing Map URL Part 1!

addam davis
3 min readFeb 23, 2022

--

Objective: Understand what goes into making a Map URL!

In order to begin programming our map API we need to create a variable that is going to store the API key. In order to request a static map to download we need to use our API key from the last tutorial. Open the script for the location panel and create a public string variable to hold the API key.

Save this and navigate to the location panel in the editor. In the inspector copy and paste your API key into the API key variable.

To download a static map, we have to use what’s called a www request to fetch a URL. We are going to have a routine that’s going to download a response and within that response is going to be an image. For that we need to pass in information, and we need to download using our API key.

The next thing we need to do is pass in parameters. We also need to figure out what parameters we need to pass in. Let’s navigate back to the overview guide to static maps. Select the link “Maps static API developers guide”

We are going to be using the URL given with parameters. How do we get the parameters?

This guide provides some Usage examples. The parameter usage section explains how to use these parameters to construct our URL.

There is Latitude and Longitudes. This is all we need to get the map location and we are going to use our device to get that. These are defined using numerals.

The guide also provides an example using geolocation. The parameters used are, (center = longitude, latitude) zoom, size, API key.

This example is centering the image based on where you are in the world.

We are going to use this information in the next lesson to construct out URL. I’ll see you in the next tutorial!

--

--