I am having some issues in OpenLayers 5.3.0. The context is that I'm using Sharepoint lists as a backend to save feature data and OpenLayers is running in a Vue.js container. Everything works as expected:
The geoJSON feature strings are pulled in from SharePoint and aggregated into a feature collection. As I load each feature I add custom properties - most importantly the ItemID from the SharePoint list. The features load on the map. I can draw new features and save all of them.
If at any point I get all features with code like
allFeatures = self.drawLayer.getSource().getFeatures();
the features will contain the additional properties I have added.
The problem I am having is that when use a select interaction the selected feature comes back differently if it is a point or if it is a polygon - using for example:
self.drawClickSelect.on('select', function(e) {
self.selectedFeatures = e.selected;
console.log(self.selectedFeatures);
});
The feature comes back with the added properties if it is a polygon, but if it's a point the properties itemID and modified do not exist.
Examples Polygon returns:
e {…}
dispatching_: (...)
disposed_: (...)
geometryChangeKey_: (...)
geometryName_: (...)
id_: (...)
listeners_: (...)
ol_lm: (...)
ol_uid: (...)
pendingRemovals_: (...)
revision_: (...)
styleFunction_: (...)
style_: (...)
**values_: Object
geometry: e
itemID: 13
modified: false**
Point returns:
0: e
dispatching_: (...)
disposed_: (...)
geometryChangeKey_: (...)
geometryName_: (...)
id_: (...)
listeners_: (...)
ol_lm: (...)
ol_uid: (...)
pendingRemovals_: (...)
revision_: (...)
styleFunction_: (...)
style_: (...)
**values_: Object
geometry: (...)**
self.drawLayer.getSource().getFeatures()
returns: (Note that the properties I'm interested are present for each feature.)
"{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-9148122.009657301,4148932.8076870437],[-9148001.336280514,4149124.4626323017],[-9148174.732892036,4149232.323163778],[-9148225.35521765,4149153.4073993675],[-9148302.20055545,4149200.6003566994],[-9148335.00415841,4149155.742857091],[-9148551.727115743,4149293.291205446],[-9148561.789387284,4149278.5208011325],[-9148673.828665541,4149349.3877884443],[-9148735.371373663,4149252.6485635266],[-9148560.38595463,4149144.0397318634],[-9148567.23964962,4149133.2237431305],[-9148549.761260215,4149122.8749220027],[-9148544.360359373,4149132.5307491873],[-9148449.959080853,4149071.7602422866],[-9148456.755445173,4149061.5738832294],[-9148442.091697177,4149052.313675927],[-9148435.004098615,4149063.0075244764],[-9148340.775473515,4149000.2413342204],[-9148324.546920547,4149028.1325729615],[-9148199.787204698,4148944.980097804],[-9148184.701774493,4148972.1811943417],[-9148122.009657301,4148932.8076870437]]]},"properties":{"itemID":12,"modified":false}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-9149230.727863472,4149974.6889362033],[-9148917.825374642,4149776.7721247915],[-9149008.484043097,4149633.442597651],[-9149321.386531925,4149831.359409064],[-9149230.727863472,4149974.6889362033]]]},"properties":{"itemID":13,"modified":false}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-9149507.058888558,4150498.531335066]},"properties":{"itemID":21,"modified":false}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-9149383.916618763,4150420.6414931556]},"properties":{"itemID":22,"modified":false}}]}"
Is there some known issue with points that would make them different than polygons with regard to properties?
value_
field but should be accessed using.getProperties()
(methods not documented in the API are usually not available when using minified builds) What do you get when loggingself.selectedFeatures[0].getProperties()
self.selectedFeatures = self.map.forEachFeatureAtPixel(e.mapBrowserEvent.pixel, function(feature) { return feature; });
returns exactly what I'm after.