Domain as Drop down ArcGIS Javascript

1917
3
Jump to solution
03-07-2016 07:40 AM
KathleenBrenkert
Occasional Contributor

I would really love to use the codedvalues from the domains I have set up in my database, but having a really hard time finding any working examples.  I have a tiled map service and a feature layer that I load and then the following code runs.  Most of the time my tiled map service does not load and the drop down is not populated - however if I refresh the page, my tiled service will load and the drop down is populated.  What am I missing?

map.on("load", init);
    function init()
    {
        codedDomain("myFieldName","myDropDownID");
        
    }
    
    
    function codedDomain(fieldName,dropdown){
        var newDropdown= dom.byId(dropdown);
        var domain = fLayer.getDomain(fieldName);
        for (var i=0; i<domain.codedValues.length; i++)
        {
            if (i<domain.codedValues.length)
            {
                newDropdown[newDropdown.length]=new Option(domain.codedValues.name);    
            }
            
        }
    }
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
SteveCole
Frequent Contributor

One possibility is that your feature layer isn't fully loaded when your map's load event calls your codedDomain function. Are you using this code to add your layers to the map?

map.addLayers([layer01, layer02]);

If you are, you should look into using the map's "layer-add-result" event in order to fire off your codedDomain function. Here's a forum post which kind of shows you the syntax for what you need to do.

Steve

View solution in original post

3 Replies
SteveCole
Frequent Contributor

One possibility is that your feature layer isn't fully loaded when your map's load event calls your codedDomain function. Are you using this code to add your layers to the map?

map.addLayers([layer01, layer02]);

If you are, you should look into using the map's "layer-add-result" event in order to fire off your codedDomain function. Here's a forum post which kind of shows you the syntax for what you need to do.

Steve

KathleenBrenkert
Occasional Contributor

thank you! I was calling it when the map loaded not the layer - works now!

SteveCole
Frequent Contributor

Awesome. The async nature of Javascript still screws me up. Glad you got it working.

0 Kudos