+ Reply to Thread
Results 1 to 13 of 13

Thread: Map Resolutions

  1. #1
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Map Resolutions

    I want to set the MaximumResolution property so that you can't zoom out past the full extent of the largest layer in a map pack. Is there a way to programmatically get that value so that when you change map packs it can automatically calculate that?

    Also, is there a way to force the map object to limit the pan range so you can't pan way over past the edge of the world and then zoom into whitespace and get lost?

    Thanks,

    James

  2. #2
    Mike Branscomb

    Join Date
    Feb 2010
    Posts
    882
    Points
    359
    Answers Provided
    59


    0

    Default Re: Map Resolutions

    Hi,

    I'll look into the MaximumResolution <> Map Package question.

    Regarding limiting the pan - one very easy way to resolve this is setting the WrapAround property on the Map to True. Alternatively you could investigate listening for the map extent changed event then checking the requested extent against your restricted extent... but the overhead may be too great and/or getting the right user experience when they do try to navigate outside that extent may be tricky.

    Cheers

    Mike
    ArcGIS Runtime Product Engineer

  3. #3
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map Resolutions

    The "WrapAround" property says that it only supports WGS84 projections. The layers in my map package have GCS_WGS_1984 as the coordinate system. I'm not sure if that's the same or not. But when I set the property to true and add my LocalDynamicMapServiceLayer to the map control I checked the "WrapAroundIsActive" property and it was false, and the "SpatialProjection" of the map object was null. Since it's a read-only property, how should I set the SpatialProject to the WGS84?

    Thanks,

    James

  4. #4
    Mike Branscomb

    Join Date
    Feb 2010
    Posts
    882
    Points
    359
    Answers Provided
    59


    0

    Default Re: Map Resolutions

    Hi,

    The WrapAround property supports both the following coordinate systems:

    - WGS 1984 (WKID 4326) which is the same as your GCS_WGS_1984 map cordinate system
    - WGS 1984 Web Mercator Auxilliarty Sphere (WKID 3857 / 102100)

    The spatial reference property of the map control is determined by the coordinate system of the first valid layer added to the map. The map control does not support client-side projection-on-the-fly hence why the property is read-only.

    If you're adding the layer in XAML... or even code... and hitting a break point to check the spatial reference of the map before the LocalMapService has initialized then the spatial reference might simply not have been set yet?

    Cheers

    Mike
    ArcGIS Runtime Product Engineer

  5. #5
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map Resolutions

    Ok, well then it should work, but it doesn't. I am loading the layer in code and adding to the map object after initializing it. It's after that I set the property and check. And after that when the map displays I can still pan off into the infinite display of white-space in any direction.

    This is my code:
    Code:
    LocalArcGISDynamicMapServiceLayer lyr = new LocalArcGISDynamicMapServiceLayer(PATH_TO_MAP_PACK);
    lyr.Initialize();
    map.Layers.Add(lyr);
    map.WrapAround = true;
    After that line I check the properties on the map object and WrapAround is true but WrapAroundIsActive is false and the SpatialReference is null.

  6. #6
    Mike Branscomb

    Join Date
    Feb 2010
    Posts
    882
    Points
    359
    Answers Provided
    59


    0

    Default Re: Map Resolutions

    Hi,

    It's better to have the Map itself control the initialization of the layer rather than calling the Initialize() method directly. For example, try something along the following lines (assumes your Map's x:Name property is "MapControl"):


    MapControl.WrapAround = true;

    //Add a WGS84 tiled service:
    ArcGISTiledMapServiceLayer arcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer()
    {
    Url = "http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer",
    ID="WorldTopoMap"
    };
    MapControl.Layers.Add(arcGISTiledMapServiceLayer);

    //Add a WGS84 Map Package asynchronously:
    LocalMapService.GetServiceAsync(@"PATH_TO_MAP_PACK", (localMapService) =>
    {
    LocalArcGISDynamicMapServiceLayer localArcGISDynamicMapServiceLayer = new LocalArcGISDynamicMapServiceLayer()
    {
    Path = localMapService.Path,
    ID = "TheLayerID",
    ImageFormat = ArcGISDynamicMapServiceLayer.RestImageFormat.PNG32,
    PanBuffer = PanBufferSize.Medium
    };
    MapControl.Layers.Add(localArcGISDynamicMapServiceLayer);
    });

    I'm interested to hear your results. If you're still not seeing the WrapAround property work as you expect - perhaps you could post a small, shareable, sample of your data that I can test?

    Cheers

    Mike
    ArcGIS Runtime Product Engineer

  7. #7
    Mike Branscomb

    Join Date
    Feb 2010
    Posts
    882
    Points
    359
    Answers Provided
    59


    0

    Default Re: Map Resolutions

    Hi,

    Following up on the question about limiting the pan extent and the maximum resolution <> map package question - you can use the ConstrainExtentBehaviour to achieve both goals:

    http://resourcesbeta.arcgis.com/en/h...tBehavior.html

    Which you can implement by doing the following:

    1. Add the required references:

    System.Windows.Interactivity.dll
    ESRI.ArcGIS.Client.Behaviors.dll

    2. Declare the System.Windows.Interactivity.dll namespace in your window delcaration:

    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

    3. Add a behaviour collection to the map and specify a ConstrainExtentBehavior in XAML:

    <esri:Map x:Name="MyMap" Extent="-120,30,-60,60">
    <i:Interaction.Behaviors>
    <esriBehaviors:ConstrainExtentBehavior
    ConstrainedExtent="-120,30,-60,60"/>
    </i:Interaction.Behaviors>
    </esri:Map>

    4. Or do it in code:

    XAML:

    <i:Interaction.Behaviors>
    <esriBehaviors:ConstrainExtentBehavior x:Name="Constraint" />
    </i:Interaction.Behaviors>

    Code:

    using System.Windows.Interactivity;
    using ESRI.ArcGIS.Client.Behaviors;

    Envelope env = new ESRI.ArcGIS.Client.Geometry.Envelope(-13046639, 4036241, -13045773, 4036769);
    Constraint.ConstrainedExtent = env;


    Cheers

    Mike
    Last edited by mbranscomb; 08-16-2011 at 07:35 AM.
    ArcGIS Runtime Product Engineer

  8. #8
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map Resolutions

    Quote Originally Posted by mbranscomb View Post
    Hi,

    It's better to have the Map itself control the initialization of the layer rather than calling the Initialize() method directly. For example, try something along the following lines (assumes your Map's x:Name property is "MapControl"):


    MapControl.WrapAround = true;

    //Add a WGS84 tiled service:
    ArcGISTiledMapServiceLayer arcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer()
    {
    Url = "http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer",
    ID="WorldTopoMap"
    };
    MapControl.Layers.Add(arcGISTiledMapServiceLayer);

    //Add a WGS84 Map Package asynchronously:
    LocalMapService.GetServiceAsync(@"PATH_TO_MAP_PACK", (localMapService) =>
    {
    LocalArcGISDynamicMapServiceLayer localArcGISDynamicMapServiceLayer = new LocalArcGISDynamicMapServiceLayer()
    {
    Path = localMapService.Path,
    ID = "TheLayerID",
    ImageFormat = ArcGISDynamicMapServiceLayer.RestImageFormat.PNG32,
    PanBuffer = PanBufferSize.Medium
    };
    MapControl.Layers.Add(localArcGISDynamicMapServiceLayer);
    });

    I'm interested to hear your results. If you're still not seeing the WrapAround property work as you expect - perhaps you could post a small, shareable, sample of your data that I can test?

    Cheers

    Mike
    I tried this way as well. This time when I check properties after everything is loaded and running the "WrapAroundIsActive" is true, but it still allowed me to pan way off into the ocean of white-space and lose my way back to the map. I have tried to attached the map pack I'm using, but it won't allow me to. It lists the file size limit as 10MB for mpk files and mine is only 3.7MB, so I think the form is broken as I'm getting a "Request Entity Too Large" error.

    I guess I'll try the Interactivity stuff next, but your response doesn't address how to find the max extent of the map pack dynamically, just how to set the values.

    Thanks,

    James

  9. #9
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map Resolutions

    For adding the reference to the behaviors dll in the xaml, is there a schema for it or should I just add a direct assembly reference like so:

    xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors"

    Thanks,

    James

  10. #10
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map Resolutions

    Quote Originally Posted by psiclopz View Post
    I guess I'll try the Interactivity stuff next, but your response doesn't address how to find the max extent of the map pack dynamically, just how to set the values.
    I figured it out. I tied onto the map.Layers.LayersInitialized event and then grabbed the map.Extent which was automatically the entire map, and used that as the base for my constraint. It works great. Don't know why the WrapAround stuff doesn't work, but this Constraint might work out better anyways.

    Thanks,

    James

  11. #11
    Mike Branscomb

    Join Date
    Feb 2010
    Posts
    882
    Points
    359
    Answers Provided
    59


    0

    Default Re: Map Resolutions

    Hi,

    Re Full Extent of Map Package:

    If you use the LocalMapService class to work with Map Packages then you have the access to the FullExtent property as soon as the local map service is initialized. Alternatively, you'll get the same extent value from the FullExtent property of the LocalArcGISDynamicMapServiceLayer which will be populated during the layer initialization. In this case, you can either use the LayersInitialized event as you have, or if you want to listen for a specific layer, you can use the Initialized event on the layer, for example:

    localArcGISDynamicMapServiceLayer.Initialized += (s, e) =>
    {
    // Do something with localMapService.FullExtent.
    };
    MapControl.Layers.Insert(1, localArcGISDynamicMapServiceLayer);


    Re Reference/Schema:

    Sorry - you shouldn't need xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors" - just xmlns:esri="http://schemas.esri.com/arcgis/client/2009" should work.


    Cheers

    Mike
    Last edited by mbranscomb; 08-17-2011 at 04:49 AM.
    ArcGIS Runtime Product Engineer

  12. #12
    James McElroy
    Join Date
    Jul 2011
    Posts
    47
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map Resolutions

    Quote Originally Posted by mbranscomb View Post
    Re Reference/Schema:

    Sorry - you shouldn't need xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors" - just xmlns:esri="http://schemas.esri.com/arcgis/client/2009" should work.
    Hi Mike,

    Without that reference line I get these two errors when attempting to compile.

    Error 142 ''esriBehaviors' is an undeclared prefix. Line 12, position 18.' XML is not valid.
    Error 152 The type 'esriBehaviors:ConstrainExtentBehavior' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

    With the reference line compiles and works...

  13. #13
    Mike Branscomb

    Join Date
    Feb 2010
    Posts
    882
    Points
    359
    Answers Provided
    59


    0

    Default Re: Map Resolutions

    Hi,

    Yes - that correct - you can drop the esriBehaviors prefix and just use the esri prefix/namespace you have already declared.

    Cheers

    Mike
    ArcGIS Runtime Product Engineer

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts