如何从谷歌静态地图API获取图像 [英] How to get image from Google static map API

查看:487
本文介绍了如何从谷歌静态地图API获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个code生成从谷歌API的静态图像,但我有太多的要求,所以有时我从谷歌得到过度使用。

 字符串经纬度= location.Latitude +,+ location.Longitude;
字符串路径=htt​​p://maps.googleapis.com/maps/api/staticmap?center=+经纬度+
   和缩放= 16安培;大小= 200×200和放大器;地图类型=路线图和放大器;标记=颜色:蓝色%7Clabel:S%7C+
   经纬度+&放大器;传感器=假;

是否有可能从C#调用这个生成和保存图像?我不能找到办法让图像对象。


解决方案

 使用(Web客户端WC =新的WebClient()){
  wc.DownloadFile(URL,@C:\\ TEMP \\ img.png);
}

I use this code to generate static images from Google API, but I have too many requests, so sometimes I get overuse from 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";

Is it possible to call this from C# to generate and save images? I can't find way to get an image object.

解决方案

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

这篇关于如何从谷歌静态地图API获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