-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Use DOM instead of map canvas for ol.render.Box #4278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
css/ol.css
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not simply blue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the old style had color: [0, 0, 255, 1]. But you're right, blue would be simpler.
|
Theoretically drag zoom and drag box could have different styles in the past, but not in your new approach. Should we have 2 css classes? |
|
Btw, so happy to see this PR! |
A |
|
Good point. Instead of removing the |
|
@fredj You were faster typing what we both thought at the same time it seems :-) |
|
Makes perfect sense. You and @fredj had the same thought. |
|
:-) |
|
And the box-selection example should be updated: diff --git a/examples/box-selection.js b/examples/box-selection.js
index ded8174..69ed2a9 100644
--- a/examples/box-selection.js
+++ b/examples/box-selection.js
@@ -8,9 +8,6 @@ goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.OSM');
goog.require('ol.source.Vector');
-goog.require('ol.style.Fill');
-goog.require('ol.style.Stroke');
-goog.require('ol.style.Style');
var vectorSource = new ol.source.Vector({
@@ -44,15 +41,7 @@ var selectedFeatures = select.getFeatures();
// a DragBox interaction used to select features by drawing boxes
var dragBox = new ol.interaction.DragBox({
- condition: ol.events.condition.platformModifierKeyOnly,
- style: new ol.style.Style({
- fill: new ol.style.Fill({
- color: [255, 255, 255, 0.4]
- }),
- stroke: new ol.style.Stroke({
- color: [100, 150, 0, 1]
- })
- })
+ condition: ol.events.condition.platformModifierKeyOnly
});
map.addInteraction(dragBox); |
|
Good catch. Will do @fredj. |
|
Other than that this LGTM @ahocevar |
|
Thanks for the great suggestions. I just force-pushed a new version of the pull request. |
|
@fredj, do you want to take another look? In addition to what you suggested, I also gave |
|
LGTM thanks |
Use DOM instead of map canvas for ol.render.Box
|
In ol 3.10 I had the following: How would I implement the above with the latest version? Before it was:
Now it is:
|
|
The v3.11 upgrade notes should more or less answer your question. Define your drag box like this: this.circleInteraction = new ol.interaction.DragBox({
disabled : true,
condition : ol.events.condition.ctrlKeyOnly,
className: 'dragbox-circle'
});And css like this: .dragbox-circle {
border-color: rgba(255,0,0,1);
border-width: 1px;
background-color: rgba(255,0,0,0.3);
}Let us know if anything remains unclear. |
With this change, the drag box we use for
ol.interaction.DragZoomandol.interaction.DragBoxis just a DOM element with CSS styling. This way it works for all renderers.Fixes #1583.