静态 google 地图 api 中的数百个图钉
Hundreds of pins in static google map api
这很好用:
static void Main(string[] args)
{
string latlng = "55.379110,-3.1420898";
string url = "http://maps.googleapis.com/maps/api/staticmap?center=" + latlng +
"&zoom=6&size=1000x1000&maptype=satellite&markers=color:blue%7Clabel:S%7C" +
latlng + "&sensor=false";
using (WebClient wc = new WebClient())
{
wc.DownloadFile(url, @"C:\Bla\img.png");
}
}
只是想知道,我怎样才能添加数百个图钉并将地图另存为 png?当然get请求是有限制的,不能附加太多的查询字符串参数。
PS:限制为 8192 个字符 - 请参阅 https://developers.google.com/maps/documentation/static-maps/intro 部分 URL 大小限制
您将不得不处理来自 Google 静态地图 API 的 url 大小限制。
https://developers.google.com/maps/documentation/static-maps/intro#url-size-restriction
URL Size Restriction
Google Static Maps API URLs are restricted to 8192 characters in size.
In practice, you will probably not have need for URLs longer than
this, unless you produce complicated maps with a high number of
markers and paths. Note, however, that certain characters may be
URL-encoded by browsers and/or services before sending them off to the
API, resulting in increased character usage. For more information, see
Building a Valid URL.
添加多个标记:
https://developers.google.com/maps/documentation/static-maps/intro
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=YOUR_API_KEY
恐怕下载和存储静态地图图像是违反服务条款的:
You may not store and serve copies of images generated using the Google Static Maps API from your website. All web pages that require static images must link the src attribute of an HTML img tag or the CSS background-image attribute of an HTML div tag directly to the Google Static Maps API so that all map images are displayed within the HTML content of the web page and served directly to end users by Google.
https://developers.google.com/maps/faq?csw=1#tos_staticmaps_reuse
您可能还对以下内容感兴趣:Issue 207: KML layer in Static Maps API
这很好用:
static void Main(string[] args)
{
string latlng = "55.379110,-3.1420898";
string url = "http://maps.googleapis.com/maps/api/staticmap?center=" + latlng +
"&zoom=6&size=1000x1000&maptype=satellite&markers=color:blue%7Clabel:S%7C" +
latlng + "&sensor=false";
using (WebClient wc = new WebClient())
{
wc.DownloadFile(url, @"C:\Bla\img.png");
}
}
只是想知道,我怎样才能添加数百个图钉并将地图另存为 png?当然get请求是有限制的,不能附加太多的查询字符串参数。
PS:限制为 8192 个字符 - 请参阅 https://developers.google.com/maps/documentation/static-maps/intro 部分 URL 大小限制
您将不得不处理来自 Google 静态地图 API 的 url 大小限制。 https://developers.google.com/maps/documentation/static-maps/intro#url-size-restriction
URL Size Restriction Google Static Maps API URLs are restricted to 8192 characters in size. In practice, you will probably not have need for URLs longer than this, unless you produce complicated maps with a high number of markers and paths. Note, however, that certain characters may be URL-encoded by browsers and/or services before sending them off to the API, resulting in increased character usage. For more information, see Building a Valid URL.
添加多个标记:
https://developers.google.com/maps/documentation/static-maps/intro
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=YOUR_API_KEY
恐怕下载和存储静态地图图像是违反服务条款的:
You may not store and serve copies of images generated using the Google Static Maps API from your website. All web pages that require static images must link the src attribute of an HTML img tag or the CSS background-image attribute of an HTML div tag directly to the Google Static Maps API so that all map images are displayed within the HTML content of the web page and served directly to end users by Google.
https://developers.google.com/maps/faq?csw=1#tos_staticmaps_reuse
您可能还对以下内容感兴趣:Issue 207: KML layer in Static Maps API