GoogleApi
1.0.0
无缝 Google Api 集成。
Google 地图、地点、道路、搜索和翻译。
请随意贡献、提出问题和报告问题。我通常回复速度很快(24-48 小时)。
您需要额外的 .Net 框架支持吗?请告诉我。
新增内容:版本 5.0.0 包含路线 Api(方向和矩阵)、Ariel View Api 和地址验证 Api。
可以通过使用单独的 Facede 实现或通过依赖项注入单独的 api 来使用该库。
每个 api 实现都包含一个请求和一个响应。请求具有反映支持的参数的属性,响应表示返回的 json 的对象模型。
其他一些值得注意的成员。
var uri = request . GetUri ( ) ; // Gets the full request uri, including query parameters.
var params = request . GetQUeryStringParameters ( ) ; // Gets a list of all the added parameters.
response . RawJson // The raw json returned by Google.
response . RawQueryString // The querystring sent to Google when invoking the request.
每个 api 都有一个通用的外观操作来执行请求并返回响应。
下面的示例仅填充请求、调用外观操作并接收返回的响应。
TRequest request = new TRequest ( ) ;
TResponse response = await { Api } . [ { SubGroup } ] . { Action } . QueryAsync < TRequest , TResponse > ( request ) ;
请参阅下文,了解支持的 Api 和操作的完整列表。
如果首选将 api 作为依赖项注入,请在启动期间注册服务,如下所示。
services
. AddGoogleApiClients ( ) ;
然后,根据需要将各个 Api 注入构造函数中
public class MyClass
{
private Api api ;
public MyClass ( Api api )
{
this . api = api
}
}
请参阅下文,了解支持的 Api 和操作的完整列表。
如果需要WebProxy
,请在注册 GoogleApi 依赖项或使用 Facade 之前设置静态属性HttpClientFactory.Proxy
。
支持以下 api。
GoogleMaps.Directions
)GoogleMaps.DistanceMatrix
)GoogleMaps.Elevation
)GoogleMaps.Geocode.PlaceGeocode
)GoogleMaps.Geocode.AddressGeocode
)GoogleMaps.Geocode.LocationGeocode
)GoogleMaps.Geocode.PlusCodeGeocode
)GoogleMaps.Geolocation
)GoogleMaps.Roads.NearestRoads
)GoogleMaps.Roads.SnapToRoad
)GoogleMaps.Roads.SpeedLimits
)GoogleMaps.Routes.Directions
)GoogleMaps.Routes.Matrix
)GoogleMaps.AddressValidation
)GoogleMaps.AerialView.GetVideo
)GoogleMaps.AerialView.RenderVideo
) GooglePlaces.Search.FindSearch
)GooglePlaces.Search.NearBySearch
)GooglePlaces.Search.TextSearch
)GooglePlaces.Details
)GooglePlaces.Photos
)GooglePlaces.AutoComplete
)GooglePlaces.QueryAutoComplete
) GoogleSearch.WebSearch
)GoogleSearch.ImageSearch
)GoogleSearch.VideoSearch.Channels
)GoogleSearch.VideoSearch.Playlists
)GoogleSearch.VideoSearch.Vidoes
) GoogleTranslate.Detect
)GoogleTranslate.Languages
)GoogleTranslate.Translate
) 运行测试套件很简单。
测试项目将与您的 Google 订阅(免费或付费)相关的设置存储在application.default.json
中。
最重要的是ApiKey
,用于识别 Google 订阅。
{
"ApiKey" : " " ,
"SearchEngineId" : " " ,
}
有关生成密钥的更多信息可以在这里找到:https://console.developers.google.com/