Open Layers doesn't show the label in the given lat, lon

67 Views Asked by At

I try to add a label to a point in open layers. The label is seen but it's somewhere near (0,0) point, not in the given lat, lon point.

var point = new OpenLayers.Geometry.Point(lon,lat);
var label_feature = new OpenLayers.Feature.Vector(point);
    label_feature.attributes = {
        myLabel: "my label"
    };

    vector_layer.addFeatures([label_feature]);

Here's the offset values in vector style

labelXOffset: "0",
labelYOffset: "12",

and I get the renderer

var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
                        renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

OK, I found a solution:

All you need is to transform point with a projection:

var projection = new OpenLayers.Projection("EPSG:4326");
point = point.transform(projection, map.getProjectionObject());