|
POST
|
Hi Sarah, I'm not sure if this will help, but I went a different route with highlighting a feature from a clicked row in a dGrid. I didn't use a FeatureLayer, but a regular ArcGISDynamicMapServiceLayer along with a GraphicLayer. In my application, when the user click on a feature (or group of features), I get the list of returned features from an IdentifyTask. These get added to a GraphicsLayer and are used to populate a dGrid that resides in a TabContainer. If more than one layer is turned on in the TOC, then the results from each layer will be put into a separate dGrid. identifyTask.execute(identifyParams, function (results) { populateTC(results, evt); });
function populateTC(results, evt) {
try {
if (dijit.byId('tabs').hasChildren) {
dijit.byId('tabs').destroyDescendants();
}
if (results.length === 0) {
console.log('Nothing found.');
return;
}
var combineResults = {};
for (var i = 0, len = results.length; i < len; i++) {
var result = results;
var feature = result.feature;
var lyrName = result.layerName.replace(' ', '');
if (combineResults.hasOwnProperty(lyrName)) {
combineResults[lyrName].push(result);
}
else {
combineResults[lyrName] = [result];
}
switch (feature.geometry.type) {
case "point": case "multipoint":
layerResultsGraphic.add(new esri.Graphic(feature.geometry, symbolResultPoint, feature.attributes));
break;
case "polyline":
layerResultsGraphic.add(new esri.Graphic(feature.geometry, symbolResultPolyline, feature.attributes));
break;
case "polygon": case "extent":
layerResultsGraphic.add(new esri.Graphic(feature.geometry, symbolResultPolygon, feature.attributes));
break;
}
}
for (result in combineResults) {
if (combineResults.hasOwnProperty(result)) {
var columns = buildColumns(combineResults[result][0].feature);
var features = [];
for (i = 0, len = combineResults[result].length; i < len; i++) {
features.push(combineResults[result].feature);
}
var data = array.map(features, function (feature) {
return lang.clone(feature.attributes);
});
var dataGrid = new (declare([Grid, Selection, DijitRegistry, ColumnHider]))({
id: "dgrid_" + combineResults[result][0].layerId,
bufferRows: Infinity,
columns: columns,
selectionMode: "single",
"class": "resultsGrid"
});
var gridWidth = "width: " + String(columns.length * 100) + "px";
dataGrid.addCssRule("#" + dataGrid.id, gridWidth);
dataGrid.on(".dgrid-row:click", gridSelect);
dataGrid.on("show", function () {
dataGrid.resize();
});
dataGrid.on(mouseUtil.enterRow, gridEnter);
dataGrid.on(mouseUtil.leaveRow, function () {
map.graphics.clear();
});
var plural = "";
if (combineResults[result].length !== 1) { plural = "s"; }
var cp = new dijit.layout.ContentPane({
id: result,
//content: "<strong>" + combineResults[result][0].layerName + "</strong> (" + combineResults[result].length + " feature" + plural + ")",
content: combineResults[result].length + " feature" + plural,
//content: dataGrid,
title: combineResults[result][0].layerName,
style: "overflow: auto"
}).placeAt(dijit.byId('tabs'));
cp.addChild(dataGrid);
cp.startup();
dataGrid.renderArray(data);
}
}
tc.startup();
tc.resize();
map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
}
catch (e) { console.log(e.message); }
}
When the user moves the mouse over one of the rows in the dGrid, I search the GraphicsLayer for the correct feature and add that graphic to the map.graphics layer. If the use clicks on the row, I use the same logic to "flash" the feature.
function gridEnter(e) {
map.graphics.clear();
var gridId = e.currentTarget.id;
var selectedGrid = dijit.byId(gridId);
var row = selectedGrid.row(e);
graphicHighlight = findGraphicByAttribute(row.data);
if (graphicHighlight !== null) {
switch (graphicHighlight.geometry.type) {
case "point": case "multipoint":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPoint));
break;
case "polyline":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPolyline));
break;
case "polygon": case "extent":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPolygon));
break;
}
}
}
function gridSelect(e) {
var graphicFlash;
var gridId = e.currentTarget.id;
var selectedGrid = dijit.byId(gridId);
var row = selectedGrid.row(e);
graphicHighlight = findGraphicByAttribute(row.data);
if (graphicHighlight !== null) {
switch (graphicHighlight.geometry.type) {
case "point": case "multipoint":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPoint)
break;
case "polyline":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPolyline);
break;
case "polygon": case "extent":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPolygon);
break;
}
map.graphics.add(graphicFlash);
}
var shape = graphicFlash.getDojoShape();
var animStroke = fx.animateStroke({
shape: shape,
duration: 500,
color: { end: new dojo.Color([0, 0, 0, 0]) }
});
var animFill = fx.animateFill({
shape: shape,
duration: 500,
color: { end: new dojo.Color([0, 0, 0, 0]) }
});
var anim = dojo.fx.combine([animStroke, animFill]).play();
var animConnect = dojo.connect(anim, "onEnd", function () {
map.graphics.remove(graphicFlash);
});
}
function findGraphicByAttribute(attributes) {
for (i = 0; i < layerResultsGraphic.graphics.length; i++) {
if (JSON.stringify(layerResultsGraphic.graphics.attributes) === JSON.stringify(attributes)) { return layerResultsGraphic.graphics; }
}
return null;
}
Since the map.graphics layer is always on top of all other layers (including other GraphicsLayers), I never have to worry about the order.
... View more
05-14-2014
11:34 AM
|
0
|
0
|
1619
|
|
POST
|
Do you have a proxy set up properly? Notice that the code contains this
urlUtils.addProxyRule({
proxyUrl: "/proxy",
urlPrefix: "test25.net"
});
... View more
05-14-2014
05:28 AM
|
0
|
0
|
3452
|
|
POST
|
The order of the modules in the require section have to match the order of the arguments in the function section. Take a look at this blog for more details. require([ "esri/map", "esri/tasks/FindTask", "esri/tasks/FindParameters", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/Color", "dojo/on", "dojo/dom", "dijit/registry", "dojo/_base/array", "dojo/_base/connect", "dojox/grid/DataGrid", "dojo/data/ItemFileReadStore", "dijit/form/Button", "dojo/parser", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/dijit/HomeButton", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!" ], function( Map, FindTask, FindParameters, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, Color, on, dom, registry, arrayUtils, connect, DataGrid, ItemFileReadStore, Button, parser, Tiled,ArcGISDynamicMapServiceLayer,HomeButton
... View more
05-12-2014
01:12 PM
|
0
|
0
|
1158
|
|
POST
|
You have to set the export quality of the output. Take a look at this page which shows you how to do that.
... View more
05-08-2014
05:23 AM
|
0
|
0
|
563
|
|
POST
|
You may want to start a separate thread to get the attention of the API developers.
... View more
05-06-2014
08:28 AM
|
0
|
0
|
1297
|
|
POST
|
That Fiddle show a new error. However, if you switch back to 3.8, that error goes away.
... View more
05-06-2014
07:57 AM
|
0
|
0
|
1297
|
|
POST
|
You have both var djConfig = {
parseOnLoad: true,
packages: [{
"name": "agsjs",
"location": "http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/build/agsjs"
}]
}; and parser.parse(); Use one or the other. And take a look at this page on parseOnLoad vs. parser.parse()
... View more
05-06-2014
07:03 AM
|
0
|
0
|
3537
|
|
POST
|
It's a known issue. Take a look at this thread, which offers some more explanation, as well as a link to a possible solution.
... View more
05-06-2014
05:27 AM
|
0
|
0
|
713
|
|
POST
|
Check the capabilities of your map service. I noticed that when using a service like Jake did, it works fine. However, if I used a service from an older server (http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3, for example), the click event would never get activated.
... View more
05-01-2014
11:09 AM
|
0
|
0
|
2862
|
|
POST
|
Why are the attributes of a feature returned from a Query shown with the field names while the attributes of a feature returned from an Identify shown with field aliases? This example lists the field names in the console for each. [ATTACH=CONFIG]33494[/ATTACH][ATTACH=CONFIG]33495[/ATTACH] I'm building the data store for dGrids two ways. In one grid, I'm getting all the records from the results of Query to show all the available features. In another grid, I'm building the data store from the results of an Identify where the user clicks on the map. Both grids have a column with an icon that indicates that there are photos at that site. The user can click on the icon to show a slideshow of the photos. I'm using a rendercell function to create a popup window with the slideshow. function renderPhotoColumn(object, value, cell, options) { if (object.PhotoCount > 0) { var image = new Image(); image.src = "../resources/assets/images/CheckMark.png"; image.onclick = function () { createSlideShow(object) }; return image; } } function createSlideShow(siteObject) { try { fpSlideshow.setTitle("Site " + siteObject["Site ID"] + " photos"); var data = []; for (var i = 1; i <= siteObject.PhotoCount; i++) { data.push({ image: parameters.photoURL + "thumbnails/" + siteObject["Site ID"] + "_" + i + ".jpg", link: parameters.photoURL + siteObject["Site ID"] + "_" + i + ".jpg" }); } Galleria.configure({ popupLinks: true }); Galleria.run('.galleria', { dataSource: data }); fpSlideshow.show(); } catch (e) { console.log("createSlideshow - " + e.message); } } However, since the field names are not the same ("Site ID" versus "SITE_ID"), this breaks for the grid created from the Query. [ATTACH=CONFIG]33497[/ATTACH][ATTACH=CONFIG]33496[/ATTACH]
... View more
04-30-2014
02:34 PM
|
0
|
2
|
4182
|
|
POST
|
This line var gridId = e.currentTarget.id; is returning the name of the div that the grid is stored in, not the grid itself. So then this line var selectedGrid = dijit.byId(gridId); returns an "undefined"
... View more
04-29-2014
11:18 AM
|
0
|
0
|
1827
|
|
POST
|
Thanks Ken....I I tweaked the JSFiddle to reflect your example sand now when I click the map I dont get any return to the grid...thoughts? http://jsfiddle.net/Jaykapalczynski/HjMB9/17/ You should get into the habit of using debugging tools like Firebug. These are the errors from your Fiddle [ATTACH=CONFIG]33445[/ATTACH] For the mouseUtils error, you'll have to add the "dgrid/util/mouse" module in your require statement.
... View more
04-29-2014
09:55 AM
|
0
|
0
|
1827
|
|
POST
|
Take a look at this site where a feature is highlighted from a grid. The feature can be highlighted by moving the mouse over the row in the grid or by clicking on the row. When the grid (dataGrid) is created, I add on listeners:
dataGrid.on(".dgrid-row:click", gridSelect);
dataGrid.on("show", function () {
dataGrid.resize();
});
dataGrid.on(mouseUtil.enterRow, gridEnter);
and these are the functions that highlight the grid. I put the highlight graphics into the map.graphics layer.
//this highlights the graphic
function gridEnter(e) {
map.graphics.clear();
var gridId = e.currentTarget.id;
var selectedGrid = dijit.byId(gridId);
var row = selectedGrid.row(e);
graphicHighlight = findGraphicByAttribute(row.data);
if (graphicHighlight !== null) {
switch (graphicHighlight.geometry.type) {
case "point": case "multipoint":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPoint));
break;
case "polyline":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPolyline));
break;
case "polygon": case "extent":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPolygon));
break;
}
}
}
//this "flashes" the graphic
function gridSelect(e) {
var graphicFlash;
var gridId = e.currentTarget.id;
var selectedGrid = dijit.byId(gridId);
var row = selectedGrid.row(e);
graphicHighlight = findGraphicByAttribute(row.data);
if (graphicHighlight !== null) {
switch (graphicHighlight.geometry.type) {
case "point": case "multipoint":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPoint)
break;
case "polyline":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPolyline);
break;
case "polygon": case "extent":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPolygon);
break;
}
map.graphics.add(graphicFlash);
}
var shape = graphicFlash.getDojoShape();
var animStroke = fx.animateStroke({
shape: shape,
duration: 500,
color: { end: new dojo.Color([0, 0, 0, 0]) }
});
var animFill = fx.animateFill({
shape: shape,
duration: 500,
color: { end: new dojo.Color([0, 0, 0, 0]) }
});
var anim = dojo.fx.combine([animStroke, animFill]).play();
var animConnect = dojo.connect(anim, "onEnd", function () {
map.graphics.remove(graphicFlash);
});
}
function findGraphicByAttribute(attributes) {
for (i = 0; i < layerResultsGraphic.graphics.length; i++) {
if (JSON.stringify(layerResultsGraphic.graphics.attributes) === JSON.stringify(attributes)) { return layerResultsGraphic.graphics; }
}
return null;
}
... View more
04-29-2014
08:42 AM
|
0
|
0
|
2209
|
|
POST
|
Do you have the function activateIdentify inside the require statement? If so, it's a problem of scope. What you should do is something like
on(dom.byId("identifyDiv"), "click", function (){
activateIdentify();
});
... View more
04-28-2014
07:46 AM
|
0
|
0
|
3145
|
|
POST
|
Either can be used as a showcase for seeing how the code works. Are you sure it's not working? It's designed to filter when you click on the "Apply filter" text. For example, choosing Smallmouth Bass and LMBV will show 2 features. You could alter it to apply the filter when you select the dropdown box instead.
... View more
04-24-2014
07:01 PM
|
0
|
0
|
2872
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 2 weeks ago | |
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|