我有一个 openlayers 地图,其中添加了作为几何矢量点的标记。在样式选项中,我为每个设置了一个大小。但是,问题是,如果我放大或缩小,它们都会变成相同的大小,直到我再次加载整个页面。换句话说,一旦我放大或缩小,它们都是一样的。
var layer_style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
var style = OpenLayers.Util.extend({}, layer_style);
var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
map.addLayers([terrain, road, satellite, hybrid, pointLayer]);
var lonlat = new OpenLayers.LonLat(0, 140);
lonlat.transform(proj, map.getProjectionObject());
map.setCenter(lonlat, 2);
var point = new OpenLayers.Geometry.Point(-40, -40);
point = point.transform(proj, map.getProjectionObject());
style.pointRadius = 10;
var pointFeature = new OpenLayers.Feature.Vector(point, null, style);
pointLayer.addFeatures([pointFeature]);
var point = new OpenLayers.Geometry.Point(-40, -40);
point = point.transform(proj, map.getProjectionObject());
style.pointRadius = 40;
var pointFeature = new OpenLayers.Feature.Vector(point, null, style);
pointLayer.addFeatures([pointFeature]);
当我加载这个时,我得到两个标记,一个大小为 10,另一个大小为 40。但是当我放大或缩小时,它们都变成相同的大小。