Skip to content

Instantly share code, notes, and snippets.

@dbauszus-glx
Created June 15, 2019 16:16
Show Gist options
  • Save dbauszus-glx/625bc6b557c4df940ee04a4bcfb03959 to your computer and use it in GitHub Desktop.
Save dbauszus-glx/625bc6b557c4df940ee04a4bcfb03959 to your computer and use it in GitHub Desktop.
OpenLayers modify geometry interaction and XYZ update via XHR.
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