Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将用户在绘制边界框时限制为特定大小,例如 1024 x 1024。如何在 Open Layers 3 (OL3) 中执行此操作?谢谢!
您可以捕获 drawend 事件并进行相应的过滤。
drawInteraction.on("drawend", function(e) { var feature = e.target.sketchFeature_; // allow or disallow here, not sure how you can do that. });
drawInteraction 是 type ol.interaction.Draw,您的交互几何类型ol.geom.GeometryType将是 Polygon。
ol.interaction.Draw
ol.geom.GeometryType