Unfortunately, lots of links like this are now broken.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>Dojo Dropdown Demo</title> <link rel="stylesheet" href="https://community.esri.com//serverapi.arcgisonline.com/jsapi/arcgis/3.0/js/dojo/dijit/themes/claro/claro.css"> <!-- ArcGIS API for JavaScript --> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0compact"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.Query"); dojo.require("dijit.form.FilteringSelect"); dojo.require("dojo.data.ItemFileReadStore"); dojo.addOnLoad(init); var map,queryTask; function init() { queryTask = new esri.tasks.QueryTask("http://armstrong.uww.edu/ArcGIS/rest/services/NewCampus/MapServer/27"); map = new esri.Map("map"); dojo.connect(map, "onLoad", function() { //populate dropdown executeQuery(); }); // Add the campus basemap var campusMap = new esri.layers.ArcGISTiledMapServiceLayer('http://armstrong.uww.edu/ArcGIS/rest/services/NewCampus/MapServer'); map.addLayer(campusMap); } function executeQuery() { //execute the query task then populate the dropdown menu with list of building names var query = new esri.tasks.Query(); query.returnGeometry = true; query.outFields = ["BldgName","FID"]; query.where = "1=1"; queryTask.execute(query,populateMenu); } function populateMenu(featureSet){ var items = dojo.map(featureSet.features, function (item) { return { name: item.attributes.BldgName, id:item.attributes.FID }; }); var data = { identifier:"id", items:items }; var objStore = new dojo.data.ItemFileReadStore({data:data}); var filteringSelect = new dijit.form.FilteringSelect({ style:'width:300px;', placeHolder:'Select a building or start typing', store:objStore, required:false, labelAttr:'name', fetchProperties:{sort:[{attribute:'name'}]}, onChange:function(val){ if(val){ var selectQuery = new esri.tasks.Query(); selectQuery.returnGeometry = true; selectQuery.objectIds = [val]; queryTask.execute(selectQuery,function(featureSet){ map.graphics.clear(); //clear any existing map graphics //get the first feature and add to map if(featureSet.features.length > 0){ var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2),new dojo.Color([255,255,0,0.25])); var feature = featureSet.features[0]; var graphic = new esri.Graphic(feature.geometry,symbol); map.graphics.add(graphic); } }); } } },'bldgSelect'); } </script> </head> <body class='claro' style="font-family: Arial Unicode MS,Arial,sans-serif;"> <input id='bldgSelect'/> <div id="wrapper" style="position: relative; width: 700px; height: 500px; border:1px solid #000;"> <!-- Map canvas --> <div id="map" style="position: absolute; width: 700px; height: 500px; z-index: 1;"></div> </div> </body> </html> �??
Thanks for directing me to that sample, that's what I've been hunting for. I wish they hadn't buried it there but at least it's a start.I'm disappointed that I will apparently have to significantly rewrite and restructure pretty much all of my code on all of my sites with the new release. The differences are substantial.
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"); }); }
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); }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.