Select to view content in your preferred language

Adding QuakesSince1970 Time Aware to Flexviewer 2.0

638
2
09-02-2010 07:08 AM
MattMoyles
New Contributor III
I've been working on implementing the quakessince1970 time aware layer example into flex viewer but am running into some trouble.  I'm trying to use the TimeWidget that comes with Flexview 2 to do this.  I can't quite figure out how to make the layer display the different quake points like in this sample.  I'm probably just not doing something simple like adding the layer to the map properly but if someone has a second and could look over this code and get back to me I would very much appreciate.

From TimeWidget.mxml
            [Bindable]
            private var sliderLoop:Boolean = false;
            [Bindable]
            private var sliderSingleThumbAsTimeInstant:Boolean = false;
            [Bindable]
            private var sliderThumbCount:int = 1;
            [Bindable]
            private var sliderThumbMovingRate:int = 1000;
            
            private var temporalRenderer:TemporalRenderer;

            protected function init():void
            {
                if (configXML)
                {
                    var dateFormat:String = configXML.dateformat;
                    if (dateFormat)
                    {
                        myDateFormatter.formatString = dateFormat;
                    }
                    sliderLoop = configXML.loop == "true";
                    sliderSingleThumbAsTimeInstant = configXML.singlethumbastimeinstant == "true";
                    if (!isNaN(parseInt(configXML.thumbcount)))
                    {
                        sliderThumbCount = parseInt(configXML.thumbcount);
                    }
                    if (!isNaN(parseInt(configXML.thumbmovingrate)))
                    {
                        sliderThumbMovingRate = parseInt(configXML.thumbmovingrate);
                    }
                    var timeExtent:TimeExtent;
                    var startTime:Number = Date.parse(configXML.timeextent.starttime);
                    var endTime:Number = Date.parse(configXML.timeextent.endtime);
                    if (!isNaN(startTime) && !isNaN(endTime))
                    {
                        timeExtent = new TimeExtent();
                        timeExtent.startTime = new Date(startTime);
                        timeExtent.endTime = new Date(endTime);
                    }
                    if (timeExtent)
                    {
                        var timeStopsInterval:Number = parseFloat(configXML.timestopsinterval);
                        var timeStopsUnits:String;
                        var timeStopsUnitsConfig:String = configXML.timestopsunits || "";
                        switch (timeStopsUnitsConfig.toLowerCase())
                        {
                            case "years":
                                timeStopsUnits = TimeInfo.UNIT_YEARS;
                                break;
                            case "months":
                                timeStopsUnits = TimeInfo.UNIT_MONTHS;
                                break;
                            case "days":
                                timeStopsUnits = TimeInfo.UNIT_DAYS;
                                break;
                            case "hours":
                                timeStopsUnits = TimeInfo.UNIT_HOURS;
                                break;
                            case "minutes":
                                timeStopsUnits = TimeInfo.UNIT_MINUTES;
                                break;
                            case "seconds":
                                timeStopsUnits = TimeInfo.UNIT_SECONDS;
                                break;
                        }
                        if (timeStopsUnits && !isNaN(timeStopsInterval))
                        {
                            timeSlider.createTimeStopsByTimeInterval(timeExtent, timeStopsInterval, timeStopsUnits);
                        }
                        else    
                        {
                            timeSlider.createTimeStopsByCount(timeExtent);
                        }
                    }
                }
                
                //initialize temporal renderer
                /*temporalRenderer = new TemporalRenderer();
                temporalRenderer.latestObservationRenderer = new Renderer();*/
            }
            
            

            protected function widgetClosedHandler(event:Event):void
            {
                timeSlider.pause();
                map.timeSlider = null;
                map.timeExtent = null;
            }

            protected function widgetOpenedHandler(event:Event):void
            {
                map.timeSlider = timeSlider;
                map.addLayer(fLayer);
            }
            
            protected function fLayer_loadHandler(event:LayerEvent):void
            {
                /*var timeInfo:TimeInfo = fLayer.layerDetails.timeInfo;
                myTimeSlider.createTimeStopsByTimeInterval(timeInfo.timeExtent, timeInfo.timeInterval, timeInfo.timeIntervalUnits);*/

        ]]>
    </fx:Script>
    <fx:Declarations>
        <mx:DateFormatter id="myDateFormatter" formatString="MMMM, YYYY"/>
    </fx:Declarations>
    <viewer:WidgetTemplate id="wTemplate"
                           closed="widgetClosedHandler(event)"
                           height="115"
                           minHeight="115"
                           minWidth="335"
                           open="widgetOpenedHandler(event)"
                           width="335">
        <viewer:layout>
            <s:VerticalLayout gap="10"
                              horizontalAlign="center"
                              paddingTop="4"/>
        </viewer:layout>
        <esri:Map timeSlider="{timeSlider}">
            <esri:lods>
                <esri:LOD resolution="39135.7584820001" scale="147914381.897889"/>
                <esri:LOD resolution="19567.8792409999" scale="73957190.948944"/>
                <esri:LOD resolution="9783.93962049996" scale="36978595.474472"/>
                <esri:LOD resolution="4891.96981024998" scale="18489297.737236"/>
                <esri:LOD resolution="2445.98490512499" scale="9244648.868618"/>
                <esri:LOD resolution="1222.99245256249" scale="4622324.434309"/>
                <esri:LOD resolution="611.49622628138" scale="2311162.217155"/>
            </esri:lods>
            <!--esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/-->>
            <esri:FeatureLayer id="fLayer"
                               load="fLayer_loadHandler(event)"
                               mode="snapshot"
                               outFields="[Magnitude]"
                               visible="true"
                               url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0">
                <esri:renderer>
                    <esri:TemporalRenderer>
                        <esri:latestObservationRenderer>
                            <esri:SimpleRenderer>
                                <esri:PictureMarkerSymbol height="60"
                                                          source="assets/Red_glow.swf"
                                                          width="60"
                                                          xoffset="-17"
                                                          yoffset="18"/>
                            </esri:SimpleRenderer>
                        </esri:latestObservationRenderer>
                        <esri:observationRenderer>
                            <esri:ClassBreaksRenderer attribute="Magnitude">
                                <esri:ClassBreakInfo maxValue="5">
                                    <esri:SimpleMarkerSymbol color="0xFF0000"
                                                             size="8"
                                                             style="triangle"/>
                                </esri:ClassBreakInfo>
                                <esri:ClassBreakInfo maxValue="7" minValue="5">
                                    <esri:SimpleMarkerSymbol color="0xFF0000"
                                                             size="12"
                                                             style="triangle"/>
                                </esri:ClassBreakInfo>
                                <esri:ClassBreakInfo minValue="7">
                                    <esri:SimpleMarkerSymbol color="0xFF0000"
                                                             size="25"
                                                             style="triangle"/>
                                </esri:ClassBreakInfo>
                            </esri:ClassBreaksRenderer>
                        </esri:observationRenderer>
                        <esri:observationAger>
                            <esri:TimeRampAger>
                                <esri:alphaRange>
                                    <esri:AlphaRange fromAlpha="0.05" toAlpha="1.0"/>
                                </esri:alphaRange>
                            </esri:TimeRampAger>
                        </esri:observationAger>
                    </esri:TemporalRenderer>
                </esri:renderer>
            </esri:FeatureLayer>
        </esri:Map>
        <s:Label fontSize="14"
                 horizontalCenter="true"
                 styleName="WidgetTitle"
                 text="{myDateFormatter.format(timeSlider.timeExtent.endTime)}"/>
        <esri:TimeSlider id="timeSlider"
                         loop="{sliderLoop}"
                         singleThumbAsTimeInstant="{sliderSingleThumbAsTimeInstant}"
                         thumbCount="{sliderThumbCount}"
                         thumbMovingRate="{sliderThumbMovingRate}"
                         width="100%"/>
    </viewer:WidgetTemplate>
Tags (2)
0 Kudos
2 Replies
BjornSvensson
Esri Regular Contributor
Are you asking how to set up the configuration files for something like the TimeSlider widget sample:
http://help.arcgis.com/en/webapps/flexviewer/live/index.html?config=../samples/config-timeslider.xml

If so, here are the main config files for it:
http://help.arcgis.com/en/webapps/flexviewer/samples/config-timeslider.xml
http://help.arcgis.com/en/webapps/flexviewer/live/widgets/Time/TimeWidget_QuakesSince1970.xml

If not, what is it that you are trying to do in the code for the widget?
0 Kudos
MattMoyles
New Contributor III
Thnx Bjorn thats what I needed for some reason I didn't see these in the documentation.
0 Kudos