You are here: > ESRI Forums > arcgis server forums > Thread Replies

ArcGIS Server Forums

ArcGIS API for JavaScript forum

Change Map Label Font , Size , Color ; ArcG...   brenda m Apr 20, 2009
Re: Change Map Label Font , Size , Color ;...   Brett Lord-Castillo Apr 20, 2009
Re: Change Map Label Font , Size , Color ;...   brenda m Apr 27, 2009
Re: Change Map Label Font , Size , Color ;...   Brett Lord-Castillo Apr 27, 2009
Re: Change Map Label Font , Size , Color ;...   Jayant Sai Apr 27, 2009
Re: Change Map Label Font , Size , Color ;...   brenda m Apr 28, 2009
Re: Change Map Label Font , Size , Color ;...   Brett Lord-Castillo Apr 28, 2009
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author brenda m 
Date Apr 20, 2009 
Message Hi,

To enable the user changing the font of labels displayed in the map (by clicking a button),
looking for c# / javascript code to change the map's labels' font (size, color , position).

Thank you,

Brenda 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author Brett Lord-Castillo 
Date Apr 20, 2009 
Message Your best bet for doing this through javascript will be to use an esri.symbol.TextSymbol graphic on top of the object you want to label.
See this sample for an idea of how to do this:
http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssamples/util_label_point.html

With a text symbol, you can define font and color. Font gives you access to size, style, variant, weight, and family.

esri.GeometryService.labelPoints(polygons, callback?, errback?) will give you a label point for polygons.
For points, you can use the points themselves as label points
Not sure what you can do about linear features though. One idea would be to find the midpoint of the line and set a point there. Then set the offset for the text symbol, then use trig to find the rotation of the line and rotate the label to match the line rotation. That works perfectly fine for straight lines, not so well for polylines.
 
  Brett Lord-Castillo
------------------------------
St Louis County Police
Office of Emergency Management
------------------------------
Do you dojo?
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author brenda m 
Date Apr 27, 2009 
Message Hi,

Brett thank you for your answer.

Looking for a code that will change the labels of the actual map such as the streets' name.
(not looking for addition of a new label to be changed)

Thank you,

Brenda 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author Brett Lord-Castillo 
Date Apr 27, 2009 
Message I'm not sure you would really want to do that; it seems kinda dangerous to give a 3rd party the ability to modify your source map documents.

 
  Brett Lord-Castillo
------------------------------
St Louis County Police
Office of Emergency Management
------------------------------
Do you dojo?
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author Jayant Sai 
Date Apr 27, 2009 
Message I guess one way might be to have the street names in different layers of the map document and then control the language by controlling the visibility of the appropriate layer through the JavaScript API. 
  Jayant B Sai
ArcGIS JavaScript API 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author brenda m 
Date Apr 28, 2009 
Message Hi,

Brett and Jayant thank you for your answers.

Brett - you are right , of course:

The labels should be changed locally by the user so only the display will be changed - and not the actual label in the mxd BUT the change should be implemented for the labels that come from the mxd (such as the streets' name).

Jayant - could you please show a code that would do such manipulation as you described ?

Thank you,

Brenda
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Change Map Label Font , Size , Color ; ArcGis Server c# 9.3 
Author Brett Lord-Castillo 
Date Apr 28, 2009 
Message It's not really a code based solution. It's more a service design based solution.

In your MXD, say you have a source layer SDEDBO.Centerlines.
Add the layer to your map twice. The top one, renamed to "StreetLabels1". The bottom one renamed to "Streets".
For StreetLabels1, do all of your labeling as you want for your first iteration of label options, but turn off all of the symbology. For "Streets" do all of your symbology but turn off labeling.
Now, add SDEDBO.Centerlines to the map again, rename it "StreetLabels2"; place it below "StreetLabels1" and above "Streets". Turn off all symbology for that layer and do your labels in your second iteration of label types. Keep doing this for as many iterations of labels as you want. Your users will only be able to select label formats that you have created in the source document in this manner.

Now, when you save the mxd, turn off all of the labels and leave on only "Streets" (or, you can leave on one label layer and that will be the default). On your javascript map, when you add the service, use the default visibility. Create a control of some sort that will be your labeling control (like a radio button or drop down menu). Whenever a labeling option is selected, your will change your visibility so that the "Streets" layer is still on and all the label layers are off except the one that matches the labeling option.
 
  Brett Lord-Castillo
------------------------------
St Louis County Police
Office of Emergency Management
------------------------------
Do you dojo?