Skip to content

Commit

Permalink
Fix value update
Browse files Browse the repository at this point in the history
  • Loading branch information
llienher committed Jul 22, 2019
1 parent ccf22c6 commit 2c3c5a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 8 additions & 2 deletions contribs/gmf/src/editing/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ const exports = function($http, $q, $rootScope, $injector, $timeout, gmfThemes,
*/
this.ogcServers_ = null;

/**
* @type {ol.source.Vector | undefined}
* @private
*/
this.ngeoSnappingSource_ = this.injector_.get('ngeoSnappingSource') || undefined;

};


Expand Down Expand Up @@ -574,11 +580,11 @@ exports.prototype.handleMapMoveEnd_ = function() {
* @private
*/
exports.prototype.refreshSnappingSource_ = function() {
this.injector_.get('ngeoSnappingSource').clear();
this.ngeoSnappingSource_.clear();
for (const uid in this.cache_) {
const item = this.cache_[+uid];
if (item.active) {
this.injector_.get('ngeoSnappingSource').addFeatures(item.features);
this.ngeoSnappingSource_.addFeatures(item.features.getArray());
}
}
};
Expand Down
10 changes: 4 additions & 6 deletions src/interaction/MeasureLength.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ exports.prototype.createDrawInteraction = function(style) {
* @return {LineString} Geometry.
*/
exports.prototype.linestringGeometryFunction = function(coordinates, opt_geometry) {
if (modifierPressed && this.tolerance !== undefined) {
if (modifierPressed && this.tolerance !== undefined && this.source !== undefined) {
const viewRotation = this.getMap().getView().getRotation();
const angle = Math.PI / 4;
const from = coordinates[coordinates.length - 2];
Expand All @@ -105,11 +105,9 @@ exports.prototype.linestringGeometryFunction = function(coordinates, opt_geometr
const delta = this.getMap().getView().getResolution() * this.tolerance;
const bbox = [to[0] - delta, to[1] - delta, to[0] + delta, to[1] + delta];

const layers = this.getMap().getLayers().getArray();
const vectorLayer = layers.find(layer => layer.type === 'VECTOR');
if (vectorLayer !== undefined) {
const layerSource = vectorLayer.getSource();
const featuresInExtent = layerSource.getFeaturesInExtent(bbox);
const layerSource = this.source;
const featuresInExtent = layerSource.getFeaturesInExtent(bbox);
if (featuresInExtent.length > 0) {
featuresInExtent.forEach((feature) => {
feature.getGeometry().forEachSegment((point1, point2) => {
// Line points are: from A to M (to B that we need to find)
Expand Down

0 comments on commit 2c3c5a6

Please sign in to comment.