[英]OpenLayers 2 set labels on a specific coordinates
Hi im triying to print a group of labels on a map (OSM), the problem is that i don't know how to set those on a specific coordinates, the labels appear on the map but it is like i dont set the coordinates i attach the source. 您好,我想在地图(OSM)上打印一组标签,问题是我不知道如何在特定坐标上设置标签,标签出现在地图上,但是就像我没有设置坐标i附加源。
var vectorLayer = new OpenLayers.Layer.Vector("Etiquetas", {
styleMap: new OpenLayers.StyleMap({'default':{
strokeColor: "",
strokeOpacity: 1,
strokeWidth: 3,
fillColor: "",
fillOpacity: 0,
pointRadius: 6,
pointerEvents: "visiblePainted",
label : "${etiqueta}",
fontColor: "${favColor}",
fontSize: "10px",
fontFamily: "Courier New, monospace",
fontWeight: "bold",
labelOutlineColor: "white",
labelOutlineWidth: 3
}},{ visibility: true, displayInLayerSwitcher: true })
});
var pointFeature;
var point;
for (i = 0; i < elementos.length; i++) {
var datos_ubicacion = elementos[i].split("|");
if (datos_ubicacion[0] != "") {
var long = parseFloat(datos_ubicacion[7]);
var lati = parseFloat(datos_ubicacion[6]);
var coordenada = new OpenLayers.LonLat(long,
lati).transform(new OpenLayers.Projection('EPSG:4326'),
map.getProjectionObject());
point = new OpenLayers.Geometry.Point(lati,long);
pointFeature = new OpenLayers.Feature.Vector(point);
pointFeature.attributes=
{
etiqueta: datos_ubicacion[1],
favColor: 'black'
};
}
}
map.addLayer(vectorLayer);
}
vectorLayer.addFeatures([pointFeature]);
I solved, just need to make a convertion of coordinates 我解决了,只需要进行坐标转换
var point = new OpenLayers.Geometry.Point(long,lati);
point = point.transform(new OpenLayers.Projection('EPSG:4326'),
map.getProjectionObject());
pointFeature = new OpenLayers.Feature.Vector(point);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.