我想从具有几何和地理位置的SQL表中查询数据,例如具有属性id,name,lat,long和poly的对象表。
我已经使用ajax实现了查询,该查询使用lat和long信息给出了城市的结果。我想同时使用ajax来获取polygon属性。
以下是我的代码部分:
var map = (function() {
var bingMap = null;
var mapElementID = "myMap";
var key = "API_KEY";
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;
}