์ ๋ํฐ์๋ค๊ฐ ๊ตฌ๊ธ์ง๋์ข ์ฐ๋์์ผ๋ณผ๋ ค๊ณ ํ๋๋ฐ ์๊พธ ๋นจ๊ฐ์ ๋ฌผ์ํ๊ฐ ๋จ๊ณ ์๋ ์ํ์ผ
api key๋ google static map api key ๋ฐ์์ ์ฌ์ฉํ๊ณ ์๋๋ฐ ์ด๋์ ๋ฌธ์ ๊ฐ ๋๊ฑด์ง ๋ชจ๋ฅด๊ฒ ์ด
๊ทธ๋ฅ ์ ํ๋ธ๋ ๋ค๋ฅธ ๋ธ๋ก๊ทธ์์ ๊ฐ์ ธ์จ ์์ค ๊ทธ๋๋ก ๋ฐ์์ ์ฌ์ฉํ๊ณ ์๋๋ฐ ์กฐ์ธ์ข ํด์ค
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GoogleApiTest : MonoBehaviour
{
public RawImage img;
string url;
public float lat;
public float lon;
LocationInfo li;
public int zoom = 14;
public int mapWidth = 640;
public int mapHeight = 640;
public enum mapType { roadmap, satellite, hybrid, terrain }
public mapType mapSelected;
public int scale;
IEnumerator Map()
{
url = "https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap & markers = color:blue % 7Clabel: S % 7C40.702147,-74.015794 & markers = color:green % 7Clabel: G % 7C40.711614,-74.012318 & markers = color:red % 7Clabel: C % 7C40.718217,-73.998284 & key = ๋ด ๊ตฌ๊ธapi key";
WWW www = new WWW(url);
yield return www;
img.texture = www.texture;
img.SetNativeSize();
}
// Start is called before the first frame update
void Start()
{
img = gameObject.GetComponent<RawImage>();
StartCoroutine("Map");
}
// Update is called once per frame
/* public RawImage kRawImg;
public string strBaseURL = "https://maps.googleapis.com/maps/api/staticmap?center=";
public double dLatitude = 37.4014171; // ์๋
public double dLongitude = 127.1102274; // ๊ฒฝ๋
public int iMapZoom = 14;
public int iMapWidth = 640; // ๋ฌด๋ฃ ์ง์ ์ต๋ ํด์๋
public int iMapHeight = 640; // ๋ฌด๋ฃ ์ง์ ์ต๋ ํด์๋
public string strPath = "weight:3%7Ccolor:blue%7Cenc:{coaHnetiVjM??_SkM??~R";
๋ด ๊ตฌ๊ธapi key"; // ๋ณธ์ธ์ด ๋ฐ๊ธ ๋ฐ์ API ํค ์ ๋ ฅ(์์ด๋ ๋จ)IEnumerator map()
{
string url = strBaseURL + dLatitude + "," + dLongitude +
"&zoom=" + iMapZoom.ToString() +
"&size=" + iMapWidth.ToString() + "x" + iMapHeight.ToString() +
"&path=" + strPath + strGoogleAPIKey;
Debug.Log("URL: " + url);
WWW www = new WWW(url);
yield return www;
kRawImg.texture = www.texture;
kRawImg.SetNativeSize();
}
// Use this for initialization
void Start()
{
kRawImg = gameObject.GetComponent<RawImage>();
StartCoroutine(map());
}
// Update is called once per frame
void Update()
{
}*/
}
RawImage๋ง๊ณ Image์จ๋ ๊ทธ๋ผ?
๊ทธ๊ฑด ์ํด๋ดค๋ค ๋ง์ฝ Image๋ก ํ๊ฒ๋๋ฉด img.texture ๋์ ๋ญ ์จ์ผํด?
www ๋ฆฌํด์จ๊ฑฐ์ ๋ฉ์ธ์ง์์? - dc App