From 8dba754d31c5805972316a29e82e1325af858507 Mon Sep 17 00:00:00 2001 From: Stephen Sporik Date: Mon, 4 May 2015 18:18:49 -0400 Subject: [PATCH 1/5] Zoom Icon in Query Grid --- .../src/modules/core/configuration/app.js | 2 +- .../src/modules/core/query/querying.js | 44 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/basicviewer/src/modules/core/configuration/app.js b/basicviewer/src/modules/core/configuration/app.js index 95bfc9d..926e414 100644 --- a/basicviewer/src/modules/core/configuration/app.js +++ b/basicviewer/src/modules/core/configuration/app.js @@ -15,7 +15,7 @@ define(["dojo/_base/declare", "dojox/html/entities", "dojo/_base/lang", "dojo/Ev //The ID for a web map from ArcGIS Online (AGO) //If not going to specify a Web Map in AGO, then use empty quotes ("") here - webmap: "d1201eea7afb4ed49f08a310e9803f2f", //"blank" default map; an OpenStreetMap basemap + webmap: "1d6cee2d8c7145b79f45d96fd454e07b", //"blank" default map; an OpenStreetMap basemap //Some sample web maps to try for testing: //webmap: "252fb36ac7404043a0f3d2022958b5d0", //veterans services //webmap: "c545bf8fde0a46c2aa52a10e9118750a", //growthprint diff --git a/basicviewer/src/modules/core/query/querying.js b/basicviewer/src/modules/core/query/querying.js index 0547372..a860bd4 100644 --- a/basicviewer/src/modules/core/query/querying.js +++ b/basicviewer/src/modules/core/query/querying.js @@ -7,10 +7,10 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dijit/layout/ContentPane", "dojo/data/ItemFileWriteStore", "dojox/grid/DataGrid" , "dojox/grid/EnhancedGrid", "dojo/data/ItemFileWriteStore", "dojox/grid/enhanced/plugins/exporter/CSVWriter", "dojox/grid/enhanced/plugins/NestedSorting", "../utilities/maphandler", "dojo/_base/lang", "dijit/registry", "dojo/html", "dojo/dom", "dojo/on", "dijit/form/Button", "esri/request", "dojo/dnd/move" , "esri/toolbars/draw", "esri/graphic", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "dojox/layout/FloatingPane" - , "jquery", "dojox/widget/Standby", "dojo/dom-construct", "esri/tasks/query", "dojo/_base/connect", "../utilities/environment", "dojo/text!./templates/querying.html"], + , "jquery", "dojox/widget/Standby", "dojo/dom-construct", "esri/tasks/query", "dojo/_base/connect", "dojo/query", "../utilities/environment", "dojo/text!./templates/querying.html"], function (declare, WidgetBase, dom, json, ContentPane, ItemFileWriteStore, DataGrid, EnhancedGrid, ItemFileWriteStore, CSVWriter, NestedSorting, mapHandler, lang, registry, html, dom, on, Button, esriRequest, move , Draw, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, FloatingPane - , $, Standby, domConstruct, Query, connect, environment, template) { + , $, Standby, domConstruct, Query, connect, dojoquery, environment, template) { return declare([WidgetBase, ContentPane], { // The template HTML fragment (as a string, created in dojo/text definition above) templateString: template @@ -351,6 +351,12 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij var layout = []; var identifierVar = results.objectIdFieldName; /*set up layout*/ + //set first column to magnifying glass icon + layout.push({ 'name': "Zoom To", 'field': "", 'formatter': lang.hitch(this, "_renderCell")}); + + + + for (var j = 0; j < results.fields.length; j++) { if (results.fields[j].type == "esriFieldTypeOID") { identifierVar = results.fields[j].name; @@ -371,16 +377,20 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij /*create a new grid*/ //var grid = new DataGrid({ - var grid = new dojox.grid.EnhancedGrid({ + var grid = new EnhancedGrid({ id: 'grid', store: store, structure: layout, + autoHeight: true, + autoWidth: true, rowSelector: '20px', //width of the row selector at the beginning of a row + escapeHTMLinData: true, plugins: { exporter: true, nestedSorting: true } }); + grid.setStore(store); @@ -483,19 +493,13 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij //download.click(); // This will download the data file named "iMap_Results.csv". }); }); - - - - grid.set('autoHeight', true); - grid.set('autoWidth', false); + grid.update(); /*Call startup() to render the grid*/ grid.startup(); /*append the new grid to the div*/ grid.placeAt("subContainer"); - - - + dijit.byId('grid').resize(); dijit.byId('grid').update(); @@ -507,6 +511,12 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij /*Call startup() to render the grid*/ grid.startup(); + + //use dojo/query to set a click event for all elements in the class "zoomImg", this enables using dojo/on for all elements at once. + //this must be done AFTER the grid is rendered with results and the zoom icons exist in the DOM. + dojoquery(".zoomImg").on("click", lang.hitch(this, function(e){ + this._zoomToFeature(e); + })); //document.getElementById("subContainer").style.height = (dojo.byId('floatingPane').offsetHeight - 80).toString() + "px"; @@ -607,6 +617,18 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij }).appendTo(cboBox); } } + , _renderCell: function(item){ + var img = ""; + return img; + } + + , _zoomToFeature: function(item){ + //get graphic results layer + + //query layer for OID + + //zoom to graphic + } }); }); From 7022d61800a88bad01209e3c9ad4f5d5d5493682 Mon Sep 17 00:00:00 2001 From: Stephen Sporik Date: Tue, 5 May 2015 19:31:43 -0400 Subject: [PATCH 2/5] Zooming to Graphic --- .../src/modules/core/query/querying.js | 569 +++++++++++------- 1 file changed, 340 insertions(+), 229 deletions(-) diff --git a/basicviewer/src/modules/core/query/querying.js b/basicviewer/src/modules/core/query/querying.js index a860bd4..a57fadf 100644 --- a/basicviewer/src/modules/core/query/querying.js +++ b/basicviewer/src/modules/core/query/querying.js @@ -5,12 +5,14 @@ * connector (dojo/aspect) does not obtain the proper callback parameters. */ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dijit/layout/ContentPane", "dojo/data/ItemFileWriteStore", "dojox/grid/DataGrid" - , "dojox/grid/EnhancedGrid", "dojo/data/ItemFileWriteStore", "dojox/grid/enhanced/plugins/exporter/CSVWriter", "dojox/grid/enhanced/plugins/NestedSorting", "../utilities/maphandler", "dojo/_base/lang", "dijit/registry", "dojo/html", "dojo/dom", "dojo/on", "dijit/form/Button", "esri/request", "dojo/dnd/move" - , "esri/toolbars/draw", "esri/graphic", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "dojox/layout/FloatingPane" - , "jquery", "dojox/widget/Standby", "dojo/dom-construct", "esri/tasks/query", "dojo/_base/connect", "dojo/query", "../utilities/environment", "dojo/text!./templates/querying.html"], - function (declare, WidgetBase, dom, json, ContentPane, ItemFileWriteStore, DataGrid, EnhancedGrid, ItemFileWriteStore, CSVWriter, NestedSorting, mapHandler, lang, registry, html, dom, on, Button, esriRequest, move - , Draw, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, FloatingPane - , $, Standby, domConstruct, Query, connect, dojoquery, environment, template) { + , "dojox/grid/EnhancedGrid", "dojo/data/ItemFileWriteStore", "dojox/grid/enhanced/plugins/exporter/CSVWriter", "dojox/grid/enhanced/plugins/NestedSorting", "dojox/grid/enhanced/plugins/Selector", "../utilities/maphandler", "dojo/_base/lang", "dijit/registry", "dojo/html", "dojo/dom", "dojo/on", "dijit/form/Button", "esri/request", "dojo/dnd/move" + , "esri/toolbars/draw", "esri/graphic", "esri/geometry/Multipoint", "esri/geometry/Polygon", "esri/geometry/Polyline", "esri/SpatialReference" + , "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "dojox/layout/FloatingPane" + , "jquery", "dojox/widget/Standby", "dojo/dom-construct", "esri/tasks/query", "dojo/_base/connect", "dojo/query", "dojo/_base/array", "../utilities/environment", "dojo/text!./templates/querying.html"], + function (declare, WidgetBase, dom, json, ContentPane, ItemFileWriteStore, DataGrid, EnhancedGrid, ItemFileWriteStore, CSVWriter, NestedSorting, Selector, mapHandler, lang, registry, html, dom, on, Button, esriRequest, move + , Draw, Graphic, Multipoint, Polygon, Polyline, SpatialReference + , SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, FloatingPane + , $, Standby, domConstruct, Query, connect, dojoquery, arrayUtil, environment, template) { return declare([WidgetBase, ContentPane], { // The template HTML fragment (as a string, created in dojo/text definition above) templateString: template @@ -19,8 +21,8 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij , toolbar: null // Once a tree has been created and before switching to another, store it here to use again later if needed (_switchTree) /* an item in the list looks like - {index: , store: , model: , tree: } - */ + {index: , store: , model: , tree: } + */ //Available for parent to know if add data contents have been created , ContentsCreated: false , _paneStandby: null @@ -29,6 +31,8 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij , _subCbo: null , _fieldsCbo: null , _fieldArray: null + , _resultsGrid: null + , _identifierVar: null //The event handlers below are not needed, unless for custom code. They are here for reference. @@ -48,7 +52,7 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij //The dojo accordion, which this module inherits from, has been created and is accessible (though not actually shown yet) , startup: function () { this.inherited(arguments); - this._paneStandby = new Standby({ target: this.id }); + this._paneStandby = new Standby({target: this.id}); document.body.appendChild(this._paneStandby.domNode); //create a results graphics layer and add to the map @@ -73,9 +77,15 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij //if not, create a title out of the ID layerName = layerName.replace(/_/g, " "); //push layer id, url, name and type - layers.push({ id: mapvariable.id, name: layerName, url: mapvariable.url, type: mapvariable.type }); + layers.push({ + id: mapvariable.id, + name: layerName, + url: mapvariable.url, + type: mapvariable.type + }); mapServices.push(mapvariable.url); - }; + } + ; } //get the graphics layers, first compare with mapservices already processed (to weed out popup feature layers) for (var j = 0; j < this.map.graphicsLayerIds.length; j++) { @@ -83,8 +93,14 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij // if it's a feature layer and not another graphics layer, and it doesn't match a current layer if (mapvariable.type == "Feature Layer" && mapServices.indexOf(mapvariable.url.replace("/" + mapvariable.layerId, "")) == -1) { //add the layer id, name, url, and type to the array - layers.push({ id: mapvariable.id, name: mapvariable.name, url: mapvariable.url, type: mapvariable.type }); - }; + layers.push({ + id: mapvariable.id, + name: mapvariable.name, + url: mapvariable.url, + type: mapvariable.type + }); + } + ; } //set the global variable to this combo box for later use @@ -97,11 +113,18 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij if (layers.length != 0) { //sets up the services in the map that the user can query off of - $('', { label: serviceJSON.layers[j].name }).appendTo(this._subCbo); + $('', {label: serviceJSON.layers[j].name}).appendTo(this._subCbo); } } @@ -263,12 +294,18 @@ define(["dojo/_base/declare", "dijit/_WidgetBase", "dojo/dom", "dojo/json", "dij for (var j = 0; j < layerJSON.fields.length; j++) { if (layerJSON.fields[j].type == "esriFieldTypeString") { fields.push(layerJSON.fields[j]); - }; - }; + } + ; + } + ; $('#serviceCbo').prop('disabled', 'disabled'); $('#layerCbo').prop('disabled', 'disabled'); $('#fieldCbo').empty(); - $('