如何显示在ASP.Net GridView控件雅虎静态地图?地址用于装载地图将存在于的GridView的列中的一个,并根据每一行的静态地图对各行要显示的地址。

有帮助吗?

解决方案

我已经完成了代码来显示ASP.Net网页上静态地图。我们可以称之为在GridView的行数据绑定事件和显示雅虎静态地图的DisplayYStaticMap方法中的GridView也

公共静态字符串DisplayYStaticMap(串streetName,串CITYNAME,串Statename的,INT imgWidth,INT imgHeight,INT变焦)         {             Web客户端WC =新Web客户端();

        StringBuilder strb = new StringBuilder();
        strb.Append("http://local.yahooapis.com/MapsService/V1/mapImage?Appid=YOURAPIID--&");
        if (streetName != "")
        {
            strb.Append("street=");
            strb.Append(streetName);
        }
        if (CityName != "")
        {
            strb.Append("&city=");
            strb.Append(CityName);
        }
        if (stateName != "")
        {
            strb.Append("&state=");
            strb.Append(stateName);
        }
        if (imgHeight != 0)
        {
            strb.Append("&image_height=");
            strb.Append(imgHeight);
        }
        if (imgWidth != 0)
        {
            strb.Append("&image_width=");
            strb.Append(imgWidth);
        }
        if (zoom != 0)
        {
            strb.Append("&zoom=");
            strb.Append(zoom);
        }
        string str = wc.DownloadString(strb.ToString());

        if (str.IndexOf("--&") != -1)
        {
            return str.Substring(str.IndexOf("http://gws.maps.yahoo.com"), str.IndexOf("--&"));
        }
        else
        {
            return str.Substring(str.IndexOf("http://gws.maps.yahoo.com"));
        }
    }
}

imgPhotos.Src = DisplayYStaticMap(ds.Tables [0] .Rows [0] [ “PropertyAddress”]。的ToString()。SUBSTRING(0,ds.Tables [0] .Rows [0] [ “PropertyAddress”]的ToString()。的IndexOf( “”)),                             ds.Tables [0] .Rows [0] [ “PropertyCity”]的ToString(),ds.Tables [0] .Rows [0] [ “PropertyState”]的ToString(),150,90,8);

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top