Solved! Go to Solution.
// ************* THIS IS THE CODE FOR A BASEMAP GALLERY DROP DOWN MENU with ICONS OUT of the BOX **************************** function createBasemapGallery() { //add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps var basemapGallery = new esri.dijit.BasemapGallery({ showArcGISBasemaps: true, basemapsGroup:{owner:"myesriuser",title:"mygroup"}, bingMapsKey: 'bingKey', map: map }, "basemapGallery"); basemapGallery.startup(); dojo.connect(basemapGallery, "onError", function(msg) {console.log(msg)}); } // ************* THIS IS THE CODE Feautre layer check boxes to make them turn on and off ****************************
//************************FIND TASK for SIGNS ********************************************* //Create Find Task using the URL of the map service to search findTask = new esri.tasks.FindTask("https://myserver/pubgis/rest/services/Signs/MapServer/"); // findTask = new esri.tasks.FindTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/TaxParcelQuery/MapServer/"); //Create the find parameters findParams = new esri.tasks.FindParameters(); findParams.returnGeometry = true; findParams.layerIds = [0]; // findParams.searchFields = ["SIGNTYPE"]; // findParams.searchFields = ["OWNERNME1","OWNERNME2"]; findParams.searchFields = ["DATEINST","SIGNCATEGORY","SIGNTYPE","DIRFACES","SUBSTRMAT","BACKGRDMAT","SIGNSIZE","SIGNMEMO","HEIGHT","SUPPORTID"]; findParams.outSpatialReference = map.spatialReference; //*****************************FIND TASK ******************************************************************************* //**************************Sign QUERY TASK ***************************************//// // build query queryTask = new esri.tasks.QueryTask("https://myserver/pubgis/rest/services/Signs/Signs2/MapServer/0"); //dojo.connect(queryTask, "onComplete", showResults); //build query filter query = new esri.tasks.Query(); query.returnGeometry = true; // query.outFields = ["FACILITYID","DATEINST","SIGNCATEGORY","SIGNTYPE","DIRFACES","SUBSTRMAT","BACKGRDMAT","SIGNSIZE","SIGNMEMO","HEIGHT","SUPPORTID","OBJECTID"]; query.outFields = ["*"]; query.outSpatialReference = map.spatialReference; //************************** END Sign QUERY TASK ***************************************//// //**************************Support QUERY TASK ***************************************//// // build query queryTaskSupport = new esri.tasks.QueryTask("https://myserver/pubgis/rest/services/Signs/MapServer/1"); //build query filter querySupport = new esri.tasks.Query(); querySupport.returnGeometry = true; querySupport.outFields = ["*"]; querySupport.outSpatialReference = map.spatialReference; //************************** END Support QUERY TASK ***************************************//// // SignInfoTemplate = new esri.InfoTemplate(); SignInfoTemplate = new esri.InfoTemplate("FacilityID: ${FACILITYID}", "Date Installed: ${DATEINST}<br />Sign Category: ${SIGNCATEGORY}<br />Sign Type: ${SIGNTYPE}<br />Support ID: ${SUPPORTID}<br />Direction Faces: ${DIRFACES}<br />Substrate Material: ${SUBSTRMAT}<br />Background Material: ${BACKGRDMAT}<br />Sign Size: ${SIGNSIZE}<br />Sign Memo: ${SIGNMEMO}<br />Height: ${HEIGHT}"); SupportInfoTemplate = new esri.InfoTemplate("FacilityID: ${FACILITYID}", "Date Installed: ${DATEINST}<br />Support Type: ${SUPPORTTYPE}<br />Support Length: ${SUPPORTLENGTH}<br />Road Name: ${ROADNAME}<br />Support Location: ${SUPPORTLOCATION}<br />Support Memo: ${SUPPORTMEMO}");
var txtType = "SIGNTYPE = "; //String for Type Search var txtDate = "DATEINST = TO_DATE("; //String for Type Search var txtFacId = "FACILITYID = "; //String for Type Search var grid; function doTypeQuery() { query.where = (txtType + "\'" + dojo.byId("SignQuery").value + "\'").toString(); //execute query queryTask.execute(query,showFResults); } function doDateQuery() { query.where = (txtDate + "\'" + dojo.byId("DateQuery").value + " 00:00:00\',\'YYYY-MM-DD HH24:MI:SS\')").toString(); //execute query queryTask.execute(query,showFResults); } function doFacIdQuery() { query.where = (txtFacId + "\'" + dojo.byId("FacIdQuery").value + "\'").toString(); //execute query queryTask.execute(query,showFResults); } function showFResults(results) { //remove all graphics on the maps graphics layer map.graphics.clear(); esri.hide(dojo.byId("gridsup")); esri.show(dojo.byId("grid")); var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5])); var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 255]), 1), new dojo.Color([0, 255, 0, 0.25])); var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 1); var items = []; dojo.forEach(results.features, function (feature) { var graphic = feature; switch (graphic.geometry.type) { case "point": graphic.setSymbol(markerSymbol); break; case "polyline": graphic.setSymbol(lineSymbol); break; case "polygon": graphic.setSymbol(polygonSymbol); break; } // //Set the infoTemplate. graphic.setInfoTemplate(SignInfoTemplate); //Add graphic to map map.graphics.add(graphic); // return feature.attributes; items.push(feature.attributes); }); //Create data object to be used in store var data = { identifier: "OBJECTID", //This field needs to have unique values label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere. items: items }; //Create data store and bind to grid. store = new dojo.data.ItemFileReadStore({ data:data }); grid = dijit.byId('grid'); grid.setStore(store); //+++++++++++++++++++++++++ Zoom back to extent of graphics selected ++++++++++++++++++++++++++++++++++ //Check to see if there is only one graphic for (var i=0, il=results.features.length; i<il; i++) { dojo.forEach(map.graphics.graphics,function(graphic){ g = graphic; return; }); } //if only one graphic and graphic is a point then go to the extent of that graphic if (g.geometry.type === "point" && i===1) { var pExtent = new esri.geometry.Extent({"xmin":g.geometry.x - 500,"ymin":g.geometry.y - 500,"xmax":g.geometry.x + 500,"ymax":g.geometry.y + 500,"spatialReference":{"wkid":g.geometry.spatialReference.wkid}}); map.setExtent(pExtent); } else //go to the extent of all the graphics { var graphicExtent = esri.graphicsExtent(map.graphics.graphics); map.setExtent(graphicExtent); }; //***************END Zoom back to extent of graphics selected ++++++++++++++++++++++++////////// }