Hello All,
I have noticed an issue in one of my apps when trying to print (with Export Web Map task) with features from a Feature Layer selected. The print task successfully runs, however every time I try to create a printout when more than one feature is selected, only one feature displays on the map. Below is the code I use to create the selection:
var parcelsUrl = "http://summitmaps.summitoh.net/arcgis/rest/services/ParcelQuery/MapServer/1";
featureLayerParcel = new esri.layers.FeatureLayer(parcelsUrl, {
mode: esri.layers.FeatureLayer.MODE_SELECTION,
visible: true,
id: "Attribute Selection",
outFields: ["*"]
});
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new dojo.Color([0, 255, 255]), 2), new dojo.Color([0, 0, 255, 0.20]));
featureLayerParcel.setSelectionSymbol(symbol);
map.addLayer(featureLayerParcel);
function queryParcels() {
featureLayerParcel.clearSelection();
parcelQuery.clearSelection();
domUtils.show(parcelSearchLoad);
var queryParcels = new esri.tasks.Query();
//switch where clause based selected search field
queryParcels.where = "PARID LIKE '" + "%" + dom.byId("parcelText").value + "'";
if (dom.byId("attributeSelector").value === "PARID") {
queryParcels.where = "PARID LIKE '" + "%" + dom.byId("parcelText").value + "%" + "'";
} else if (dom.byId("attributeSelector").value === "ADDR") {
queryParcels.where = "ADRNO LIKE '" + dom.byId("addrNum").value + "%" + "'" + "AND ADRSTR LIKE '" + dom.byId("addrText").value + "%" + "'";
} else {
queryParcels.where = "OWN1 LIKE '" + "%" + dom.byId("ownerText").value + "%" + "'";
}
featureLayerParcel.selectFeatures(queryParcels, esri.layers.FeatureLayer.SELECTION_NEW, function(features, selectionMethod) {
parcelSelection = [];
totalParcels = features.length;
document.getElementById("selectedParcels").innerHTML = features.length;
document.getElementById("totalNumberSelected").innerHTML = features.length;
for (var i = 0, il = features.length; i < il; i++) {
parcelSelection.push(features.attributes.PARID);
}
console.log(parcelSelection);
var newStore = new ItemFileReadStore({
data: {
idenitifer: "",
items: []
}
});
var grid = registry.byId("grid2");
grid.setStore(newStore);
if (features.length === 1) {
document.getElementById("parcelPosition").innerHTML = features.length;
var feature = features[0];
var parid = feature.attributes.PARID;
selectParcel(parid);
document.getElementById("selectedParcels").innerHTML = features.length;
domUtils.hide(parcelSearchLoad);
} else if (features.length > 1) {
var parcelItems = dojo.map(features, function(feature) {
return feature.attributes;
});
var parcelData = {
identifier: "OBJECTID",
items: parcelItems
};
var parcelStore = new dojo.data.ItemFileReadStore({
data: parcelData
});
var parcelGrid = registry.byId("grid2");
parcelGrid.on("rowclick", onRowClickHandler);
parcelGrid.setStore(parcelStore);
map.setExtent(graphicsUtils.graphicsExtent(featureLayerParcel.getSelectedFeatures()), true);
domUtils.hide(parcelSearchLoad);
} else {
domUtils.hide(parcelSearchLoad);
alert("No Parcels found!");
}
});
document.getElementById("oldTaxMapWidget").style.display = "none";
}
}In the webmap JSON sent to the print task, the objectIds for the selected features are included. See snippet from JSON below:
{
"id":"Attribute Selection",
"title":"Attribute Selection",
"opacity":1,
"minScale":0,
"maxScale":0,
"layerDefinition":{
"drawingInfo":{
"renderer":{
"type":"simple",
"symbol":{
"color":[
0,
0,
255,
51
],
"outline":{
"color":[
0,
255,
255,
255
],
"width":1.5,
"type":"esriSLS",
"style":"esriSLSSolid"
},
"type":"esriSFS",
"style":"esriSFSNull"
}
}
},
"objectIds":[
[
26764885
],
[
26764886
],
[
26765418
],
[
26765419
],
[
26765540
],
[
26765541
],
[
26765542
]
]
},
"url":"http://summitmaps.summitoh.net/arcgis/rest/services/ParcelQuery/MapServer/1"
},See the attached image. In this case there are 7 features selected but in the output of the print task just one feature is shown. Has anyone had this issue? Any help is appreciated!
Thanks,
Ryan