Created
June 15, 2019 16:16
-
-
Save dbauszus-glx/625bc6b557c4df940ee04a4bcfb03959 to your computer and use it in GitHub Desktop.
OpenLayers modify geometry interaction and XYZ update via XHR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const modifyInteraction = new ol.interaction.Modify({ | |
source: sourceVector | |
}); | |
modifyInteraction.on('modifyend', e => { | |
const feature = JSON.parse(geoJSON.writeFeature(e.features.getArray()[0])); | |
const xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'https://geolytix.xyz/dev/api/location/edit/geom/update?locale=GB&layer=Scratch&table=dev.scratch&srid=3857&id=' + feature.properties.id); | |
xhr.setRequestHeader('Content-Type', 'application/json'); | |
xhr.onload = e => { | |
if (e.target.status !== 200) return; | |
clearTileCache(); | |
}; | |
xhr.send(JSON.stringify(feature.geometry)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment