[英]OpenLayers Point Geometry never resizes
我的网站包含一个OpenStreetMaps。 我使用OpenLayers将Geometry.Point放置在城市顶部。
一个按钮允许用户调整此点的大小,但是它从未调整大小,我不明白为什么。
这是我的代码:
var button = document.myform.btClear,
map = new OpenLayers.Map("map_element", {}),
osm = new OpenLayers.Layer.OSM(),
vectors = new OpenLayers.Layer.Vector(),
fromProjection = new OpenLayers.Projection("EPSG:4326"),
toProjection = new OpenLayers.Projection("EPSG:900913"),
position = new OpenLayers.LonLat(6.9673223,50.9572449).transform(fromProjection, toProjection),
point = new OpenLayers.Geometry.Point(6.9673223,50.9572449).transform(fromProjection, toProjection);
map.addLayer(osm);
map.addLayer(vectors);
map.setCenter(position, 5);
pointFeature = new OpenLayers.Feature.Vector(point);
vectors.addFeatures([pointFeature]);
button.onclick = function() {
vectors.features[0].geometry.resize(1.5, point);
vectors.redraw();
};
你能帮我弄清楚吗?
谢谢
我与OpenLayers的合作不多,所以在这里花点盐吃。 我正在看这个示例( http://dev.openlayers.org/releases/OpenLayers-2.12/examples/resize-features.html ),我认为调整几何尺寸的功能与您的预期有所不同。 我认为您真正想要改变的是风格。 我已经在http://jsfiddle.net/MLundin617/39KE5/2/上修改了您的小提琴作为示例。 这还不完整,因为单击也可以改变该点的颜色,但我相信它离您要寻找的更近。
这是主要的更改:
radius = 2
button.onclick = function() {
radius = radius * 1.5
vectors.features[0].style = {pointRadius: radius}
vectors.redraw();
};
(此外,在您的jsFiddle中,您引用的表单元素不正确,因此无法定义onclick。)
让我知道是否有帮助。 很好奇也看到其他答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.