谷歌地图API支持的.NET库

12
我正在寻找一个.NET库或封装器,用于Google Maps,其中包含所有类型的响应作为C#类。
我希望能够做到以下操作:
var url = "http://maps.googleapis.com/maps/api/geocode/json?address=Wellington&sensor=false";

//Utility functions would be ideal                  
string jsonResponse = GoogleMaps.GetJson(url);
string jsonResponse = GoogleMaps.GeocodeAddress("Wellington");

我希望能够像这样使用结果:

GeocodeResponse r = JsonConvert.DeserializeObject<GeocodeResponse>(jsonResponse);    //I am using Json.NET

if(r.status.Equals("OK"))
{
    DoSomethingWith(r.result.formatted_address);    //intellisense documentation for all the bits in the result would be great
}

有这样的东西吗?

这有点像以下问题:

但那里的答案不是我想要的,我不需要拖放地图控件。

2个回答

3

gmaps-api-net(现在在GitHub上)已经过时。 - Alex P.

3

Google Maps API的.NET包装库:

  1. GoogleApi
  2. google-maps

gmaps-api-net已经过时(截至本回答时间)- 最后一次更新Directions API是在2016年。

GoogleApi的使用示例:

using GoogleApi.Entities.Common;
using GoogleApi.Entities.Maps.Directions.Request;
using GoogleApi.Entities.Maps.Directions.Response;

public void GetRoute()
{
    DirectionsRequest request = new DirectionsRequest();    

    request.Key = "AIzaSyAJgBs8LYok3rt15rZUg4aUxYIAYyFzNcw";

    request.Origin = new Location("Brasov");
    request.Destination = new Location("Merghindeal");

    var response = GoogleApi.GoogleMaps.Directions.Query(request);

    Console.WriteLine(response.Routes.First().Legs.First().DurationInTraffic);
    Console.WriteLine(response.Routes.First().Legs.First().Distance);
    Console.WriteLine(response.Routes.First().Legs.First().Steps);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接