Select to view content in your preferred language

Displaying a static graphic

944
4
Jump to solution
01-24-2013 02:44 PM
CharlesTilly
Deactivated User
I would like to display a box on the map that remains stationary as the user pans around.  The box represents different print templates, and the user will often pan the map a little to get their desired extent within their desired template.

The problem is that I can't figure out how to keep the box stationary.  By creating a rectangle within a graphics layer, the rectangle initially appears on the map in the center as expected.  However, if I pan the map the rectangle goes with it, which is not the desired effect.  I would like for the rectangle to stay in the center of the map the whole time. 

I've tried using the clear() method as well as deleting the graphic layer and then recreating it, then re-adding the new graphic layer to the map with the new rectangle.  The result is always the same.  It appears as though the parameters for the viewable map area get set at each scale and those values are fixed until the user changes scale by zoom event.

Here is an example of how I am using the graphics layer.  This code snippet is in my PAN_END event handler and notice that although I have the x & y value set to 0,0 the rectangle actually appears at a location relative to the last extent NOT THE CURRENT EXTENT.  UGH!  Anyone have any experience with doing something similar or insight into how to pull this off?

protected function map_panEndHandler(event:Event):void
{
[INDENT]
if (this.mapGraphicsLyr){
[INDENT]mapGraphicsLyr.clear();
_map.removeLayer(mapGraphicsLyr);
mapGraphicsLyr=null;[/INDENT]}
mapGraphicsLyr = new GraphicsLayer();
mapGraphicsLyr.graphics.lineStyle(3,0x00FF00);
mapGraphicsLyr.graphics.drawRect(0, 0, 500, 500); //x, y, width, height
_map.addLayer(mapGraphicsLyr,-1);
[/INDENT]
}

Thanks for reading.

Chuck
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
CharlesTilly
Deactivated User
Robert,

Thank you!

That is in fact what I was looking for.  Follow up question though. While scouring the documentation looking for the right method or object that would do what I needed, I naturally kept gravitating to staticLayer but the [read only] attribute led me to believe it was read only.  Furthermore the description makes it seem like it is for adding already existing graphics like legends to the map.  What is the disconnect here?  Why does the documentation say it is read only when in fact you can add additional graphics layers to it?  I can't find anything in the documentation that discusses the use of the Map.staticLayer.addElement.

Thank you again!

Chuck
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Chuck,

   There are several undocumented areas of the API because the team does not really intend for people to use them (does not mean you can't though). It is called static because that layer does not move when the map is paned. It is for things like the scalebar, esri logo, and the new map attribution.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow these steps as shown in the below graphic:

0 Kudos
YannCabon
Esri Contributor
Hi Chuck,

The staticLayer is marked as [read-only] as you cannot change the actual reference to it.
But this doesn't mean that its properties/functions are not accessible.
Indeed the API use the static layer to add components to it like the logos, legend, etc.

Feel free to use it to add your own components in it.

Yann
0 Kudos