//Existing Land Use (popup)
{ "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer/0",
"visibility": true,
"opacity": 0,
"mode": 2, //Selection-only
"layerDefinition": {
"minScale": 100000,
"maxScale": 0,
},
"title": "popup Existing Land Use",
"id": "popelu",
"popupInfo": {
"title": "Existing Land Use",
"fieldInfos": [
{'fieldName': "JURISDICTION","label": "Jurisdiction","visible": true,},
{"fieldName": "ELUSHADE","label": "Existing LU","visible": true,},
{"fieldName": "ELU2_DESC","label": "Description","visible": true,}
],
"description": null
}
},
//Existing Land Use (display tiled service)
{ "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer",
"visibility": false,
"opacity": 0.75,
"title": "Existing Land Use",
"id": "elu",
"description": null
},
//TT Zoning (popup)
{ "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/Rezoning/Zoning/MapServer/0",
"visibility": true,
"opacity": 0,
"mode": 2, //Selection-only
"title": "popup TT Zoning",
"id": "popttzon",
"popupInfo": {
"title": "TT Zoning",
"fieldInfos": [
{"fieldName": "ZONING","label": "Zoning","visible": true,},
],
"description": null
}
},
//TT Zoning (display dynamic service, set visibleLayers)
{ "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/Rezoning/Zoning/MapServer",
"visibility": false,
"opacity": 0.75,
"visibleLayers": [0], //set layer to Zoning
"title": "TT Zoning",
"id": "ttzon",
"description": null
}, webmap.itemData = {
//IMPORTANT: Make sure the id of the popup and display layers are consistent!
//All popup layers need be named "pop" + {name of display layer}
//e.g. for Existing LU, the display layer id = "elu" and the corresponding popup layer id = "popelu"
//IMPORTANT: Make sure the popup and display layers are set to the same visibility (i.e., both 'true' or both 'false')
"operationalLayers": [
//Existing Land Use (popup)
{ "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer/0",
"visibility": false,
"opacity": 0,
"mode": 2, //Selection-only
"layerDefinition": {
"minScale": 100000,
"maxScale": 0,
},
"title": "popup Existing Land Use",
"id": "popelu",
"popupInfo": {
"title": "Existing Land Use",
"fieldInfos": [
{'fieldName': "JURISDICTION","label": "Jurisdiction","visible": true,},
{"fieldName": "ELUSHADE","label": "Existing LU","visible": true,},
{"fieldName": "ELU2_DESC","label": "Description","visible": true,}
],
"description": null
}
},
//Existing Land Use (display tiled service)
{ "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer",
"visibility": false,
"opacity": 0.75,
"title": "Existing Land Use",
"id": "elu",
"description": null
}, dojo.forEach(layerList, function (layer) {
menu.addChild(new dijit.CheckedMenuItem({
label: layer.title,
checked: layer.visible,
onChange: function () {
if (layer.layer.featureCollection) {
//turn off all the layers in the feature collection even
//though only the main layer is listed in the layer list
dojo.forEach(layer.layer.featureCollection.layers, function (layer) {
layer.layerObject.setVisibility(!layer.layerObject.visible);
});
} else {
layer.layer.setVisibility(!layer.layer.visible); //this is where the layer's visibility is toggled on/off.
[INDENT] //ADDITIONAL CODE
//Add the following to toggle the corresponding popup layer(s) in sync with the display layer. 11/20/13 jms
//This way the popup box functionality will only return results from visible layers. (Too many layers in the list slows down the popup functionality otherwise...)
//Important! Make sure in the create webmap that the popup and display layers are set to the same visibility (i.e., both 'true' or both 'false')
console.log("layer: '" + layer.layer.id + "', visibility changed to '" + layer.layer.visible + "'");
//console.log("popupid: " + map.getLayer("popelu").id);
//var popupId = "popelu";
var popupId = "pop" + layer.layer.id;
var popupLayer = map.getLayer(popupId);
popupLayer.setVisibility(!popupLayer.visible);
console.log("popupLayer: '" + popupLayer.id + "', visibility changed to '" + popupLayer.visible + "'");[/INDENT] //END OF ADDITIONAL CODE
}
}
}));
});