Select to view content in your preferred language

change fill color of esri.toolbars.Draw.EXTENT

878
3
04-27-2010 06:12 AM
todddoerr
Occasional Contributor
Hello,
I want to change the fill color of the esri.toolbars.Draw.EXTENT box on the fly while it is being drawn on the map to show the user has reached some limit.  How do I do that?  Through Firebug I've found the node that contains the fill information and it looks like this:
<g id="map_graphics_layer" style="display: block;" transform="matrix(1, 0, 0, 1, 0, 0)"><rect fill="rgb(0, 0, 0)" fill-opacity="0.25" stroke="rgb(255, 0, 0)" stroke-opacity="1" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" x="522" y="177" width="26" height="19" stroke-dasharray="none" dojoGfxStrokeStyle="solid" fill-rule="evenodd"/></g>

Programmatically, I'm able to  get that node using var extentBox = dojo.byId("map_graphics_layer").  And I can see the rect element but how do I edit the fill attribute?

Any help would be appreciated.
Todd
0 Kudos
3 Replies
todddoerr
Occasional Contributor
To anybody that is interested, I figured out how to change the fill color.  Here's my code.
// query for the rect element - not map_graphics_layer
var extentBoxElement = dojo.query('rect')[0];

// set fill to red
extentBox.setAttribute('fill',"rgb(255, 0, 0)");

This only works in FF though.  IE generates 'Error: Member not found' during setAttribute.  Inspection of the element in Firebug Lite shows there is no fill attribute and it's not obvious what attribute is being used for fill.
If anybody knows how to change the fill in IE it would be greatly appreciated.

Thanks.

Hello,
I want to change the fill color of the esri.toolbars.Draw.EXTENT box on the fly while it is being drawn on the map to show the user has reached some limit.  How do I do that?  Through Firebug I've found the node that contains the fill information and it looks like this:
<g id="map_graphics_layer" style="display: block;" transform="matrix(1, 0, 0, 1, 0, 0)"><rect fill="rgb(0, 0, 0)" fill-opacity="0.25" stroke="rgb(255, 0, 0)" stroke-opacity="1" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" x="522" y="177" width="26" height="19" stroke-dasharray="none" dojoGfxStrokeStyle="solid" fill-rule="evenodd"/></g>

Programmatically, I'm able to  get that node using var extentBox = dojo.byId("map_graphics_layer").  And I can see the rect element but how do I edit the fill attribute?

Any help would be appreciated.
Todd
0 Kudos
DerekSwingley
Regular Contributor
I'm kinda late but how about esri.toolbars.Draw.setFillSymbol() when you cross some threshold?

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/draw.htm#setFillSymbol
0 Kudos
todddoerr
Occasional Contributor
Thank you.  That is a much better solution.  I just needed to read and understand the JS API better.
Thanks again.

I'm kinda late but how about esri.toolbars.Draw.setFillSymbol() when you cross some threshold?

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/draw.htm#setFillSymbol
0 Kudos