Select to view content in your preferred language

How to force a map load on a map in a tab not shown?

2644
12
11-30-2011 12:07 PM
CarmenDurham
Frequent Contributor
Please see attached image..

The location and FireGround tabs both contain maps.  The user enters an address and the maps on both tabs need respond to the address entered. 

When the app first opens, the Location tab is active. If an address is entered first, and then make the FireGround tab active, nothing happens because it appears that the Map is not loaded yet.   Is there a way to "force" the Map to load without activating the tab?  I want the fire responders to be able to click on the FireGround tab and it already be zoomed to the entered address with the information they need.

Once the FireGround tab is activated, I can enter an address and it works fine.

Using API 2.0.
Hope I am just missing something simple.
Thanks,
Carmen
Tags (2)
0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
Carmen,

   If you are using a ViewStack than you need the creationPolicy set to all

<mx:ViewStack id="vs" height="100%" width="100%" creationPolicy="all">
0 Kudos
CarmenDurham
Frequent Contributor
Robert,

Well, that helped, for sure, but then another issue pops up!

I can tell the processing occurs, but the extent and/or scale that I set is not honored in the second tab.  I am not sure where it is going.  I stripped the code down to the same exact thing for both tabs - initial extent and all  -- but the initial extent on the second tab is always wrong. (I have switched the two maps and the same thing happens for second tab).

See images and I have attached the stripped down code. 

First image - location_extentasexpected.jpg is the first tab.  Everything appears correctly.
Second image - firegroundtab_extentwrong.jpg.  This is what appears when the second tab is clicked to display fireground map.  This should appear exactly the same as the first image with this basic code. But the extent is not the same.  With the full code, all of the processing occurs and graphics are displayed, but none of the extent/scale changes are honored.

Any help will be appreciated - I have a Friday deadline. I really hope it is not another bug with scales and extents.  I have already had issues with bugs and API versions!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Carmen,

    What is the reasoning on using an API version that is 4 minor versions behind and about to be 5 minor version behind real soon?
0 Kudos
CarmenDurham
Frequent Contributor
Robert,

