-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Removal of ol.FeatureOverlay #3758
Conversation
c163fcf
to
f1679ff
Compare
* Sets the layer as overlay on a map. The map will not manage this layer in its | ||
* layers collection, and the layer will be rendered on top. This is useful for | ||
* temporary layers. The standard way to add a layer to a map and have it | ||
* managed by the map is use {@link ol.Map#addLayer}. |
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.
to use ...
a quick comment. As mentioned in #3737, a featureoverlay isn't needed in several of the examples if the select interaction is used instead; this also simplifies those examples. #3757 enables that, so it might be better to merge #3757 and change those examples first. Then they would no longer need to be changed in this PR. ISTM this would be better than changing them here, and then changing them again as and when #3757 is merged. |
*/ | ||
ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { | ||
goog.asserts.assert(goog.isNull(this.featuresCollection_), | ||
'bindFeatuesCollection can only be called once'); |
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.
Typo.
f1679ff
to
ded64fe
Compare
@@ -2471,6 +2472,14 @@ olx.interaction.DrawOptions.prototype.freehandCondition; | |||
|
|||
|
|||
/** | |||
* Wrap the world horizontaly on the sketch overlay. Default is `false`. | |||
* @type {boolean|undefined} |
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.
horizontaly -> horizontally
ded64fe
to
512523f
Compare
I have 2 remaining questions which might be addressed simply by docs:
Since I'm not too familiar with the renderer code, it might be good to have someone more knowledgeable wrt the renderer code look specifically at the rendering changes as well. But I'll leave the call up to you @ahocevar |
512523f
to
827f82a
Compare
Exactly. I added this information to the API docs, and also added a unit test to verify that it works properly.
This is indeed the only breaking change after the removal of |
* When set to `false`, the features will be maintained in an | ||
* {@link ol.Collection}, which can be retrieved through | ||
* {@link ol.source.Vector#getFeaturesCollection}. | ||
* |
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.
I would add that the spatial queries for extent/coordinate only work if set to true
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.
Done.
There's another change that I think should be mentioned in the release notes: if you were using a FO |
ol.layer.Vector can now manage both an RTree and a Collection of features. The new useSpatialIndex option allows to opt out of RTree management, and the new ol.Collection type of the features option allows to opt in for Collection management.
When a layer is configured with a map, it will be added on top of other layers, and not be managed in the map's features collection. The layerState will have an 'unmanaged' flag for such layers. For vector layers, this flag is used to not skip any features.
This also introduces a wrapX option to the Draw, Modify and Select interaction.
025f383
to
9acd652
Compare
I added that to the upgrade notes. You're right, it would be more consistent to use |
The only change to renderer code is the removal of the map replay group, which was only used by Edit: this replayGroup was never exposed to the API, so there is no need to mention it in the upgrade notes. |
I did review it @ahocevar and it looked good to me. |
Thanks @bartvde. Is this good to merge? |
LGTM |
Shouldn't |
Good call @elemoine. I'll create a pull request. |
Quick note: proviously, all the feature overlays attached to a map were equal from the "feature render order" point of view. It's not the case with "umanaged" vector layers. "Unmanaged" vector layers are ordered: the features of the first "unmanaged" vector layer will be drawn below the features of the second "unmanaged" vector layer, etc. |
@elemoine True. I mentioned that in the upgrade notes. |
@elemoine do you know of a use case where this will be problematic? We couldn't think of one. |
The problem is related to components that create vector layers internally (e.g. select interaction). |
WOW |
In our application we have independent components, each using a |
@elemoine As long as your styles don't use var overlay1 = new ol.FeatureOverlay({
style: /* ... */
});
var overlay2 = new ol.FeatureOverlay({
style: /* ... */
});
overlay1.addFeature(feature1);
overlay2.addFeature(feature2); you could now do something like var layer = new ol.source.Vector({
source: new ol.source.Vector(),
style: /* ... */
});
featuresIndex = [{}, {}];
function addFeature(feature, index) {
layer.getSource().addFeature(feature);
featuresIndex[index][goog.getUid(feature)] = feature;
}
function removeFeature(feature, index) {
layer.getSource().removeFeature(feature);
featuresIndex[index][goog.getUid(feature)] = undefined;
}
addFeature(feature1, 0);
addFeature(feature2, 1); In the styleFunction you just check for the feature whether it is in |
As I said, currently, each component has its own |
Maybe I can build an API/abstraction around your "index" idea. Any consumer of that API would first ask the API for an identifier or something. It will then use that identifier in subsequent operations like |
That sounds good @elemoine, much smarter than the app level solution I suggested above. Thanks! |
There's a difference in display behaviour with this change. If you go to http://openlayers.org/en/master/examples/select-features.html and select the hover option, there's an annoying flickering as the cursor passes over the features. This doesn't occur with http://openlayers.org/en/v3.6.0/examples/select-features.html |
This is a bug. Thanks for reporting @probins. I'll create a separate ticket for that. |
With an option to disable the spatial index of
ol.source.Vector
, and amap
option forol.layer.Layer
to render on top of other layers without adding it to the map's layers collection, and a way to manage features of anol.source.Vector
in anol.Collection
, we can get rid ofol.FeatureOverlay
.This simplifies code in many places, and it also improves date line handling, which was not possible with
ol.FeatureOverlay
.Fixes #3704.
Fixes #2386.