Need to use a classbreakrenderer, but for one of the class breaks of numbers 1-1, need to use uniquevaluerenderer for that class.
What is the best way to do this?
You can have a classbreakrenderer that only has a single value. Using the classbreakrenderer sample, set one state_fips to its own color. (This code will only show some states and counties since it's retrieving only the first 1000). Indiana (state_fips = 18) will be colored yellow.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Class Breaks Renderer</title> <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css"> <style> html, body, #map{ height: 100%; margin: 0; padding: 0; } </style> <script src="http://js.arcgis.com/3.11/"></script> <script> var map; require([ "esri/map", "esri/layers/FeatureLayer", "esri/InfoTemplate", "esri/symbols/SimpleFillSymbol", "esri/renderers/ClassBreaksRenderer", "esri/Color", "dojo/dom-style", "dojo/domReady!" ], function( Map, FeatureLayer, InfoTemplate, SimpleFillSymbol, ClassBreaksRenderer, Color, domStyle ) { map = new Map("map", { basemap: "streets", center: [-88, 40], zoom: 7, slider: false }); var symbol = new SimpleFillSymbol(); symbol.setColor(new Color([150, 150, 150, 0.5])); // Add five breaks to the renderer. // If you have ESRI's ArcMap available, this can be a good way to determine break values. // You can also copy the RGB values from the color schemes ArcMap applies, or use colors // from a site like www.colorbrewer.org // // alternatively, ArcGIS Server's generate renderer task could be used var renderer = new ClassBreaksRenderer(symbol, "STATE_FIPS"); renderer.addBreak(0, 5, new SimpleFillSymbol().setColor(new Color([56, 168, 0, 0.5]))); renderer.addBreak(6, 17, new SimpleFillSymbol().setColor(new Color([139, 209, 0, 0.5]))); renderer.addBreak(18, 18, new SimpleFillSymbol().setColor(new Color([255, 255, 0, 0.5]))); renderer.addBreak(19, 20, new SimpleFillSymbol().setColor(new Color([255, 128, 0, 0.5]))); renderer.addBreak(21, Infinity, new SimpleFillSymbol().setColor(new Color([255, 0, 0, 0.5]))); var infoTemplate = new InfoTemplate("${NAME}", "${*}"); var featureLayer = new FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3", { mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], infoTemplate: infoTemplate }); //featureLayer.setDefinitionExpression("STATE_NAME = 'Kansas'"); featureLayer.setRenderer(renderer); map.addLayer(featureLayer); }); </script> </head> <body> <div id="map"></div> </body> </html>
Actually need to have one of those classbreak renderer be not set to just a single symbol, but to another set of renderers- i.e. uniquerenderers with its own different sets of symbols.
Thanks.