Select to view content in your preferred language

Zoom to Full Extent

4378
12
09-08-2010 05:34 AM
JoshuaCoates
Deactivated User
Is there a way to zoom to the full extent of the map by adding some some sort of widget or feature to the header? I have read through similar posts, however, I have not read anything specific about "zoom to full extent". Also, any reason why my map background used to display white as it is suppose to be in my web browser but it is now black like the rest of the UI around the map? (off topic I know, just didnt want to posts several different posts for what is probably an easy fix). Thanks!


Josh C.
Tags (2)
0 Kudos
12 Replies
AndyGup
Esri Regular Contributor
Hi Josh,

To automatically zoom to the full extent of the map put the values for the full extent as properties similar to this. I just copied and pasted from the API doc samples, but you should get the idea:

<?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="World Street Map">

    <!--
    This sample shows how to add a street basemap layer to your application.

    The sample uses a cached map service from ArcGIS Online.

    You can browse the ArcGIS.com site for additional online basemap and reference
    map services or publish your own geographic data as a service using ArcGIS Server.
    -->

    <fx:Declarations>
        <esri:Extent id="initialExtent"
                     xmin="-17731" ymin="6710077" xmax="-12495" ymax="6712279">
            <esri:SpatialReference wkid="102100"/>
        </esri:Extent>
    </fx:Declarations>

    <esri:Map extent="{initialExtent}">
        <esri:ArcGISTiledMapServiceLayer url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
    </esri:Map>
</s:Application>


I know you didn't ask about it, but to zoom to the full extent of the map manually try something like this were tiledMapLyr1 is the id of your map service layer:

protected function button1_clickHandler(event:MouseEvent):void
{
[INDENT]var newExtent:Extent = tiledMapLyr1.fullExtent;
map.extent = newExtent;
[/INDENT]}

You can find this info in the API reference, for a tiledMapServiceLayer you'd look here: http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/TiledMapServiceLayer.html

In regards to the background color behind the map, that is based on the backgroundColor property that is set for your application, for example:

<s:Application
[INDENT]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="World Topographic Map"
backgroundColor="black">
[/INDENT]
You'll just need to check and see what that is set too in your app. I hope that helps,

-Andy
ESRI Developer Network (EDN)
0 Kudos
BjornSvensson
Esri Regular Contributor
Josh, I'm assuming this is in regards to the new Flex Viewer...

FYI - "Zoom to full extent" functionality will be part of a Navigation Widget that we plan to include in version 2.1 of the ArcGIS Viewer for Flex.
0 Kudos
JoshuaCoates
Deactivated User
Yea that didnt really help too much, but thanks anyway. I was just looking to have a button to go to the initial extent of the map like bjorn was saying. I guess I'll have to wait.
0 Kudos
BillLotz
Frequent Contributor
Josh, I'm assuming this is in regards to the new Flex Viewer...

FYI - "Zoom to full extent" functionality will be part of a Navigation Widget that we plan to include in version 2.1 of the ArcGIS Viewer for Flex.


Is there a list on the new functionality that will be included in 2.1?
I just created a primitive navigation widget; while I did learn a lot, I just as soon use your stuff?
0 Kudos
JoshuaCoates
Deactivated User
knoxgis,

would you be kind enough to share your code for the navigation widget you have created? I would like to see how it looks?
0 Kudos
BillLotz
Frequent Contributor
knoxgis,

would you be kind enough to share your code for the navigation widget you have created? I would like to see how it looks?

Joshua,
I just took the code from the navigation bar sample at http://help.arcgis.com/en/webapi/flex/samples/index.html and put it in a widget. I copied the "Hello World" widget under the samples and put it in that.
I did have to nest the controlBarLayout in a Panel to get it to work.
Bill
0 Kudos
JoshuaCoates
Deactivated User
Can I just insert all the code from that, from " <fx:Script> all the way to the bottom into my MapManager.mxml and it work? What do you mean by "nest the controlBarLayout in a Panel"? Can you post your mxml so I can look at this? I really do not know much about creating code so seeing it helps. Thanks for your help!
0 Kudos
BillLotz
Frequent Contributor
Can I just insert all the code from that, from " <fx:Script> all the way to the bottom into my MapManager.mxml and it work? What do you mean by "nest the controlBarLayout in a Panel"? Can you post your mxml so I can look at this? I really do not know much about creating code so seeing it helps. Thanks for your help!

Josua,
Guess what, I don't know much about creating code either! I posted (or attempted to) a zip of the mxml. You will se that I haven't done much to this yet, it isn't real refined,  but it does work for me. It sound like the widget in the next release will be the way to go, but it is good to play around with the code.
I just got my learner's permit.
Bill
0 Kudos
JoshuaCoates
Deactivated User
Thanks Bill, it works like a charm. Well I havent actually "used" the tools yet, because I'm in the process of caching my map services so I can not physically see my map to test the funcionality of the tools. But i have the widget showing up and the tools are in there with my custome title and ID:) I appreciate it!!


Thanks,
Josh C.
0 Kudos