0
我看到它支持非GWT版本,在这里:http://openlayers.org/dev/examples/draw-feature.html(点击“抽奖箱”)如何在gwt-openlayers中绘制矩形?
不过,我不能找到一种方法来访问通过GWT-的OpenLayers此功能。我正在使用SmartGWT,但我不认为这很重要。
我看到它支持非GWT版本,在这里:http://openlayers.org/dev/examples/draw-feature.html(点击“抽奖箱”)如何在gwt-openlayers中绘制矩形?
不过,我不能找到一种方法来访问通过GWT-的OpenLayers此功能。我正在使用SmartGWT,但我不认为这很重要。
这是使用DrawFeature控件使用RegularPolygonHandler完成的。
地图下面的平局圆圈按钮actaully切换按钮。当按下圆圈绘制(实际上是40边的多边形),并且在没有按矩形的时候绘制(其实际上是具有4边的多边形)。 所以当这个例子启动时,试着在地图上绘制,你会看到绘制了矩形。
这是你有兴趣(用于创建箱)代码:
final DrawFeature drawRegularPolygon = new DrawFeature(vectorLayer, new RegularPolygonHandler());
map.addControl(drawRegularPolygon);
drawRegularPolygon.activate();
RegularPolygonHandlerOptions options = new RegularPolygonHandlerOptions();
options.setSides(4);
((RegularPolygonHandler) drawRegularPolygon.getHandler()).setOptions(options);
谢谢!我会试试这个。 – BLuFeNiX
这对我来说是一个很好的开始,但我需要画矩形(不只是方块)。我现在正在研究它,所以请让我知道如果你有更多的代码/建议。谢谢! – BLuFeNiX
用'options.setIrregular(true)完成;'我选择了你的答案。 – BLuFeNiX