Text labels for polygon layers

Last post 4/3/2009 2:30:32 AM by Chris Pietschmann. 2 replies. << Back to Web.Maps.VE v2.0 General
3/20/2009 9:35:09 PM
abgibbs

Text labels for polygon layers

I'm having a REAL hard time getting plain text labels to display property for polygon layers on a map.  I'm drawing polygon layers on the map from a set of Lat/Long points in a database, the layers show up great, just can't seem to get a plain text label to show up right.

I've tried MANY different approaches  . . . the Shape.Title and Shape.Tag properties don't seem to have anything to do with this, neither do the same properties on the ShapeLayer.  The TextOffset and ImageOffset don't seem to do anything, I change them and the text always shows up in the same place.  I tried setting the Icon.CustomText property, but that just displays text along with the default red "pushpin" icon, but I just want plain text.  If I specify no IconImage I just get a broken JPG "icon" on top of the text.  Also, the text appears to wrap on every whitespace character, so the text "TWP 14S RGE 13E" shows up like:

TWP
14S
RGE
13E

The CustomHTML property yeilds better results but not great.  My CustomHTML is simple, just a <font> tag and some text.  The text always shows up as a clickable hyperlink, regardless of what's in the CustomHTML property, which makes the users think it's something they can click on.  I can set the exact centerpoint of the polygon using the Shape.IconAnchor property, but the HTML always shows up slightly offset from the anchor point. There appears to be some hidden "padding" that makes the HTML always high and to the left.  Also, the HTML seems to be left-justified to the anchor point, causing longer text to run off the right side of the polygon, leaving plenty of open space to the left.

I hope I'm just doing this wrong, and you have a simple solution for me -- surely there must be an easy way to display a simple text layer over the center of an object I've drawn on the map!

Thanks,
Aaron

3/30/2009 9:16:58 PM
abgibbs

Re:Text labels for polygon layers

*BUMP*

Please respond

4/3/2009 2:30:32 AM
Chris Pietschmann

Re:Text labels for polygon layers

This should give you the desired results of displaying some text over the map:

shape.CustomIcon = new CustomIconSpecification("<div style='white-space: nowrap;'>TWP 14S RGE 13E</div>");

There really isn't any other better way to display any textual content over top of the map other than using a custom Tile Layer. This method of setting the CustomHTML of the Shapes CustomIconSpecification is really the only option.

One thing to note with when using CustomHTML is that it will not display on the 3D map, the 3D map will display a default red pushpin instead.