[英]create polylines in gmap and generate image
我正在尝试在asp.net中生成一个gmap图像。 我需要指定不同的纬度和经度,并用折线生成Google地图图像。 到目前为止,我能够使用以下代码创建图像:
protected void btnMap_Click(object sender, EventArgs e)
{
Save_Image("http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false");
}
private void Save_Image(string URL)
{
WebClient client = new WebClient();
string strFileName = DateTime.Now.GetHashCode().ToString() + ".png";
client.DownloadFile(URL, Server.MapPath("~/images/" + strFileName));
imgGmap.ImageUrl = "~/images/" + strFileName;
}
我找不到在此网址中传递经度和纬度的方法。 我已经检查了这个做相同事情的博客,但是我没有找到使用此演示生成图像的方法。
根据文档,您应该能够像这样指定折线的路径:
路径=颜色:0x0000ff |重量:5 | 40.737102,-73.990318 | 40.749825,-73.987963 | 40.752946,-73.987384 | 40.755823,-73.986397
例如
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false&path=color:0x0000ff|weight:5|40.702147,-74.015794|40.711614,-74.012318|40.718217,-73.998284
或者,您可以使用编码的折线格式(可用于大大缩短URL)。
您可以指定为:
&path = weight:3%7Ccolor:orange%7Cenc: polyline_data
要获取该polyline_data,您可以在此处使用在线表单: https : //developers.google.com/maps/documentation/utilities/polylineutility
您也可以根据以下规范编写算法: https : //developers.google.com/maps/documentation/utilities/polylinealgorithm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.