有人可以告诉我如何统一使用Google Map API。
我知道如何使用静态地图,因为它是图像,但是另一个API都返回json,如何使用它,如何统一显示路线,我只找到java的方法,如何在c#中统一。>
https://developers.google.com/maps/documentation/directions/start
答案 0 :(得分:0)
您想通过以下方式处理传入的json: 将返回的json反序列化为一个类,然后使用您的结果。
Google Maps Platform Documentation-拥有您需要的所有请求参数和示例。
您还可以使用gmaps-api-net
之类的库如何进行网络请求:Microsoft WebRequest Documentation
这是我如何使用连接到统一的天气api的示例。 它从我的位置收集我需要的数据,这取决于我所在的天气,它开始下雪/下雨还是晴天/多云。 您可以以相同的方式使用Google Maps API。收集,提供并重复。
private async Task<WeatherInfo> GetWeather()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("http:/g/data/2.5/weather?id=" + CityId + "&APPID=" + API_KEY));
WebResponse response = await request.GetResponseAsync();
StreamReader reader = new StreamReader(response.GetResponseStream());
string jsonResponse = reader.ReadToEnd();
WeatherInfo info = JsonUtility.FromJson<WeatherInfo>(jsonResponse);
string weatherString = info.weather[0].main;
return info;