Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. var features = new ol.Collection();
  2. var featureOverlay = new ol.layer.Vector({
  3. source: new ol.source.Vector({features: features}),
  4. style: new ol.style.Style({
  5. fill: new ol.style.Fill({
  6. color: 'rgba(255, 255, 255, 0.2)'
  7. }),
  8. stroke: new ol.style.Stroke({
  9. color: '#ffcc33',
  10. width: 2
  11. }),
  12. image: new ol.style.Circle({
  13. radius: 7,
  14. fill: new ol.style.Fill({
  15. color: '#ffcc33'
  16. })
  17. })
  18. })
  19. });
  20. featureOverlay.setMap(map);
  21.  
  22. var modify = new ol.interaction.Modify({
  23. features: features,
  24. // the SHIFT key must be pressed to delete vertices, so
  25. // that new vertices can be drawn at the same position
  26. // of existing vertices
  27. deleteCondition: function(event) {
  28. return ol.events.condition.shiftKeyOnly(event) && ol.events.condition.singleClick(event);
  29.  
  30. }
  31. });
  32. map.addInteraction(modify);
  33.  
  34. var draw; // global so we can remove it later
  35. var typeSelect = document.getElementById('type');
  36.  
  37. function addInteraction() {
  38. draw = new ol.interaction.Draw({
  39. features: features,
  40. type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
  41. });
  42. map.addInteraction(draw);
  43. }
  44.  
  45. addInteraction();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement