Select to view content in your preferred language

Zoom in - click instead of drawing box?

986
3
07-12-2010 10:20 AM
SusanMordy1
Deactivated User
Users are used to clicking on the screen to zoom out with the zoom out tool, instead of drawing a box.

In ArcMap, the zoom out tool allows users to click on the screen to zoom out in addition to drawing a box to zoom out.

It is possible to do this with the FSV?
Tags (2)
0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
It would require a code change. I've updated the NavigationTools.mxml sample to show how it can be done. See the myMap_mapClickHandler function.

<?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"
               pageTitle="Using the navigation tools">

    <fx:Script>
        <![CDATA[
            import com.esri.ags.events.MapMouseEvent;
            import com.esri.ags.tools.NavigationTool;
            
            import mx.logging.LogEventLevel;
            
            import spark.events.IndexChangeEvent;

            private function tbb_changeHandler(event:IndexChangeEvent):void
            {
                switch (tbb.selectedItem)
                {
                    case "Zoom In":
                        {
                            navTool.activate(NavigationTool.ZOOM_IN);
                            break;
                        }
                    case "Zoom Out":
                        {
                            navTool.activate(NavigationTool.ZOOM_OUT);
                            break;
                        }
                    case "Pan":
                        {
                            navTool.activate(NavigationTool.PAN);
                            break;
                        }
                    default:
                        {
                            navTool.deactivate();
                            break;
                        }
                }
            }

            protected function myMap_mapClickHandler(event:MapMouseEvent):void
            {
                if (tbb.selectedItem == "Zoom Out")
                {
                    myMap.centerAt(event.mapPoint);
                    myMap.zoomOut();
                }
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <esri:NavigationTool id="navTool" map="{myMap}"/>

        <mx:TraceTarget includeCategory="true"
                        includeLevel="true"
                        includeTime="true"
                        level="{LogEventLevel.DEBUG}"/>
        <!-- The output from TraceTarget is available when debugging this sample in Flash Builder -->
    </fx:Declarations>

    <s:controlBarLayout>
        <s:HorizontalLayout gap="10"
                            horizontalAlign="center"
                            paddingBottom="7"
                            paddingLeft="10"
                            paddingRight="10"
                            paddingTop="7"/>
    </s:controlBarLayout>
    <s:controlBarContent>
        <s:ButtonBar id="tbb" change="tbb_changeHandler(event)">
            <s:ArrayList>
                <fx:String>Zoom In</fx:String>
                <fx:String>Zoom Out</fx:String>
                <fx:String>Pan</fx:String>
            </s:ArrayList>
        </s:ButtonBar>
        <s:HGroup gap="0">
            <s:Button click="navTool.zoomToPrevExtent()"
                      enabled="{!navTool.isFirstExtent}"
                      label="Previous Extent"/>
            <s:Button click="navTool.zoomToNextExtent()"
                      enabled="{!navTool.isLastExtent}"
                      label="Next Extent"/>
        </s:HGroup>
        <s:Button click="navTool.zoomToFullExtent()" label="Full Extent"/>
    </s:controlBarContent>

    <esri:Map id="myMap" mapClick="myMap_mapClickHandler(event)">
        <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
    </esri:Map>

</s:Application>
0 Kudos
SusanMordy1
Deactivated User
Thanks Dasa. I added some of the above code to mapManager.mxml but I get the following error:

Defintion import com.esri.ags.tools.NavigationTool; could not be found
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos