c# - 如何从 Google 静态 map API 获取图像

标签 c# asp.net-mvc google-maps google-maps-api-3

我使用此代码从 Google API 生成静态图像,但我的请求太多,因此有时我会过度使用 Google。

string latlng = location.Latitude + "," + location.Longitude;
string path = "http://maps.googleapis.com/maps/api/staticmap?center=" + latlng +
   "&zoom=16&size=200x200&maptype=roadmap&markers=color:blue%7Clabel:S%7C" +
   latlng + "&sensor=false";

是否可以从 C# 调用它来生成和保存图像?我找不到获取图像对象的方法。

最佳答案

using (WebClient wc = new WebClient()) {
  wc.DownloadFile(url, @"c:\temp\img.png");
}

关于c# - 如何从 Google 静态 map API 获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11594702/

相关文章:

python - 如何将 Django 变量作为 javascript 方法参数传递?

c# - 像这样使用嵌套的 Try..Catch block 不好吗?

c# - 如何将 C# 对象列表导出到 Excel 电子表格?

c# - 以编程方式触发选择事件

jQuery 不显眼的 Ajax 表单在 'per-table-row' 场景中不起作用

html - 谷歌地图在 iOS 上通过框溢出

c# - 如何在ConfigureServices方法中获取IOptions?

C# 删除 HTML 代码并合并段落

asp.net-mvc - 为什么我的应用程序不使用脚手架身份页面?

Android - Google Places API 自动完成 sdk,如何只获得英文结果?