3

I'm working on an application that has to access data from a server. The flex application uses Esri's World_Imagery basemap and is able to access my data from the ArcGIS for Server, running locally on the same machine.

There are multiple layers to the data that are be displayed, and I would like to toggle them from ActionScript. What is the best way to do this? I've taken a look at the documentation, but it's unclear to me how to go about doing this without the preset widgets that Esri provides.

Here's my code:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Example - dynamic maps on top of projected map tiles">

    <fx:Script>
        <![CDATA[
            var b:Boolean = false;
            if (b) {
                //Show Pennwell_PowerPlants
            } else {
                //Hide Pennwell_PowerPlants
            }
        ]]>
    </fx:Script>

    <esri:Map level="3" wrapAround180="true">
        <esri:center>
            <esri:WebMercatorMapPoint lon="0" lat="0" />
        </esri:center>
        <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" />
        <esri:ArcGISDynamicMapServiceLayer url="http://localhost:6080/arcgis/rest/services/Pennwell_Substations/MapServer" />
        <esri:ArcGISDynamicMapServiceLayer url="http://localhost:6080/arcgis/rest/services/Pennwell_PowerPlants/MapServer" />
    </esri:Map>
</s:Application>
1

give your map "layers" IDs. toggle the visibility on/off via the "visible" option. eg.

penwellPowerStations.visible=false; // hide it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.