examples showing use of ElementLayer.Envelope?

3254
4
08-14-2012 05:56 AM
Labels (1)
MichaelStiso
New Contributor
Hi. Could one of you perhaps point me toward either some documentation on "ElementLayer.Envelope" -- or better yet, some examples of its use -- other than the ArcGIS API description?

I'm having troubles adding an image to the element layer of a map, and unfortunately the API description hasn't helped me...

Thanks in advance.
0 Kudos
4 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

Can you post a sample of your code?


Cheers

Mike
0 Kudos
MichaelStiso
New Contributor
Hi,

Can you post a sample of your code?


Well, at this point, I'm just trying to recreate the ElementLayer sample in the interactive WPF SDK sample set (also here: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ElementLayer). Here is the code I have in the LayoutRoot grid:


           [INDENT]<Grid x:Name="LayoutRoot">

  [INDENT]<esri:Map x:Name="myMap" Background="White" Margin="8" WrapAround="True">

   [INDENT]<esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>

   <esri:GraphicsLayer IsHitTestVisible="True" ID="myGraphicsLayer" MapTip="{x:Null}" Renderer="{x:Null}" RendererTakesPrecedence="True"/>

   <esri:ElementLayer ID="myElementLayer">
    [INDENT]<esri:ElementLayer.Children>


                    [INDENT]<!--Arrow pointing at Copenhagen from the right-->
                    <TextBlock Text="&lt;=" HorizontalAlignment="Right"
      FontSize="15" Foreground="Blue" FontWeight="Bold"
      esri:ElementLayer.Envelope="12.5698,55.6765,12.5698,55.6765" />

                    <!-- Red box - No size specified. Envelope guides the size -->
                    <Rectangle Fill="Red" esri:ElementLayer.Envelope="0,0,10,10" />

                    <!--Editable textbox-->
                    <TextBox Width="100" Height="20" esri:ElementLayer.Envelope="40,0,40,0"
       Text="Editable text" HorizontalAlignment="Right" VerticalAlignment="Bottom" />[/INDENT]


               </esri:ElementLayer.Children>[/INDENT]
   </esri:ElementLayer>[/INDENT]

  </esri:Map>[/INDENT]
</Grid>[/INDENT]


When I use this code, the TextBlock and TextBox both appear in the center of the map, and the rectangle doesn't appear at all. I've tried playing around with the Envelope values, but the changes either do nothing or make the element disappear (except for the rectangle, which never appears).

I know this is probably something pretty easy that I'm missing because I'm new to WPF and such, which is why I was hoping to find some examples (outside what I have found on this site) to study.

Thanks for any help.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

I think there's nothing wrong with your code - the only issue is the coordinates of the Envelope you're specifying. You'll find the red box is there but it's just super small.

The Envelope values are spatial coordinates - and in the case of the example online which uses "0,0,10,10" those are in WGS84 so the X and Y values could be -180 / 180 and -90 / 90.

However your map does not explicitly define an extent or spatial reference and therefore it's taken from the first layer which is the world streetmap in the Web Mercator Auxiliary Sphere coordinate system - valid values for X and Y are therefore -20000000 / 20000000 - hence why the red box is very, very small.


Cheers

Mike
0 Kudos
MichaelStiso
New Contributor
Hi,

I think there's nothing wrong with your code - the only issue is the coordinates of the Envelope you're specifying. You'll find the red box is there but it's just super small.



Yes, you're right, it was there. I had to do a little learning about coordinate systems to adjust it, but I think I'm on track now for the time being. Thanks for the help.
0 Kudos