Skip to content

Commit

Permalink
Fix ol3 to ol5 breaking changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpmcmlxxvi committed Jun 15, 2019
1 parent d728316 commit 42ee3f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/js/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ const olexp = {
// --------------------------------------------------
const extent = this.getExtent();
if (extent !== null) {
view.fit(extent, map.getSize());
view.fit(extent);
return;
}

Expand Down
10 changes: 2 additions & 8 deletions src/js/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ const olexp = {
*/
this.source = null;

/**
* WGS84 ellipsoid on which to perform measurements
* @type {ol.Sphere}
*/
this.sphere = new ol.Sphere(6378137);

/**
* Measurement tool type
* @type {olexp.measure.Type}
Expand Down Expand Up @@ -303,7 +297,7 @@ const olexp = {
const projection = this.map.getView().getProjection();
const geometry = polygon.clone().transform(projection, 'EPSG:4326');
const coordinates = geometry.getLinearRing(0).getCoordinates();
area = Math.abs(this.sphere.geodesicArea(coordinates));
area = Math.abs(ol.sphere.getArea(coordinates));
} else {
area = polygon.getArea();
}
Expand Down Expand Up @@ -337,7 +331,7 @@ const olexp = {
for (i = 0; i < numCoordinates - 1; i += 1) {
c1 = ol.proj.transform(coordinates[i], projection, 'EPSG:4326');
c2 = ol.proj.transform(coordinates[i + 1], projection, 'EPSG:4326');
length += this.sphere.haversineDistance(c1, c2);
length += ol.sphere.getDistance(c1, c2);
}
} else {
length = Math.round(line.getLength() * 100) / 100;
Expand Down
6 changes: 4 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>OpenLayers Explorer Test</title>
<meta charset="utf-8" />
<link
href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.14.2/ol.min.css"
href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css"
rel="stylesheet"
type="text/css"
/>
Expand All @@ -20,7 +20,9 @@
<div id="explorer"></div>
<div id="overlay"></div>
<script src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.14.2/ol.js"></script>
<script
src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js">
</script>
<script src="https://unpkg.com/[email protected]/w2ui.min.js"></script>
<script src="../dist/olexp.js"></script>
<script src="index.js"></script>
Expand Down

0 comments on commit 42ee3f3

Please sign in to comment.