Come integrare mappa statica Yahoo nel sito web ASP.Net
-
27-09-2019 - |
Domanda
Come visualizzare mappa statica yahoo nel controllo GridView ASP.Net? L'indirizzo per il caricamento della mappa sarà presente in una delle colonne di GridView e sulla base dell'indirizzo di ciascuna riga della mappa statica deve essere visualizzato su ogni riga.
Soluzione
Ho completato il codice per visualizzare mappa statica sulla pagina web ASP.Net. Siamo in grado di chiamare il metodo DisplayYStaticMap in mappa statica evento fila databound e visualizzazione yahoo di GridView in GridView anche.
public static stringa DisplayYStaticMap (string della via, 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)..