Objective: Create our own custom URL!
Now that we know what makes up a URL we can now create our own. For reference let’s copy the example URL and paste it into our code and comment it out.
We need to make use of this URL. Up to the “/staticmap?” is the URL. From there we are going to append a center. The center is going to be your x coordinates and y coordinates. Then a zoom, which is how focused on the image you are. Followed by a size, which the example is 400 x 400 pixels.
This is all the information we need to download an API. We are going to construct a URL and to do this we need make these parameters into variables.
Now we need to populate this data. The x and y cord are going to come from your mobile device. The zoom and image size can be set in the inspector.
Now that we have that we can begin constructing the URL. Let’s begin by creating a string variable to hold the URL.
Constructing the URL, we use the variables and breaking apart the example we now the order to we need. We need the URL variable and using strings and corresponding variables.
Save this and since we used public variables, we can see the URL become constructed in the inspector.
That’s it for constructing a URL. In the next tutorial we are going to cover downloading the image. I’ll see you in the next tutorial!