case "bore": if (!arrayBore.displayFieldName) { arrayBore.displayFieldName = idResult.layerName }; arrayBore.geometryType = idResult.geometryType; arrayBore.features.push(idResult.feature); break;if (arrayBore.displayFieldName) { newTab = new dijit.layout.ContentPane({ title: arrayBore.displayFieldName, content: layerTabContent(arrayBore, "arrayBore", type), closable: true, id: "tabBore", style: "overflow-y:auto" }); dijit.byId("tabs").addChild(newTab); //content is added to the table }dojo.connect(resultGrid, 'onDeselected', function (rowId) { map.graphics.remove(layerResults.features[rowId]); }); //connectlayerResults.features[rowId].geometry: Object spatialReference: Object type: "point" x: 468744.3380974941 y: 2011151.794075489 __proto__: Object
Solved! Go to Solution.
function addRemoveFeature(feature, layerName) { var t = dojo.filter(mapGraphics.graphics, function (item) { return item.attributes.OBJECTID == feature.attributes.OBJECTID; }); if(t.length == 0){ var symbol; var graphic; switch (feature.geometry.type) { case "point": symbol = new esri.symbol.SimpleMarkerSymbol(); var pt = new esri.geometry.Point(feature.geometry.x, feature.geometry.y, map.spatialReference); break; case "polygon": symbol = 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 pt = new esri.geometry.Polygon(map.spatialReference); pt = feature.geometry; break; } graphic = new esri.Graphic(pt, symbol, feature.attributes) graphic.layerName = layerName; mapGraphics.add(graphic); } else{ var graphic = t[0]; mapGraphics.remove(graphic); } } function selectQueryFunction(geometry) {
identifyTask info goes here
try {
identifyTask.execute(identifyParams, _buildTable("identify"));
}
catch (e) {
console.log("error in selectQueryFunction");
console.log(e);
}
}
function _buildTable(type) {
try{
return function (queryResults) {
try {
if (queryResults.length > 0) {
var panel = Ext.getCmp("southPanel"); //bottom panel
if (panel.collapsed) {
panel.expand(true);
}
var results = { displayFieldName: null, features: [], layerId: null };
var arraySurfaceWater = { displayFieldName: null, features: [], layerId: 2 };
var arraySediment = { displayFieldName: null, features: [], layerId: 3 };
var arrayHydropunch = { displayFieldName: null, features: [], layerId: 4 };
var arrayWell = { displayFieldName: null, features: [], layerId: 5 };
var arraySurfaceSoil = { displayFieldName: null, features: [], layerId: 6 };
var arrayBore = { displayFieldName: null, features: [], layerId: 7 };
var arrayOther = { displayFieldName: null, features: [], layerId: 8 };
var arrayBuildings = { displayFieldName: null, features: [], layerId: 10 };
var arraySites = { displayFieldName: null, features: [], layerId: 11 };
for (var i = 0, il = queryResults.length; i < il; i++) {
var idResult = queryResults; //pulls the individual result
switch (idResult.layerName) {
case "Surface Water":
if (!arraySurfaceWater.displayFieldName) { arraySurfaceWater.displayFieldName = idResult.layerName };
arraySurfaceWater.features.push(idResult.feature);
break;
case "Sediment":
if (!arraySediment.displayFieldName) { arraySediment.displayFieldName = idResult.layerName };
arraySediment.features.push(idResult.feature);
break;
case "Hydropunch":
if (!arrayHydropunch.displayFieldName) { arrayHydropunch.displayFieldName = idResult.layerName };
arrayHydropunch.features.push(idResult.feature);
break;
case "Groundwater Well":
if (!arrayWell.displayFieldName) { arrayWell.displayFieldName = idResult.layerName };
arrayWell.features.push(idResult.feature);
break;
case "Surface Soil":
if (!arraySurfaceSoil.displayFieldName) { arraySurfaceSoil.displayFieldName = idResult.layerName };
arraySurfaceSoil.features.push(idResult.feature);
break;
case "Soil Boring":
if (!arrayBore.displayFieldName) { arrayBore.displayFieldName = idResult.layerName };
arrayBore.features.push(idResult.feature);
break;
case "Other":
if (!arrayOther.displayFieldName) { arrayOther.displayFieldName = idResult.layerName };
arrayOther.features.push(idResult.feature);
break;
case "Buildings":
if (!arrayBuildings.displayFieldName) { arrayBuildings.displayFieldName = idResult.layerName };
arrayBuildings.features.push(idResult.feature);
break;
case "Sites":
if (!arraySites.displayFieldName) { arraySites.displayFieldName = idResult.layerName };
arraySites.features.push(idResult.feature);
break;
} //switch
} //for
var newTab;
if (arraySurfaceWater.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arraySurfaceWater.displayFieldName, content: layerTabContent(arraySurfaceWater, type), closable: true, id: "tabSurfaceWater", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arraySediment.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arraySediment.displayFieldName, content: layerTabContent(arraySediment, type), closable: true, id: "tabSediment", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arrayHydropunch.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arrayHydropunch.displayFieldName, content: layerTabContent(arrayHydropunch, type), closable: true, id: "tabHydropunch", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arrayWell.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arrayWell.displayFieldName, content: layerTabContent(arrayWell, type), closable: true, id: "tabWell", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arraySurfaceSoil.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arraySurfaceSoil.displayFieldName, content: layerTabContent(arraySurfaceSoil, type), closable: true, id: "tabSurfaceSoil", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arrayBore.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arrayBore.displayFieldName, content: layerTabContent(arrayBore, type), closable: true, id: "tabBore", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arrayOther.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arrayOther.displayFieldName, content: layerTabContent(arrayOther, type), closable: true, id: "tabOther", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arrayBuildings.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arrayBuildings.displayFieldName, content: layerTabContent(arrayBuildings, type), closable: true, id: "tabBuildings", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
if (arraySites.displayFieldName) {
newTab = new dijit.layout.ContentPane({ title: arraySites.displayFieldName, content: layerTabContent(arraySites, type), closable: true, id: "tabSites", style: "overflow-y:auto" });
dijit.byId("tabs").addChild(newTab);
}
} //if
}
//for zoomTo
}; //return
}
}
function layerTabContent(layerResults, layerName,type) {
var selectedLayers = [];
var items = dojo.map(layerResults.features, function (result) {
var symbol;
switch (result.geometry.type) {
case "point":
symbol = new esri.symbol.SimpleMarkerSymbol();
var pt = new esri.geometry.Point(result.geometry.x, result.geometry.y, map.spatialReference);
break;
case "polygon":
symbol = 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 pt = new esri.geometry.Polygon(map.spatialReference);
pt = result.geometry;
break;
}
mapGraphics.add(new esri.Graphic(pt, symbol, result.attributes));
//var graphic = new esri.Graphic(result.geometry)
//graphic.setSymbol(symbol);
selectedLayers.push(pt);
//map.graphics.add(graphic);
// structure.push(layerResults.features.attributes);
return result.attributes;
});
var data = {
items: items
//items: structure
};//data
var selectStore = new dojo.data.ItemFileReadStore({ data: data});
//normally I use 'items'
var fieldNameArr = createTableSchema(items);
var resultGrid = new dojox.grid.EnhancedGrid({
query: {
OBJECTID: '*'
},
//id: gridId,
clientSort: true,
structure: fieldNameArr,
rowsPerPage: 50,
height: "300px",
autoWidth: true,
autoHeight: true,
plugins: {
indirectSelection: {
name: "Select",
field: "Select",
width: "50px",
styles: "text-align: center;"
}//indirect
}//plugins
});//resultGrid
resultGrid.setStore(selectStore);
resultGrid.startup();
resultGrid.rowSelectCell.toggleAllSelection(true);
resultGrid.update();
resultGrid.resize();
var disconnect = dojo.connect(resultGrid, 'onDeselected', function (rowId) {
mapGraphics.remove(layerResults.features[rowId]);
//map.graphics.remove(layerResults.features[rowId]);
}); //connect
if (disconnect) { dojo.disconnect(disconnect); } //disconnect
var connect = dojo.connect(resultGrid, 'onSelected', function (rowId) {
mapGraphics.add(layerResults.features[rowId]);
//map.graphics.add(layerResults.features[rowId]);
}); //connect
if (connect) { dojo.disconnect(connect); } //disconnect
return resultGrid;
}
function addFeature(feature, addRemove) {
var symbol;
switch (feature.geometry.type) {
case "point":
symbol = new esri.symbol.SimpleMarkerSymbol();
var pt = new esri.geometry.Point(feature.geometry.x, feature.geometry.y, map.spatialReference);
break;
case "polygon":
symbol = 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 pt = new esri.geometry.Polygon(map.spatialReference);
pt = feature.geometry;
break;
}
switch (addRemove) {
case ("add"):
mapGraphics.add(new esri.Graphic(pt, symbol, feature.attributes));
break;
case ("remove"):
mapGraphics.remove(new esri.Graphic(pt, symbol, feature.attributes));
break;
}
}function addRemoveFeature(feature, layerName) { var t = dojo.filter(mapGraphics.graphics, function (item) { return item.attributes.OBJECTID == feature.attributes.OBJECTID; }); if(t.length == 0){ var symbol; var graphic; switch (feature.geometry.type) { case "point": symbol = new esri.symbol.SimpleMarkerSymbol(); var pt = new esri.geometry.Point(feature.geometry.x, feature.geometry.y, map.spatialReference); break; case "polygon": symbol = 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 pt = new esri.geometry.Polygon(map.spatialReference); pt = feature.geometry; break; } graphic = new esri.Graphic(pt, symbol, feature.attributes) graphic.layerName = layerName; mapGraphics.add(graphic); } else{ var graphic = t[0]; mapGraphics.remove(graphic); } }Thank you! This Answer saved my day!