Pergunta

Como exibir o mapa estático do Yahoo no controle de GridView ASP.NET? O endereço para carregar o mapa estará presente em uma das colunas do GridView e com base no endereço de cada linha, o mapa estático deve ser exibido em cada linha.

Foi útil?

Solução

Concluí o código para exibir o mapa estático na página da web asp.net. Podemos chamar o método DisplayStaticMap no evento de banco de dados da linha GridView e exibir o mapa estático do Yahoo no Gridview também.

public Static String DisplayStaticMap (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 = DisplayStaticMap (ds.tables [0] .Rows [0] ["PropertyAddress"]. ) .IndexOf (",")), ds.tables [0] .Rows [0] ["PropertyCity"]. ), 150,90,8);

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top