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
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jsts/2.6.1/jsts.js"></script> |
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
| /* | |
| 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, |
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
| /* | |
| Create Vector Layer | |
| */ | |
| class VectorLayer{ | |
| //Constructor accepts title of vector layer and map object | |
| constructor(title, map) { | |
| this.layer = new ol.layer.Vector({ | |
| title: title, | |
| source: new ol.source.Vector({ | |
| projection:map.getView().projection |
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
| /* | |
| 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, |
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
| /* | |
| Create overlay | |
| */ | |
| class Overlay { | |
| //Contrctor accepts map object, overlay html element, overlay offset, overlay positioning and overlay class | |
| constructor(map, element = document.getElementById("popup"), offset = [0, -15], positioning = 'bottom-center', className = 'ol-tooltip-measure ol-tooltip .ol-tooltip-static') { | |
| this.map = map; | |
| this.overlay = new ol.Overlay({ | |
| element: element, | |
| offset: offset, |
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
| /* | |
| Create and Render map on div with zoom and center | |
| */ | |
| class OLMap { | |
| //Constructor accepts html div id, zoom level and center coordinaes | |
| constructor(map_div, zoom, center) { | |
| this.map = new ol.Map({ | |
| target: map_div, | |
| layers: [ | |
| new ol.layer.Tile({ |
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
| var reader = new jsts.io.WKTReader() | |
| var a = reader.read('POINT (-20 0)') | |
| var b = reader.read('POINT (20 0)') | |
| a = a.buffer(40) | |
| b = b.buffer(40) |
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
| var parser = new jsts.io.OL3Parser(); | |
| var jstsGeom = parser.read('OpenLayers Geometry'); | |
| var buffered = jstsGeom.buffer(40); | |
| var ol_geom = parser.write(buffered) |
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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/css/ol.css" type="text/css"> | |
| <style> | |
| .map { | |
| height: 400px; | |
| width: 400px; | |
| } | |
| </style> |
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
| <body> | |
| <script type="text/javascript"> | |
| var map = new ol.Map({ | |
| target: 'map', | |
| layers: [ | |
| new ol.layer.Tile({ | |
| source: new ol.source.OSM() | |
| }) | |
| ], | |
| view: new ol.View({ |