How to display yahoo static map in ASP.Net gridview control? The address for loading the map will be present in one of the columns of gridview and based on the address of each row the static map has to be displayed on each row.
A:
I have completed the code to display static map on ASP.Net web page. We can call the DisplayYStaticMap method in gridview's row databound event and display yahoo static map in gridview also.
public static string DisplayYStaticMap(string streetName, string CityName, string stateName, int imgWidth, int imgHeight,int zoom) { WebClient wc = new WebClient();
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);
banupriya
2010-10-09 08:02:13