Как интегрировать карту Yahoo Static в веб-сайте ASP.NET
-
27-09-2019 - |
Вопрос
Как отображать статическую карту Yahoo в Asp.net GridView Control? Адрес для загрузки карты будет присутствовать в одном из столбцов GRIDVIEW и на основе адреса каждой строки статическая карта должна отображаться на каждой строке.
Решение
Я завершил код для отображения статической карты на веб-странице ASP.NET. Мы можем вызвать метод DisplaySystaticMap в соревнованиях по пангузанию ROW GRIDView и отображать экранную карту Yahoo Static в GridView.
Public Static String DisplaySystaticMap (String Streetname, String CityName, String StateName, int imgwidth, int imgheight, int zoom) {webclient wc = новый 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 = DisplaySystaticMap (ds.ttables [0]. rows [0] [«PropertyAddress»]. TOSTRING (). Подстрока (0, ds.tables [0]. Rows [0] [«PropertyAddress»]. ) .Indexof (",")), ds.ttables [0]. Rows [0] [«PropertyCity»]. TOSTRING (), DS.ttables [0]. Whows [0] [«PropertyState»]. TOSTRING ( ), 150,90,8);