Select to view content in your preferred language

Flex Viewer 2.1 - Increase maximum zoom?

3241
13
09-24-2010 06:44 AM
JackReed
Emerging Contributor
Hi,
I am using the already compiled flex viewer 2.1 and have dynamic operational layers on top of the default basemaps.  What I would like to do is to be able to zoom in closer than the default maximum zoom.  Is this possible?  I cannot find any documentation anywhere relating to this.

Thanks,
Jack
Tags (2)
0 Kudos
13 Replies
ErwanCaradec
Emerging Contributor
In previous version (1.3) it was possible to add lods (Levels Of Details) in MapManager.mxml, adding lines in map.lods array (one for each extra LOD) in mapLoadComplete function :
var lods:Array = map.lods;
lods.push( new LOD( NaN, 0.6, 3000) );
lods.push( new LOD( NaN, 0.3, 1500) );
lods.push( new LOD( NaN, 0.1, 500) );


But in 2.1 version, this modification doesn't work fine, when i zoom to one of this "extra" LOD i've got this flash error from Flex Api :
TypeError: Error #1010: Un terme n'est pas défini et n'a pas de propriété.
 at com.esri.ags.layers::TiledMapServiceLayer/loadTiles()


I need help too.
Thanks

Erwan
0 Kudos
MarcWeinshenker1
Regular Contributor
In MapManager.mxml I did the following:

Add this line among the imports at the top of the module:
import com.esri.ags.layers.supportClasses.LOD;

In the private function addLayerToMap inside the case "tiled", after map.addLayer(tiledLayer); add the line:
map.addEventListener(MapEvent.LOAD, addLODs);

Finally, at the bottom of the module, add this function (using LODs per your needs; my code adds two zoom-in steps beyond the default):

   private function addLODs (event:MapEvent):void  
   {
    var lods:Array = map.lods;
    lods.push( new LOD( 18, 0.597164283559817, 2256.994353 ) );
    lods.push( new LOD( 19, 0.298582141647617, 1128.497176 ) );
    map.lods = lods;
   }     

Hope this helps.  Sorry for not using code insertions but I'm not a frequent enough poster on these new boards to have figured it out yet.

Marc
0 Kudos
ErwanCaradec
Emerging Contributor
Thanks Mark,
you're right in 2.1 version, level value is needed, in 1.3 it was not, NaN value was correct.

In my implementation, with multi-config i need to add extra lod configuring config.xml like this :
<extralods>
 <extralod level="18" resolution="0.597164283559817" scale="2256.994353" />
 <extralod level="19" resolution="0.298582141647617" scale="1128.497176" />
</extralods>


If you need too, have a look at the modifications quoted "24/09/2010 #1" in attached files :
config.xml
ConfigData.as
ConfigManager.as
MamManager.mxml

Hope that helps.
Erwan
0 Kudos
JackReed
Emerging Contributor
Thanks for the feedback.  I am very new to Flex, and have been using the stock viewer with just some minor modifications.  If I understand correctly I need to make these changes in Adobe Flash Builder, then compile?

Thanks for your patience.

Jack
0 Kudos
ErwanCaradec
Emerging Contributor
Yes Jack,
just modify the source code as Marc Weinshenker indicate, in FlashBuilder 4, then recompile.
0 Kudos
ErwanCaradec
Emerging Contributor
I'd like to increase zoom by adding extra LODs (Levels Of Details) using a widget (code less intrusive).
In debug mode it looks that the my new LODs are correctly added to the map.lods array, but zoom slider control is not refreshed.
Is there a way to load the widget at the correct moment or refresh the map controls after new LODs have been added ?

Thanks.

Erwan

EtxraLodsWidget.xml :
<?xml version="1.0" ?>
<configuration>
 <extralods>
  <extralod level="18" resolution="0.597164283559817" scale="2256.994353" />
  <extralod level="19" resolution="0.298582141647617" scale="1128.497176" />
 </extralods>
</configuration>

ExtraLodsWidget.mxml :
<?xml version="1.0" encoding="utf-8"?>
<!--
     ////////////////////////////////////////////////////////////////////////////////
     //
     // Copyright (c) 2010 ESRI
     //
     // All rights reserved under the copyright laws of the United States.
     // You may freely redistribute and use this software, with or
     // without modification, provided you include the original copyright
     // and use restrictions.  See use restrictions in the file:
     // <install location>/License.txt
     //
     ////////////////////////////////////////////////////////////////////////////////
-->
<viewer:BaseWidget 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:viewer="com.esri.viewer.*"
                   widgetConfigLoaded="init()" xmlns:esri="http://www.esri.com/2008/ags">
    <fx:Script>
        <![CDATA[
   import com.esri.ags.events.MapEvent;
   import com.esri.ags.layers.supportClasses.LOD;
            
   private var extraLodsXml:XMLList;
   private var extraLodsArr:Array = [];

            private function init():void
            {
                if (configXML)
                {
     extraLodsXml = configXML..extralod;
     addLODs();
     
     //map.addEventListener(MapEvent.LOAD, addLODs);
     //map.dispatchEvent(new MapEvent(MapEvent.LOAD));
     
                }
            }
   private function addLODs():void
   {
    for (var i:Number = 0; i < extraLodsXml.length(); i++)
    {
     var lLevel:Number = Number(extraLodsXml[0].@level[0]);
     var lResolution:Number = Number(extraLodsXml.@resolution[0]);
     var lScale:Number = Number(extraLodsXml.@scale[0]);
     map.lods.push( new LOD( lLevel, lResolution, lScale) );
    }
   }    
        ]]>
    </fx:Script>
</viewer:BaseWidget>
0 Kudos
GeraldLee__GISP
Frequent Contributor
Cool, I need this too, but what if you dont have FlashBuilder?
0 Kudos
PaulLang
Deactivated User
I have this working. 
But let�??s say I would like to remove the existing and just use the ones I define.

Where to you go to remove the existing?
0 Kudos
ErwanCaradec
Emerging Contributor
Gerald,
here is my beta version of the ExtraLodsWidget for the FlexViewer 2.1, in the zip file you'll find uncompiled and compiled versions.
Now it's working, i've solved the zoom slider problem by sharing data between my ExtraLodsWidget and NavigationWidget.

Have look at the ReadMe file for installation instructions.

Regards.
Erwan Caradec

* paull : Could you post your code please ?  You may have a better solution.
0 Kudos