簡體   English   中英

在gmap中創建折線並生成圖像

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM