Pregunta

Cómo mostrar mapa estático yahoo en control gridview ASP.Net? La dirección para cargar el mapa estará presente en una de las columnas de gridview y en base a la dirección de cada fila el mapa estática tiene que ser visualizado en cada fila.

¿Fue útil?

Solución

He completado el código para mostrar mapa estático en la página web ASP.Net. Podemos llamar al método DisplayYStaticMap en caso fila de enlace de datos y la visualización del mapa yahoo estática del gridview en gridview también.

public static string DisplayYStaticMap (cadena StreetName, CityName secuencia, secuencia de 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);..

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top