Skip to content

Instantly share code, notes, and snippets.

@iamgeoknight
Created February 6, 2021 12:01
Show Gist options
  • Save iamgeoknight/3092270385f2b358cce0b21e97bdf743 to your computer and use it in GitHub Desktop.
Save iamgeoknight/3092270385f2b358cce0b21e97bdf743 to your computer and use it in GitHub Desktop.
/*
Create a Draw interaction for LineString and Polygon
*/
class Draw {
//Constructor accepts geometry type, map object and vector layer
constructor(type, map, vector_layer) {
this.map = map;
this.vector_layer = vector_layer;
this.draw = new ol.interaction.Draw({
type: type,
stopClick: true
});
this.draw.on('drawstart', this.onDrawStart);
this.draw.on('drawend', this.onDrawEnd);
this.map.addInteraction(this.draw);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment