Skip to content

Instantly share code, notes, and snippets.

@acanimal
Created August 2, 2014 16:09
Show Gist options
  • Save acanimal/d7a337bfe2caaf003109 to your computer and use it in GitHub Desktop.
Save acanimal/d7a337bfe2caaf003109 to your computer and use it in GitHub Desktop.
Test geometries OL3
<!doctype html>
<html lang="en">
<head>
<title>The Book of OpenLayers3 - Theory and Practice</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://ol3js.org/en/master/css/ol.css">
<!-- Bootstrap -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/3.0.2/yeti/bootstrap.min.css">
<!-- OpenLayers -->
<link rel="stylesheet" href="http://ol3js.org/en/master/css/ol.css">
</head>
<body>
<div class="container-fluid">
<h1>Geometries</h1>
<p>Open the console to see results !!!</p>
</div>
<script src="http://ol3js.org/en/master/build/ol.js"></script>
<script>
var point = new ol.geom.Point([10,30]);
console.log(
"point coordinates", point.getCoordinates(),
"extent", point.getExtent(),
"layout", point.getLayout());
var linearRing = new ol.geom.LinearRing([ [0,0], [10,0], [10,10], [0,10] ]);
console.log(
"linearRing coordinates", linearRing.getCoordinates(),
"extent", linearRing.getExtent(),
"layout", linearRing.getLayout(),
"are", linearRing.getArea());
var circle = new ol.geom.Circle([4,5], 10);
console.log(
"circle center", circle.getCenter(),
"radius", circle.getRadius(),
"extent", circle.getExtent(),
"layout", circle.getLayout());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment