Sorry I misread your question. I thought you were asking about dynamically generating symbology for a selected layer. My instructions were for that.
I have been working through the sample https://developers.arcgis.com/javascript/jssamples/renderer_dynamic_layer_change_attribute.html which allows the user to select a field from the specified service and generate a classification based on that field. It is based on a ArcGISDynamicMapServiceLayer. In order to activate the 'dynamic layers' functionality you have create a geodatabase or shape file workspace and author that as a geodata service Check the box under Capabilities > Mapping in Properties to "Allow per request modification ..."click "Manage" to browse the the geodata service you just made.The geodata service is just a temporary workspace, near as I can tell. It doesn't have anything in it.In my data, I have some values of -999 which indicates 'No data'. I didn't want these to be included when I generated my renderer, so I needed a where clause. In the sample, the function classBreaks is where the GenerateRendererParameters is defined. I added a where clause, shown in red, which takes the field the user selected and excludes the -999 data so it doesn't get used when I generate the renderer. I also needed to round my numbers, since some have too many decimals. It seems to be working just fine. I still need to figure out if you can symbolize this excluded data, with maybe a gray color or something.
FeatureLayer l = new FeatureLayer() { ID = "MyFeatureLayer", Url = "http://serverNameBlahBlah/WPFTestFeatureLayer/FeatureServer/0", //Where = "1=1" Where = "ASSIGNED_TO = 'GIS_USER'" //, //Renderer = "{StaticResource MySimplePointRenderer}" };
function classBreaks(c1, c2) { var classDef = new ClassBreaksDefinition(); classDef.classificationField = registry.byId("fieldNames").get("value") || "CROP_2002_ACRES_TREATED";//this is a field in my data classDef.classificationMethod = "natural-breaks"; classDef.breakCount = 5; // always five classes var colorRamp = new AlgorithmicColorRamp(); colorRamp.fromColor = new Color.fromHex(c1); colorRamp.toColor = new Color.fromHex(c2); colorRamp.algorithm = "hsv"; // options are: "cie-lab", "hsv", "lab-lch" classDef.baseSymbol = new SimpleFillSymbol("solid", null, null); classDef.colorRamp = colorRamp; var params = new GenerateRendererParameters(); params.classificationDefinition = classDef; params.precision = 2; params.formatLabel = true; var clauseInput = classDef.classificationField; params.where= clauseInput + " > 0"; var generateRenderer = new GenerateRendererTask(app.dataUrl); generateRenderer.execute(params, applyRenderer, errorHandler); }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.