Select to view content in your preferred language

Change layer color dinamically

2357
4
02-17-2012 12:14 PM
FernandoFonseca_Pinto_Vieira
New Contributor
I'm newbie at ArcGIS and I have to develop an application that have a layer divided in various polygons from a shapefile. Each polygon has an ID and for each ID I have various attributes in many database tables.

For example, one of this attributes indicates if a polygon is enabled or disabled and this condition can change at time. For example, a polygon is enabled today but tomorrow it can be disabled.

My application will offer a widget that queries the polygons status. If a polygon is enabled, it will be coloured red and if is disabled is coloured green.

My point is: how can I change the colour of a polygon dinamically? Is it easier at server side or at client side?

Currently I'm using Flex. However, if there is a solution available in other technologies I can adopt it.

Thanks!
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
The easist way to do this is in the MXD before your publish your map Service. But this can be done using a renderer as in this sample:

http://help.arcgis.com/en/webapi/flex/samples/01nq/01nq0000000r000000.htm

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
FernandoFonseca_Pinto_Vieira
New Contributor
Thanks, Robert.

I agree that the easist option is do this at the mxd level. I would like to know if there is a way to "republish" a map at the serve side.

What I'm saying is that before I publish the map I color it in accordance to the polygon attribute. However, the point is that after I publish the map, the information that I used to color the map can change (it is stored in a database) and I would like that the server updates my map considering the current database value automatically without I have to publish again the map.

I've read that a way is to update the attribute table at the arcserver. I could do this using pl/sql or webservice.

Do you have an example showing how to do this? Are these the best options?

Thanks in advance.

Fernando
0 Kudos
MarcGraham
Deactivated User
Hi Fernando,

I have a similar situation to you, where I have published a dynamic map service based on a database table that gets updated by an external piece of software.

When the attribute that the symbology is based on changes, the mapservice automatically updates.  As long as the value that is in the field that defines the symbology is valid for that
symbology.

Example:

COLOUR: 1 = RED, 2 = BLUE, 3 = GREEN

Field value is 1 the point is displayed as red.  The value gets updated to 3 and the point changes colour to green.  If the value gets changed to 4, and this isn't defined in the symbology, then the point will display with whatever you have as <all other values>

One useful tip is to set the "autorefresh" attribute in the layer tag in the config.xml for your flex viewer, so when the attribute updates it is automatically changed in your flex app.


Cheers,

Marc
0 Kudos
shay-geo
Frequent Contributor
Hi Fernando,

I have a similar situation. What format does ArcMap wants in the attribute for RGB to color polygon based upon the value.  I found one macro script that does change it dynamically, but i wanted to publish the map to ArcGIS Server and do the dynamic rendering.

I have 3 fields RED, BLUE , GREEN in the shapefile and i have assigned default value 255 0 0 respectively. The color should be RED.

Can someone help on How to achieve it using ArcMap->Layer -> Properties ->Symbology, please? 

I have attached a screenshot of layer properties.




Hi Fernando,

I have a similar situation to you, where I have published a dynamic map service based on a database table that gets updated by an external piece of software.

When the attribute that the symbology is based on changes, the mapservice automatically updates.  As long as the value that is in the field that defines the symbology is valid for that
symbology.

Example:

COLOUR: 1 = RED, 2 = BLUE, 3 = GREEN

Field value is 1 the point is displayed as red.  The value gets updated to 3 and the point changes colour to green.  If the value gets changed to 4, and this isn't defined in the symbology, then the point will display with whatever you have as <all other values>

One useful tip is to set the "autorefresh" attribute in the layer tag in the config.xml for your flex viewer, so when the attribute updates it is automatically changed in your flex app.


Cheers,

Marc
0 Kudos