How to request the appropriate geometry (polygons) according to the click of a button?

I want to request data from a sql table with geometry and geography, let it say a table of objects with (id, name, lat, long, poly). I ALREADY HAD A REALIZED query with ajax that gives city results with long lat information. I want the same time that ajax gets a polygon. here is my piece of code

var map = (function () {
        var bingMap = null;
        var mapElementID = "myMap";
        var key = 'AoQi8x29JLhh_iTsAec2pNK050bVHYJOI2G3sVgslKj0Bo1gP - nvP4263H4lFszY';

              function addPin(coords) {
            var location = new Microsoft.Maps.Location(coords[1], coords[2]);
            var pushpin = new Microsoft.Maps.Pushpin(location);
            pushpin.setOptions({ text: coords[0] });

            bingMap.entities.push(pushpin);
        }          
       function addCityPins() {
            for (var city = 0; city < grid.cpCities.length; city++) {
                addPin(grid.cpCities[city]);
            }
        }

        function createMap() {
            if (bingMap)
                bingMap.dispose();

            var mapOptions = {
                credentials: key,
                center: new Microsoft.Maps.Location('41.6000', '21.7000'),
                mapTypeId: Microsoft.Maps.MapTypeId.road,
                zoom: 9,
            }
            bingMap = new Microsoft.Maps.Map(document.getElementById(mapElementID), mapOptions);
            bingMap.entities.clear();  
            addCityPins();
        };
        return {
       createMap: createMap,
        };
    })();
    // ]]>
</script>




protected void ASPGridView1_CustomJSProperties(object sender, Web.ASPGridViewClientJSPropertiesEventArgs e)
{
    String[][] cities = new String[ASPxGridView1.VisibleRowCount][];

    for (int r = 0; r < ASPxGridView1.VisibleRowCount; r++)
    {
        Object[] dr = ASPxGridView1.GetRowValues(r, "City", "Latitude", "Longitude") as Object[];
        cities[r] = dr.Select(o => (string)o).ToArray();
    }
    e.Properties["cpCities"] = cities;
}
}
+4
source share

Source: https://habr.com/ru/post/1616205/


All Articles