AnsweredAssumed Answered

FeatureLayer and UniqueValueRenderer

Question asked by bradleyglennjones on Mar 4, 2016
Latest reply on Mar 4, 2016 by bradleyglennjones

I'm a total noob when it comes to the JavaScript API.  I'm teaching myself.  I'm trying to use the UniqueValueRenderer to render one of my feature layers.  When I do it with a simple renderer in the code that's commented out it works.  When I use UniqueValueRenderer or ClassBreaksRenderer the layer doesn't draw.  What am I missing?

 

Thanks

require(["esri/map",
        "esri/layers/FeatureLayer",
        "esri/symbols/SimpleLineSymbol",
        "esri/renderers/UniqueValueRenderer",
        "esri/InfoTemplate",
        "dojo/on",
        "dojo/_base/Color",
        "dojo/domReady!"],
function(Map,
        FeatureLayer,
        SimpleLineSymbol,
        UniqueValueRenderer,
        InfoTemplate,
        on,
        Color) {
    var map = new Map("map", {
        basemap: "streets",
        center: [-92.331404, 34.746788],
        zoom: 13,
        logo: false
    });


    // create the FeatureLayer object
    var sewerLines = new FeatureLayer("http://maps.lrwu.com/wa/rest/services/MoreLayers/MapServer/1", {
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["UPS_MH", "DWN_MH", "PIPLEN", "PIPDIA", "UPS_DWN", "UNITTYPE"],
        displayOnPan: false
    });


    var manholes = new FeatureLayer("http://maps.lrwu.com/wa/rest/services/MoreLayers/MapServer/0", {
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["MH_NO", "SERVSTAT", "MHDPTH", "INSTDATE", "DROPMH", "OWN", "COMPKEY"],
        displayOnPan: false
    });
    var eadFacilities = new FeatureLayer("http://maps.lrwu.com/wa/rest/services/MoreLayers/MapServer/7", {
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["BO_UNIQ", "PERMITTEE", "PERMITTYPE", "ACCOUNTNO", "TRUNKLINE"],
        displayOnPan: false
    });


    //Set the symbol and render the sewerLines
    //var symbol = new SimpleLineSymbol(
    //                SimpleLineSymbol.STYLE_SOLID,
    //                new Color([255,0,0,1]),
    //                3);
    var renderer = new UniqueValueRenderer(null, "UNITTYPE");
    renderer.addValue("GRAVITY", new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0, 1]), 3));
    renderer.addValue("FORCE", new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([ 0, 0, 255, 1]), 3));
    renderer.addValue("PRVGRV", new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 128, 0, 1]), 3));


    sewerLines.setRenderer(renderer);


    // addLayers must use an array to list layers added.
    map.addLayers([sewerLines, manholes, eadFacilities]);


});

Outcomes