Question

Comment afficher yahoo carte statique contrôle ASP.Net GridView? L'adresse de chargement de la carte sera présent dans l'une des colonnes de gridview et sur la base de l'adresse de chaque ligne de la carte statique doit être affiché à chaque ligne.

Était-ce utile?

La solution

Je viens de terminer le code pour afficher la carte statique à la page web ASP.Net. Nous pouvons appeler la méthode DisplayYStaticMap en cas databound rangée de gridview et affichage yahoo la carte statique gridview également.

public static string DisplayYStaticMap (string streetName, chaîne CityName, chaîne 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)..

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top