Good question.  I was using 2.4 api until yesterday when I hit another oddity with zooming/scaling (I've already discovered one bug).  I reverted back to 2.0 (because it has worked well for me on all other applications) and that problem was resolved. 

I tried the 2.4 api with the code attached above and had the same problem. 

In the interest of time, I just kept running with the 2.0.  The Friday deadline is a proof of concept and trial test in the field to see if this thing will work with the 4G aircards in the firetrucks.  I would have time after the test (and before final app) to figure out the scaling issue (and see if it needs to be reported to ESRI) and see if another API would work. If the app fails in the field, we have bigger problems and I may not even be continuing with the application!

The request for the second tab with a map came just last week.  Sadly, I don't get big chunks of time for programming which makes it more difficult to keep up.  I would love to do this on a regular basis, but it never turns out that way.

As always, thanks for your help.
Carmen
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Carmen,

   Here is my solution, which is actually more efficient anyway (why load the map before it is needed).

<?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:mx="library://ns.adobe.com/flex/mx" 
               xmlns:esri="http://www.esri.com/2008/ags" minWidth="955" minHeight="600"
               xmlns:local="*"
               >
    <fx:Script>
        <![CDATA[
            import com.esri.ags.FeatureSet;
            import com.esri.ags.Graphic;
            import com.esri.ags.SpatialReference;
            import com.esri.ags.events.ExtentEvent;
            import com.esri.ags.events.GraphicEvent;
            import com.esri.ags.geometry.Extent;
            import com.esri.ags.geometry.MapPoint;
            import com.esri.ags.layers.Layer;
            import com.esri.ags.layers.supportClasses.LOD;
            import com.esri.ags.tasks.supportClasses.Query;
            
            import mx.controls.Alert;
            import mx.managers.ToolTipManager;
            import mx.rpc.AsyncResponder;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            
            import skins2.SearchButtonSkin;
            

            private function onFault(event:FaultEvent):void                
            {
                Alert.show("There was a problem while processing request", "ERROR");               
            } 
            
            private function OpenSearch_Click():void
            {
                //theAddressSearch.visible = true;
            }            
            
            protected function navigatorcontent1_activateHandler(event:Event):void
            {
                var fireGroundMap:FireGroundTab = new FireGroundTab();
                fireground.addElement(fireGroundMap);
            }
            
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <esri:QueryTask id="countyBoundaryQueryTask" 
                        url="http://gis.greenvillesc.gov/ArcGIS/rest/services/BaseMaps/GreenvilleSpecialDisplay/MapServer/2" useAMF="false" 
                        fault="onFault(event)">
        </esri:QueryTask>
        
        <esri:SimpleFillSymbol id="countyLimFillOut" color="0xFF0000" alpha="0.5" style="diagonalcross" >
            <esri:SimpleLineSymbol color="0xFF0000" width="4" alpha="1" style="solid" />
        </esri:SimpleFillSymbol>
        <esri:SimpleFillSymbol id="countyLimFillIn" color="0xFFFF99" alpha="0.5" style="diagonalcross" >
            <esri:SimpleLineSymbol color="0xFFFF99" width="4" alpha="1" style="solid" />
        </esri:SimpleFillSymbol>
    </fx:Declarations>    
    
    <fx:Style>
        


    </fx:Style>
    <s:BorderContainer id="bcapp" borderColor="#007B57" width="100%" height="100%" borderWeight="3"  cornerRadius="3" skinClass="skins2.FireApplicationSkin"  >
        <s:VGroup width="100%" height="100%" gap="-3" top="65" left="5" bottom="5">    
        <s:TabBar id="tabs" left="8" y="2" dataProvider="{vs}" skinClass="skins2.CustomTabBarSkin" cornerRadius="4" height="50" />
        <mx:ViewStack id="vs" width="98%" height="95%" left="8" y="50">
            <s:NavigatorContent label="Location" width="100%" height="100%" > 
                <local:LocationTab id="locationMap"/>
            </s:NavigatorContent>
            <s:NavigatorContent label=" FireGround " id="fireground"  width="100%" height="100%" activate="navigatorcontent1_activateHandler(event)">
            </s:NavigatorContent>
            <s:NavigatorContent label=" FireHouse Info " width="100%" height="100%">    
            </s:NavigatorContent>    
        </mx:ViewStack>
        </s:VGroup>
    </s:BorderContainer>
</s:Application>
0 Kudos
CarmenDurham
Frequent Contributor
Well, at least it sounds like you are seeing some weirdness, also, and it isn't just me.  Thank you for checking on it.

(Robert had replied further but then deleted his submission)
0 Kudos
CarmenDurham
Frequent Contributor
Just an update - I have submitted this to technical support to see if it is some bug or error on my part.  Now using API 2.5 with same issue.

We performed "proof of concept" test using the 4G aircards using the application with just one of the tabs containing a map and the speed in the field was better than expected.  So, now I do need the two tabs with maps to work correctly!

Carmen
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Carmen,

   This is the only workaround I have come up with and I am not very happy with it but it works. This must be a bug with map extents.
0 Kudos
CarmenDurham
Frequent Contributor
Robert,

Thanks for helping.  It zoomed to the right extent on FireGround but then
1) the Graphic for the city/county never appeared and
2) I could no longer pan/zoom/navigate within the FireGround map.

Would you please take a look and let me know if you see the same behavior?

Thanks,
Carmen

I sent tech support two sites in trying to explain this if you or anyone else wants to see (will be disabled after support call finished).

The following includes the address search which started the whole thing.  The fireman should be able to open the app, enter the address, and the location tab would do something and the fireground tab should process without them clicking on anything but the "Search" button.

https://gis.greenvillesc.gov/twotab2/
Open, but don't touch any of the tabs and enter 206 s main st
(Location tab still does nothing but display graphic at City of Greenville scale).  Once address is entered, click the FireGround tab.   It Should zoom to a red circle and some fire hydrants.  Usually, they end up at the far upper right corner instead of middle of screen.  Interestingly, if you then enter the address again (or another one), it will work fine.  Or if you open the app and click on fireground before entering the address, it seems to work.

Then here is the one with the tabs switched - Fireground now works fine when an address is entered, but the Location map's extent is no longer with City in the middle.

https://gis.greenvillesc.gov/twotab1/

Bizarre.
0 Kudos