Skip to content

Commit

Permalink
feat(demo): update demo area
Browse files Browse the repository at this point in the history
- update demo area units to km2
- add github link
  • Loading branch information
dqunbp committed Jun 12, 2020
1 parent 35f6dfe commit 99f10a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
12 changes: 11 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
margin: 15px;
top: 0;
left: 0;
position: relative;
}
#area-container a {
position: absolute;
right: 0;
top: 0;
padding: 20px;
}
</style>

Expand All @@ -60,7 +67,10 @@
<body>
<div id="map"></div>
<div id="area-container">
<h1 id="area"></h1>
<a href="https://github.com/dqunbp/mapbox-gl-draw-rectangle-restrict-area"
>github</a
>
<h1>Area <span id="area"></span> km<sup>2</sup></h1>
</div>
<button id="draw-rectangle" class="draw">Draw Rectangle</button>
<script src="index.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ const draw = new MapboxDraw({
map.addControl(draw);

const currenArea = document.getElementById("area");
currenArea.textContent = "Area 0 m2";
currenArea.textContent = "0";

function onAreaChanged(area) {
currenArea.textContent = `Area ${area.toFixed(2)} m2`;
currenArea.textContent = `${(area / 1_000_000).toFixed(2)}`;
}

document.getElementById("draw-rectangle").addEventListener("click", () => {
Expand Down
4 changes: 1 addition & 3 deletions src/draw-rectangle-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { getIneractionSwitch } from "./switchIteractions";
const doubleClickZoom = getIneractionSwitch("doubleClickZoom");
const dragPan = getIneractionSwitch("dragPan");

function getArea(feature) {
return area(feature);
}
const getArea = (feature) => area(feature);

const DrawRectangle = {};

Expand Down

0 comments on commit 99f10a1

Please sign in to comment.