Select to view content in your preferred language

TextSymbol setAngle() doesn't rotate the text

3503
8
10-03-2013 03:46 PM
PanK
by
Emerging Contributor
I'm on JS API 3.7. I tried the new LabelLayer feature. Everything else works fine but I cannot rotate the text. I thought setAngle() in TextSymbol will do that. Turns out nothing get rotated, any idea?

Here's how I use it.

var parcelsColor = new dojo.Color("#333");
var parcelsTextSymbol = new esri.symbols.TextSymbol().setColor(parcelsColor).setAngle(200);
var parcelsLabelRenderer = new esri.renderers.SimpleRenderer(parcelsTextSymbol);
var parcelsLabel = new esri.layers.LabelLayer({ id: "parcelsLabel" });
parcelsLabel.addFeatureLayer(parcelLayer, parcelsLabelRenderer, "${" + labelField + "}");
map.addLayer(parcelsLabel);



Thanks!
0 Kudos
8 Replies
ManishkumarPatel
Deactivated User
I'm on JS API 3.7. I tried the new LabelLayer feature. Everything else works fine but I cannot rotate the text. I thought setAngle() in TextSymbol will do that. Turns out nothing get rotated, any idea?

Here's how I use it.

var parcelsColor = new dojo.Color("#333");
var parcelsTextSymbol = new esri.symbols.TextSymbol().setColor(parcelsColor).setAngle(200);
var parcelsLabelRenderer = new esri.renderers.SimpleRenderer(parcelsTextSymbol);
var parcelsLabel = new esri.layers.LabelLayer({ id: "parcelsLabel" });
parcelsLabel.addFeatureLayer(parcelLayer, parcelsLabelRenderer, "${" + labelField + "}");
map.addLayer(parcelsLabel);



Thanks!


Hi,

I found in the API documentation that the label rotation is applicable to Line feature only.Parameter: labelOptions

[TABLE="class: grid"]OptionAvailable ValuesDefault ValueApplicable Feature TypelabelRotationtrue | false trueLine
[/TABLE]



{

  lineLabelPosition: "OnLine",
  labelRotation: false
}Although when I tried to use the .setAngle and rotate using the labelRotation:true it didnt work. The other options seems to be working like lineLabelPosition:"Below"

Check this fiddle for reference: http://jsfiddle.net/patelmanya/WAVYL/10/

Since this is in BETA I think this might be a bug and esri might fix this with the final/next release.

Hope this helps. If you do find any workaround please post it.

Happy weekend!!!

Regards,
Manish Patel
0 Kudos
PanK
by
Emerging Contributor
Hi,

I found in the API documentation that the label rotation is applicable to Line feature only.Parameter: labelOptions

[TABLE="class: grid"]OptionAvailable ValuesDefault ValueApplicable Feature TypelabelRotationtrue | false trueLine
[/TABLE]



{

  lineLabelPosition: "OnLine",
  labelRotation: false
}Although when I tried to use the .setAngle and rotate using the labelRotation:true it didnt work. The other options seems to be working like lineLabelPosition:"Below"

Check this fiddle for reference: http://jsfiddle.net/patelmanya/WAVYL/10/

Since this is in BETA I think this might be a bug and esri might fix this with the final/next release.

Hope this helps. If you do find any workaround please post it.

Happy weekend!!!

Regards,
Manish Patel



Thanks for the reply, but this doesn't work for me. The only thing I can make the label rotate is to set rotate attribute in  <text> itself. It's such a hacky way. I think our best bet is to wait until BETA is over. 🙂
0 Kudos
derekswingley1
Deactivated User
I'd like to clarify:  the request is to have the label layer use the angle set on text symbols? This currently isn't possible with the label layer (as you found out, text symbol rotation is ignored). This complicates things in terms of finding overlapping labels but I'll see what we can do.
0 Kudos
PanK
by
Emerging Contributor
I'd like to clarify:  the request is to have the label layer use the angle set on text symbols? This currently isn't possible with the label layer (as you found out, text symbol rotation is ignored). This complicates things in terms of finding overlapping labels but I'll see what we can do.



Yes. I would like to set the angle on the text symbols. As of overlapping, they currently overlap anyways. That's why I have to rotate them. I could have gone the other way to fix in my situation. However, I just follow the API (https://developers.arcgis.com/en/javascript/jsapi/textsymbol.html), TextSymbol got "angle" property and "setAngle()" method. If you're saying this couldn't be done, and I would suggest to remove it from the API docs, since it may confuse other users.
0 Kudos
derekswingley1
Deactivated User
Yes. I would like to set the angle on the text symbols.


Thanks for confirming.


As of overlapping, they currently overlap anyways. That's why I have to rotate them. I could have gone the other way to fix in my situation.


That shouldn't be happening. Can you provide a repro case that shows using the label layer where it places overlapping labels?
0 Kudos
PanK
by
Emerging Contributor
That shouldn't be happening. Can you provide a repro case that shows using the label layer where it places overlapping labels?


Here's how my map looks like. I mean, it makes sense that they overlap, because the label is way too long to fit in small area. Hence, providing the user an ability to rotate the labels, when they want to.

[ATTACH=CONFIG]28143[/ATTACH]


Thanks!
0 Kudos
BorisLutskovsky
Emerging Contributor
Looks like this has been fixed in 3.9.
0 Kudos
derekswingley1
Deactivated User
Looks like this has been fixed in 3.9.


It was fixed in 3.8, so it's fixed in 3.9 too 🙂
0 Kudos