-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
10 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,7 +235,9 @@ <h5 class="source-heading">main.js</h5> | |
import View from 'ol/View.js'; | ||
import {OSM, Vector as VectorSource} from 'ol/source.js'; | ||
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer.js'; | ||
import {along} from '@turf/along'; | ||
import {fromLonLat} from 'ol/proj.js'; | ||
import {length} from '@turf/length'; | ||
|
||
const source = new VectorSource(); | ||
fetch('data/geojson/roads-seoul.geojson') | ||
|
@@ -254,9 +256,9 @@ <h5 class="source-heading">main.js</h5> | |
const distance = 0.2; | ||
|
||
// get the line length in kilometers | ||
const length = turf.lineDistance(turfLine, 'kilometers'); | ||
for (let i = 1; i <= length / distance; i++) { | ||
const turfPoint = turf.along(turfLine, i * distance, 'kilometers'); | ||
const lineLength = length(turfLine, 'kilometers'); | ||
for (let i = 1; i <= lineLength / distance; i++) { | ||
const turfPoint = along(turfLine, i * distance, 'kilometers'); | ||
|
||
// convert the generated point to a OpenLayers feature | ||
const marker = format.readFeature(turfPoint); | ||
|
@@ -304,7 +306,6 @@ <h5 class="source-heading">index.html</h5> | |
<body> | ||
<div id="map" class="map"></div> | ||
|
||
<script src="https://api.tiles.mapbox.com/mapbox.js/plugins/turf/v2.0.0/turf.min.js"></script> | ||
<script type="module" src="main.js"></script> | ||
</body> | ||
</html></code></pre> | ||
|
@@ -315,7 +316,9 @@ <h5 class="source-heading">package.json</h5> | |
<pre><code id="example-pkg-source" class="language-json">{ | ||
"name": "turf", | ||
"dependencies": { | ||
"ol": "10.2.2-dev" | ||
"ol": "10.2.2-dev", | ||
"@turf/along": "^7.1.0", | ||
"@turf/length": "^7.1.0" | ||
}, | ||
"devDependencies": { | ||
"vite": "^3.2.3" | ||
|
@@ -329,7 +332,6 @@ <h5 class="source-heading">package.json</h5> | |
</div> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
<script src="https://api.tiles.mapbox.com/mapbox.js/plugins/turf/v2.0.0/turf.min.js"></script> | ||
<script src="common.js"></script> | ||
<script src="turf.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/components/prism-core.min.js"></script> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.