ThinkGeo.com    |     Documentation    |     Premium Support

FileGeoDatabase Layer - Label Rotation

I had asked this question in the WebAPI Support but have since switched back to MVC.

Is there a way to rotate a label on an individual basis. I have an annotations layer with a column of doubles dedicated for the angle (0-359). These labels go along the outer lines of the polygon and need to be angled appropriately. Also there is a column for font size which I will need to do similar to the angles. Any help would be appreciated.

Emil had suggested some links to a Services Edition Sample, but the override doesn’t seem to work the same way in MVC.

Hi Chad,

Could you please let us know the detail problem you met?

It looks Emil provide the sample: http://wiki.thinkgeo.com/wiki/source_code_serviceseditionsample_labelingbasedoncolumns_cs_090807.zip

Which contains the customTextStyle inherit from our textStyle, that’s contained in our core code, which is the same both in MVC edition and WebAPI edition.

So I want to double check the detail information and we can suggest you how to solve it.

Regards,

Don

Hi Chad,

As below is a sample I created for you, it works well. Please try it and let me know whether that works.

8588.zip (1.9 MB)

Regards,

Don

Your sample is exactly what we need I believe, but with my map the layer breaks when trying to run the below code line. It fails on the first feature.

DrawCore ->
ScreenPointF textScreenPoint = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, feature, canvas.Width, canvas.Height);

a typical value is as follows:
canvas.CurrentWorldExtent = -10780572.503912,4724900.1173184,-10780070.885932,4724630.7962368
feature = (polygon feature)
canvas.Width = 1680.0
canvas.Height = 902.0

The polygon feature looks like it is coming across correctly with correct column values (5 column values - Text, Size, Angle, Color, Font). Just for whatever reason the ScreenPointF will fail. The values are coming from a filegeodatabase not a shapefile.

Ok, so I’ve gotten all of the values to rotate correctly but they will only appear if I put in values for the ScreenPointF. Such as changing the below line of code:

ScreenPointF textScreenPoint = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, feature, canvas.Width, canvas.Height);

to this:

ScreenPointF textScreenPoint = new ScreenPointF(500, 500);

Changing the line is the only way I am able to view the layer, otherwise it will crash the layer. Obviously this isn’t helpful to our map because all of the values overlap each other and are not readable. So something is going on with either the extent or the extenthelper.

By the way I’m running MapSuite 9.0.0.180. And the MapUnit is GeographyUnit.Meter.

Hi Chad,

I think we need a sample with data which can reproduce your problem, could you please upload one here so our developer can work based on that?

And your dll is so early, please try our latest v9 or v10 before that.

Regards,

Don

I was able to get it without changing versions by changing the code to:

ScreenPointF textScreenPoint = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, feature.GetBoundingBox().GetCenterPoint().X, feature.GetBoundingBox().GetCenterPoint().Y, canvas.Width, canvas.Height);

Thanks

Hi Chad,

I am glad to hear you solve that and thanks for your share.

Regards,

Don