Last active
June 17, 2022 08:58
-
-
Save daniele-quero/38537bd7207942cd8170f9cadab6af55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapsAPIHandler | |
{ | |
public string googleStaticMapsAPIkey = "my_api_key"; | |
public string staticMapUrl = "https://maps.googleapis.com/maps/api/staticmap"; | |
public MapsRequest mapsRequest = new MapsRequest(); | |
//builds the API request object | |
public void GetStaticMapRequest(int width, int height) {...} | |
public IEnumerator DownloadMap(RawImage image, int width, int height) | |
{ | |
GetStaticMapRequest(width, height); | |
UnityWebRequest web = UnityWebRequestTexture.GetTexture(mapsRequest.Url); | |
yield return web.SendWebRequest(); | |
if (web.result == UnityWebRequest.Result.ConnectionError) | |
Debug.LogError(web.error); | |
else | |
image.texture = DownloadHandlerTexture.GetContent(web); | |
web.Dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment