[OpenLayers-Users] Aligning label below Vector feature?

And. asufsc at gmail.com
Fri Oct 16 12:56:58 EDT 2009


"I even tried
my hand at hacking OpenLayers.js directly to move _all_ labels 20px or
so down, but couldn't find the right spot.  Any ideas?" 

You can try it:
        var offsetX = style.labelOffsetX ? style.labelOffsetX : 0;
        var offsetY = style.labelOffsetY ? style.labelOffsetY : 0;
        
        var x = (location.x / resolution + this.left + offsetX);
        var y = (location.y / resolution - this.top + offsetY);

In the renderer class SVG.js. It works with SVG (setting the attributes
"labelOffsetX" and "labelOffsetY" in the style of the feature).
But you'll have to do something like it in the class VML.js to work with VML
too.

Good luck.

Regards,
Andre.


Jani Patokallio wrote:
> 
> Greetings,
> 
> The new (for me!) text label feature for Vectors rocks, but is there any
> way to align the label *below* the associated feature?
> 
> To be specific, I'm using externalGraphics to create icons, and I'd like
> to center graphic at the point of interest and put the label below it. 
> It would be trivial to put the text at the exact location (align: "cm")
> and use graphicYOffset to move the icon out of the way, but when zoomed
> out the icon would then be pointing at the wrong place, which is not
> acceptable.
> 
> As a semi-workaround, I managed to shift the label to the lower right
> corner of the icon by using "align: lt" and padding the label with
> "\xA0\xA0" (Unicode non-breaking space), but this doesn't properly
> account for the width of the icon.  Moving the label to be below the
> image with \r, \n or \x-equivalents thereof doesn't work.  I even tried
> my hand at hacking OpenLayers.js directly to move _all_ labels 20px or
> so down, but couldn't find the right spot.  Any ideas?
> 
> Cheers,
> -jani
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Aligning-label-below-Vector-feature-tp3835113p3836752.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list