我正在用OpenLayers 3制作地图,我在PostgreSQL中有坐标(EPSG:3857),地图层是OSM (与图标相同的投影,EPSG:3857)。
问题是,当我增加缩放时,图标消失了.但是如果我减量,那么图标就不会消失。
有人告诉我投影的图标和图层必须是相同的。
有没有人能帮帮我?
我是新来StackOverFlow的
谢谢您抽时间见我,
恩里克。
注意:我的代码是用JSFiddle编写的,可以在这里看到:jsfiddle.net/y3sLksg6/
发布于 2014-11-17 17:03:10
尝试分别为每个标记设置样式,如下面的示例所示,这是jsfiddle的副本:
function AddMarkers() {
//create a bunch of icons and add to source vector
var sizeY = Object.size(coordenadas);
var x = null;
var y = null;
for (var i = 0; i < sizeY; i++) {
x = coordenadas[i].Longitude;
y = coordenadas[i].Latitude;
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([x, y]),
name: 'Marker ' + i,
population: 4000,
rainfall: 500
});
markers[i] = [x, y];
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.75,
src: './img/circleRed.png'
}))
});
// This is new !
iconFeature.setStyle(iconStyle);
vectorSource.addFeature(iconFeature);
}
return vectorLayer;
}https://stackoverflow.com/questions/26903741
复制相似问题