Created
June 18, 2021 13:44
-
-
Save ThomasG77/e7979376a3a870dd0087b54e08e4de9b to your computer and use it in GitHub Desktop.
This file contains 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: 100%; | |
} | |
</style> | |
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/build/ol.js"></script> | |
<script src="https://unpkg.com/jsts@2.3.0/dist/jsts.min.js"></script> | |
<title>OpenLayers example</title> | |
</head> | |
<body> | |
<h2>My Map</h2> | |
<div id="map" class="map"></div> | |
<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({ | |
center: ol.proj.fromLonLat([37.41, 8.82]), | |
zoom: 4 | |
}) | |
}); | |
let polygon = new ol.Feature({ | |
geometry: new ol.geom.Polygon([ | |
[ | |
[-10852646.620625805, 3906819.5017894786], | |
[-10797367.365502242, 3950847.234747086], | |
[-10691456.211645748, 3911711.47159973], | |
[-10687298.044771587, 3848605.062913627], | |
[-10777554.891503, 3804332.7398631293], | |
[-10864387.34630427, 3834907.5511772], | |
[-10852646.620625805, 3906819.5017894786], | |
], | |
]), | |
}); | |
let parser = new jsts.io.OL3Parser(); | |
var jstsGeom = parser.read(polygon.getGeometry()); | |
console.log(jstsGeom.getCoordinates()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment