Skip to content

Commit

Permalink
Merge pull request #627 from openlayers/fix_missing_source_issue
Browse files Browse the repository at this point in the history
Fix missing source issue
  • Loading branch information
gberaudo authored Aug 7, 2018
2 parents 29a5a9c + 4bb6ee7 commit 23d8141
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Port to OpenLayers 5.1.3.
* Switch to Cesium Ion (old terrain service is deprecated and will be stopped in September).
* Add an old fashioned example (currently requires a custom build of OpenLayers).
* Fix synchronization issue when a layer has no initial source.

# v 2.1 - 2018-07-13

Expand Down
2 changes: 1 addition & 1 deletion examples/vectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ const cartographicRectangle2 = new olFeature({
cartographicRectangle2.setStyle(cartographicRectangleStyle);

const vectorLayer = new olLayerVector({
source: vectorSource,
style: styleFunction
});
setTimeout(() => vectorLayer.setSource(vectorSource), 2000);

const vectorSource2 = new olSourceVector({
features: [iconFeature, textFeature, cervinFeature, ...modelFeatures, cartographicRectangle,
Expand Down
4 changes: 4 additions & 0 deletions src/olcs/VectorSynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class VectorSynchronizer extends olcsAbstractSynchronizer {
source = source.getSource();
}

if (!source) {
return null;
}

googAsserts.assertInstanceof(source, olSourceVector);
googAsserts.assert(this.view);

Expand Down

0 comments on commit 23d8141

Please sign in to comment.