我刚刚开始尝试将 Dojo 与 ESRI ArcGIS Server 一起使用。我已经尝试了一些教程,但我遇到了 Dojo FilteringSelect Dijit 的问题。
我的代码的相关部分:
<script>
dojo.require("esri.map");
dojo.require("esri.tasks.query");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.form.FilteringSelect");
var map;
function init() {
map = new esri.Map("mapDiv",{
basemap: "streets",
center: [-80.94, 33.646],
zoom: 8
});
dojo.connect(map, "onLoad", initFunctionality);
}
function initFunctionality(map) {
//build query task
var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");
//build query filter
var query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["NAME", "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI"];
query.where = "STATE_NAME = 'South Carolina'";
query.outSpatialReference = {"wkid":102100};
var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle("${NAME}");
infoTemplate.setContent( "<b>2000 Population: </b>${POP2000}<br/>"
+ "<b>2000 Population per Sq. Mi.: </b>${POP00_SQMI}<br/>"
+ "<b>2007 Population: </b>${POP2007}<br/>"
+ "<b>2007 Population per Sq. Mi.: </b>${POP07_SQMI}");
map.infoWindow.resize(245,105);
//Can listen for onComplete event to process results or can use the callback option in the queryTask.execute method.
dojo.connect(queryTask, "onComplete", function(featureSet) {
map.graphics.clear();
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.35]), 1),new dojo.Color([125,125,125,0.35]));
//QueryTask returns a featureSet. Loop through features in the featureSet and add them to the map.
dojo.forEach(featureSet.features,function(feature){
var graphic = feature;
graphic.setSymbol(symbol);
graphic.setInfoTemplate(infoTemplate);
map.graphics.add(graphic);
});
});
queryTask.execute(query);
}
function initLineID(features) {
var lineIdObjects = [];
dojo.forEach(features.features, function(feature) {
lineIdObjects.push({"name": feature.attributes.field_name});
});
//Build the appropriate data object for our data component
var data = {
"identifier": "name",
"items": lineIdObjects
}
//bind the data object to the datastore
var lineDataStore = new dojo.data.ItemFileReadStore({data: data});
//bind the data store to the FilteringSelect component
dijit.byId("lineid").store = lineDataStore;
}
dojo.ready(init);
</script>
也
<input dojoType="dijit.form.FilteringSelect"
id="lineid"
searchAttr="name"
name="widgetName"
onChange="doSomething(this.value)">
我面临的挑战是生成的页面只显示一个基本的
<input type="text">
盒子。有谁知道这是为什么?谢谢。