function highlightGridSelection(event, dGrid) {
selGraphicsLayer.clear();
var row = dGrid.row(event);
var query = new esri.tasks.Query();
var schName = [row.data.facility];
var cityName = [row.data.city];
query.where = "Facility = '" + schName + "' and " + "City = '" + cityName + "'";
query.returnGeometry = true;
query.outFields = ["*"];
query.outSpatialReference = spatialReference;
var queryTask = new esri.tasks.QueryTask(educationLayer.url+"/0");
queryTask.execute(query, highlightResults);
}
function highlightResults(results) {
if (results) {//Note: I am consistently getting results from the query task, it's not like it's blank
var feature = results.features[0];//already esri.Graphic?
var graphic = new Graphic(feature.geometry, highlightMarkerSymbol); //this seems to be the problem line
selGraphicsLayer.add(graphic);//
// app.map.graphics.add(graphic);
} else {
console.log("No records found");
}
}
markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 28,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([255,255,255]), 2),
new dojo.Color([255,0,0,0.85]));
lineSymbol = new esri.symbol.CartographicLineSymbol(esri.symbol.CartographicLineSymbol.STYLE_SOLID,
new dojo.Color([255,0,0]), 10, esri.symbol.CartographicLineSymbol.CAP_ROUND,
esri.symbol.CartographicLineSymbol.JOIN_MITER, 5);
fillSymbol = 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.85]));
// figure out which symbol to use
var symbol, g;
if ( feature.geometry.type === "point" || feature.geometry.type === "multipoint") {
symbol = markerSymbol;
} else if ( feature.geometry.type === "line" || feature.geometry.type === "polyline") {
symbol = lineSymbol;
}
else {
symbol = fillSymbol;
}
g = new esri.Graphic(evt, symbol, null, null);
selGraphicsLayer.add(g);
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;
}
//this function will highlight the selected 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;
}
}
}
//this function will "flash" the selected feature
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);
});
}
arrayUtil.forEach(features, function (f) {
//_highlightLayer.add(f);
var symbol;
if (f.geometry.type === "point" || f.geometry.type === "multipoint") {
symbol = config.highlightSymbols.markerSymbol;
} else if (f.geometry.type === "line" || f.geometry.type === "polyline") {
symbol = config.highlightSymbols.lineSymbol;
}
else {
symbol = config.highlightSymbols.fillSymbol;
}
f.geometry.spatialReference = map.spatialReference;
var g = new Graphic(f, symbol);
g.setSymbol(symbol);
_highlightLayer.add(g);
});
require([
"dojo/parser","esri/config", "esri/map", "esri/dijit/InfoWindow", "esri/dijit/Popup","esri/SpatialReference", "esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/GraphicsLayer",
"esri/dijit/BasemapGallery","agsjs/dijit/TOC","esri/tasks/IdentifyTask", "esri/tasks/IdentifyParameters", "esri/InfoTemplate", "esri/tasks/QueryTask",
"esri/tasks/query", "esri/tasks/GeometryService","dojo/_base/array", "dojo/_base/connect", "dojo/on", "dojo/dom","dijit/registry", "dojo/promise/all","esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
"dijit/TitlePane", "dijit/form/Select", "dgrid/Grid", "esri/graphic", "dojo/domReady!"
], function(
parser, esriConfig, Map, InfoWindow, Popup, SpatialReference, Extent, ArcGISDynamicMapServiceLayer, GraphicsLayer, BasemapGallery, TOC, IdentifyTask, IdentifyParameters,
InfoTemplate, QueryTask, Query, GeometryService, arrayUtils, connect, on, dom, registry, all, SimpleMarkerSymbol,
SimpleFillSymbol, SimpleLineSymbol, Color, BorderContainer, ContentPane, TitlePane, Select, Grid, Graphic) {