function loadSearch() { var bqTask = new esri.tasks.QueryTask(mapURL + "/" + bldgLayerId); var bldgQuery = new esri.tasks.Query(); bldgQuery.returnGeometry = false; bldgQuery.outFields = ["OBJECTID", "NAME", "BLDCODE", "KEYWORDS", "TYPE", "STATUS", "LABEL", "CAMPUS_ID"]; bldgQuery.where = "CAMPUS_ID = 'MAIN' AND STATUS <> 'Restricted'"; bqTask.execute(bldgQuery); dojo.connect(bqTask, "onComplete", function (nResults) { var bldgItems = dojo.map(nResults.features, function (item) { return item.attributes; }); log(bldgItems.length); var data = { 'identifier': "OBJECTID", 'label': "NAME", 'items': bldgItems }; bldgStore = new dojo.data.ItemFileReadStore({ data: data }); var searchDD = dijit.byId("bldgDD"); searchDD.set("store", bldgStore); searchDD.searchAttr = "NAME"; searchDD.fetchProperties = { sort: [{ attribute: 'NAME'}] }; dojo.connect(searchDD , "onChange", function (queryID) { }); } function queryID(bldgid) { var qidTask = new esri.tasks.QueryTask(mapURL + "/" + bldgLayerId); var queryid = new esri.tasks.Query(); var selectedBldg = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([204, 0, 0]), 2)); queryid.returnGeometry = true; queryid.outFields = ["OBJECTID", "NAME", "BLDCODE", "KEYWORDS", "TYPE", "STATUS", "LABEL"]; queryid.where = "OBJECTID = " + bldgid; //When the query completes, select the building dojo.connect(qidTask, "onComplete", function (featureSet) { if (featureSet.features[0]) { if (map.graphics) { map.graphics.clear(); } var graphic = featureSet.features[0]; var bldgnm = graphic.attributes["NAME"]; var blcode = graphic.attributes["OBJECTID"]; graphic.setSymbol(selectedBldg); //Add graphic to the map graphics layer. map.graphics.add(graphic); var selExtent = esri.graphicsExtent(map.graphics.graphics).expand(2); map.setExtent(selExtent); } }); qidTask.execute(queryid); }
require(["dojo/ready", "dojo/dom", "dojo/query", "esri/map", "esri/toolbars/navigation", "esri/tasks/query", "esri/dijit/Scalebar", "dijit/dijit", "dijit/layout/ContentPane", "dijit/layout/TabContainer", "dijit/Toolbar", "dijit/form/Button", "dijit/form/ToggleButton", "dijit/form/FilteringSelect", "dijit/TitlePane", "dojo/store/Memory", "dojo/data/ObjectStore" ]); var basemap, navToolbar, map, bldgStore, selectedBldg, visible = []; // var mapURL = "http://.../rest/services/MU_Base/MapServer"; var bldgLayerId = 58; var baseLayers = [58,59,61,62,63]; function Init() { map = new esri.Map("mapDiv", { logo: false }); var imageParameters = new esri.layers.ImageParameters(); imageParameters.format = "PNG24"; //set the image type to PNG24, note default is PNG8. basemap = new esri.layers.ArcGISDynamicMapServiceLayer(mapURL, { "imageParameters": imageParameters }); map.addLayer(basemap); //** Add the navigation toolbar navToolbar = new esri.toolbars.Navigation(map); selectedBldg = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([204, 0, 0]), 2)); //** CONNECT MAP FUNCTIONS dojo.connect(map, "onLoad", loadBuildingStore); //dojo.connect(map, "onExtentChange", extentHistoryChangeHandler); //resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in var resizeTimer; dojo.connect(map, 'onLoad', function (theMap) { var scalebar = new esri.dijit.Scalebar({ map: map, scalebarUnit: 'english' }); dojo.connect(dojo.byId("mapPanel"), 'resize', function () { map.resize(); }); visible = basemap.visibleLayers; }); } dojo.ready(Init); function loadBuildingStore() { var bqTask = new esri.tasks.QueryTask(mapURL + "/" + bldgLayerId); var bldgQuery = new esri.tasks.Query(); bldgQuery.returnGeometry = false; bldgQuery.outFields = ["OBJECTID", "NAME", "BLDCODE", "KEYWORDS", "TYPE", "STATUS", "ADDRESS"]; bldgQuery.where = "CAMPUS_ID = 'MAIN' AND STATUS <> 'RESTRICTED'"; bqTask.execute(bldgQuery); dojo.connect(bqTask, "onComplete", function (nResults) { var bldgItems = dojo.map(nResults.features, function (item) { //ATTEMPT TO SEE IF PROBLEM LIES IN INTEGER VALUE FOR IDENTIFIER IN DATASTORE? NO DIFFERENCE var idStr = item.attributes.OBJECTID.toString(); item.attributes.OBJECTID = idStr; return item.attributes; }); var data = { 'identifier': "OBJECTID", 'items': bldgItems }; var objStore = new dojo.store.Memory({ data: data, idProperty: 'OBJECTID' }); var select = new dijit.form.FilteringSelect({ id: "bldgDD", style: "width: 300px;", placeHolder: "Select a building or start typing", store: dojo.data.ObjectStore({ objectStore: objStore }), required: false, labelAttr: 'NAME', fetchProperties: { sort: [{ attribute: 'NAME'}] }, // onChange: queryID onChange: function (val) { log(val); //queryID(val); } }, "bldgDD"); }); }
Unfortunately, lots of links like this are now broken.