【发布时间】:2019-02-05 18:30:38
【问题描述】:
我在矢量图层上放置自定义标记,但是坐标点从地图的上边缘向下越远,标记形状从该点向上偏移的越多。
我正在使用不同的地图投影 (EPSG:5514),所以那里可能有连接。
我需要知道的是,在我的代码中进行哪些更改以使标记形状在指定坐标上居中。
代码的相关部分:
var stroke = new ol.style.Stroke({color: 'red', width: 1});
var fill = new ol.style.Fill({color: 'red'});
function styleFunction(feature, text) {
feature.displayText = text;
return [
new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 3,
radius: 8,
rotation: 0,
angle: 0
}),
text: new ol.style.Text({
font: '14px Calibri,sans-serif',
fill: new ol.style.Fill({ color: markerTextColor }),
stroke: new ol.style.Stroke({
color: textcolor_DKM, width: 1
}),
textAlign: 'left',
offsetX: 10,
offsetY: -2,
text: text
})
})
];
}
var vectorSource = new ol.source.Vector();
var markerVectorLayer = new ol.layer.Vector({
title: 'Notes',
visible: false,
source: vectorSource
});
var feature = new ol.Feature({
geometry: new ol.geom.Point(
ol.proj.fromLonLat([Number(lon), Number(lat)], 'EPSG:5514')
)
});
feature.setStyle(styleFunction(feature, desc));
vectorSource.addFeature(feature);
如果您需要更多信息,请告诉我。
【问题讨论】: