Closed oodujebe closed 7 years ago
I am attempting to add the ability to draw features on an OL map using this directive.
My defaults are setup as below:
/* start definition of draw interaction */ var source = new ol.source.Vector({wrapX: false}); var vector = new ol.layer.Vector({ source: source }); var typeSelect = angular.element( document.querySelector( '#type' ) ); var draw; // global so we can remove it later var value = typeSelect.value; if (value !== 'None') { draw = new ol.interaction.Draw({ source: source, type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) }); draw.on('drawstart', function(evt){ source.clear(); $(document).on('keyup', (event) => { if(event.keyCode === 27){ draw.removeLastPoint(); } }); }); draw.on('drawend', (e) => { lastFeature = e.feature; var formatGeojson = new ol.format.GeoJSON(), geojson = formatGeojson.writeGeometry(e.feature.getGeometry(), { rightHanded: true }); $scope.geoJSON = geojson; }) } $scope.typeChange = () => { console.log("typeChange Triggered"); $scope.defaults.interactions = {}; $scope.defaults.interactions.Draw = draw; }; $scope.defaults.interactions.Draw = draw; /* end definition of draw interaction */
However, it appears my Draw interactions are never triggered.
I am attempting to add the ability to draw features on an OL map using this directive.
My defaults are setup as below:
However, it appears my Draw interactions are never triggered.