Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ol5 #48

Merged
merged 4 commits into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix ol3 to ol5 breaking changes.
  • Loading branch information
dpmcmlxxvi committed Jun 15, 2019
commit 42ee3f30a6946c97a4f457d8bf6420a665807ec8
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/jquery@2.1.3/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/w2ui@1.4.3/w2ui.min.js"></script>
<script src="../dist/olexp.js"></script>
<script src="index.js"></script>
Expand Down