Select to view content in your preferred language

Zoom jumps around

2089
7
12-01-2011 11:46 AM
DorothyMortenson
Deactivated User
Hello,
I have a couple of map applications. The user can make a request, say for a particular attribute of a polygon dataset. The application finds the record of choice then zooms to that polygon - or so it should.

I find that sometimes it works the first time; sometimes it does a little jumping around but doesn't zoom - but if you click the search button again (same request) then it will zoom.

I went several months without this problem, but it seems to be getting worse.

I have a hunch it has something to do with the ContrainExtentBehavior and the size/shape of the browser window, but I'm not sure.

Following is the xaml for the map:

<esri:Map x:Name="Map" Background="White" 
                              Extent="{StaticResource StartExtent}" 
                              IsLogoVisible="False"  
                              >
                    <i:Interaction.Behaviors>
                        <esri:ConstrainExtentBehavior ConstrainedExtent="-14055335, 5124845, -12536844, 5853025" />
                    </i:Interaction.Behaviors>

                    <!-- MAP LAYERS -->
                    <esri:Map.Layers>
                        <esri:ArcGISTiledMapServiceLayer ID="Base Layer"
                       Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" Opacity="1.0" Visible="True" MinimumResolution="2" />
...


Any ideas on how to prevent this jumping-but-no-zooming behavior?

Dorothy
0 Kudos
7 Replies
DominiqueBroux
Esri Frequent Contributor
We would need to look at your zoom code.
0 Kudos
DorothyMortenson
Deactivated User
Ok.

Here is one example. The person selects a well record. A search is done to find the township/range/section. Once it's found, we zoom to that section. Here is what happens after the section is found.

      void QueryTaskSTR_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
        {

            FeatureSet featureSet = args.FeatureSet;

            if (featureSet.Features.Count == 1)
            {
                try
                {
                    Graphic selectedFeature = featureSet.Features[0];

                    double expandPercentage = 30;

                    // Zoom to selected feature (define expand percentage)
                    ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent;

                    double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100);
                    double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100);


                    ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
                    selectedFeatureExtent.XMin - (widthExpand / 2),
                    selectedFeatureExtent.YMin - (heightExpand / 2),
                    selectedFeatureExtent.XMax + (widthExpand / 2),
                    selectedFeatureExtent.YMax + (heightExpand / 2));

                    Map.ZoomTo(displayExtent);
                }
                 catch (Exception ex)
                {

                    MessageBox.Show("error: Township/Range " + ex.Message);
                }
             else
             {
              MessageBox.Show("Could not find".)
              }
               
            }


        }
0 Kudos
DorothyMortenson
Deactivated User
Just some more information.

With the browser using the whole screen.
The original map scale is: 1:3,899,267
With the first click of the button, it goes to: 1:3,558,777
With the second click of the same button, it goes to: 1:13,746

Dorothy
0 Kudos
rbae
by
Regular Contributor
I had the same issue with ConstrainExtentBehavior. 

Removed it and zoom worked fine.
0 Kudos
DorothyMortenson
Deactivated User
Yes, you are right. This gets rid of the problem.

It poses another problem, however.

The user first comes to the website with the right map extent, set by the "Extent=".  But if the user clicks on the "full extent", it zooms to the whole world.

I've got a couple of ideas Im going to try, but if anyone knows of a solution, please chime in.

Dorothy
0 Kudos
DorothyMortenson
Deactivated User
1. I have tried to set the Maxresolution of the world tiled layers I am using from ESRI. Did not work.
2. I am using the Silverlight Glass template, which includes the nice navigation bar. I was not able to find a way to control the extent of the Full Extent icon/button in the navigation tool. Seems built in.
3. I was not able to create a new icon to replace the original without it looking stupid or making it more complicated than it needs to be.

My resolution at this stage is to continue to use the ContrainExtentBehavior, but have a much more relaxed constrainedextent. It'll be bigger than I need, but at least it won't be the whole world.

so far so good.
0 Kudos
MichaelKohler
Frequent Contributor
Don't know about some of your problem. But you can change the ZoomToFullExtent if you have Expression. Open the project in Expression and select the Navigation Control. Right click on the [Navigation] control and select Edit Template... Edit Copy. Exit Expression and save changes.

Then in the xaml that was added to your User Control resources, there is a Navigation Style. Somewhere in there is the button ZoomMyFullExtent. Add a CLICK event to the button

<Button x:Name="ZoomMyFullExtent" BorderBrush="{TemplateBinding BorderBrush}" Cursor="Hand" Grid.Column="1" HorizontalAlignment="Right" Height="20" ToolTipService.ToolTip="Full Extent" VerticalAlignment="Bottom" Width="20" Click="ZoomFullExtent_Click">
                                <Grid Height="14" Width="14" Background="#FFE08D25">
                                    <Ellipse Height="Auto" Stroke="White" Width="Auto"/>
                                    <Ellipse Height="6" Stroke="White" Width="Auto"/>
                                    <Ellipse Height="Auto" Stroke="White" Width="6"/>
                                </Grid>
                            </Button>



And this is my click event
//routine to override the existing zoom to full extent which will zoom to world. This zooms to specified envelope.
        private void ZoomFullExtent_Click(object sender, RoutedEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.Envelope g = new ESRI.ArcGIS.Client.Geometry.Envelope(-8959408, 3149172, -8931633, 3170921);
            MyMap.ZoomTo(g);
        }
0 Kudos