116 lines
3.3 KiB
HTML
116 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>JSDoc: Source: modules/fetchPins.js</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"></script>
|
|
<script src="scripts/prettify/lang-css.js"></script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link
|
|
type="text/css"
|
|
rel="stylesheet"
|
|
href="styles/prettify-tomorrow.css"
|
|
/>
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<div id="main">
|
|
<h1 class="page-title">Source: modules/fetchPins.js</h1>
|
|
|
|
<section>
|
|
<article>
|
|
<pre
|
|
class="prettyprint source linenums"
|
|
><code>import makePin from "./makePin.js";
|
|
import toLatLon from "./toLatLon.js";
|
|
|
|
/**
|
|
* @module fetchPins
|
|
*/
|
|
|
|
/** Fetches pin records from database and adds pin features to pin vector source layer
|
|
* @async
|
|
* @param {ol.source.Vector} pinSource - The relevant vector source layer to add pin features to
|
|
*/
|
|
const fetchPins = async (pinSource) => {
|
|
const res = await fetch(import.meta.env.VITE_BACKEND_URL);
|
|
const pinRecords = await res.json();
|
|
|
|
pinRecords.forEach((pinRecord) => {
|
|
const [latitude, longitude] = toLatLon(
|
|
pinRecord.easting,
|
|
pinRecord.northing,
|
|
pinRecord.zone,
|
|
pinRecord.zoneLetter
|
|
);
|
|
|
|
const pin = makePin(
|
|
longitude.toFixed(5),
|
|
latitude.toFixed(5),
|
|
pinRecord.name,
|
|
pinRecord.cheapestItem,
|
|
pinRecord.cheapestFloz
|
|
);
|
|
|
|
pinSource.addFeature(pin);
|
|
});
|
|
};
|
|
|
|
export default fetchPins;
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2>
|
|
<h3>Modules</h3>
|
|
<ul>
|
|
<li>
|
|
<a href="module-changeResolutionHandler.html"
|
|
>changeResolutionHandler</a
|
|
>
|
|
</li>
|
|
<li><a href="module-fetchPins.html">fetchPins</a></li>
|
|
<li><a href="module-makePin.html">makePin</a></li>
|
|
<li><a href="module-newButton.html">newButton</a></li>
|
|
<li><a href="module-pointerMoveHandler.html">pointerMoveHandler</a></li>
|
|
<li><a href="module-searchBar.html">searchBar</a></li>
|
|
<li><a href="module-searchInputHander.html">searchInputHander</a></li>
|
|
<li><a href="module-toLatLon.html">toLatLon</a></li>
|
|
</ul>
|
|
<h3>Classes</h3>
|
|
<ul>
|
|
<li><a href="module-newButton-ButtonControl.html">ButtonControl</a></li>
|
|
</ul>
|
|
<h3>Global</h3>
|
|
<ul>
|
|
<li><a href="global.html#disposePopover">disposePopover</a></li>
|
|
<li><a href="global.html#map-onclick">map.onclick</a></li>
|
|
<li><a href="global.html#passlocation">window.passLocation</a></li>
|
|
<li><a href="global.html#placepin">window.placePin</a></li>
|
|
<li><a href="global.html#map">map</a></li>
|
|
<li><a href="global.html#pinLayer">pinLayer</a></li>
|
|
<li><a href="global.html#pinSource">pinSource</a></li>
|
|
<li><a href="global.html#popup">popup</a></li>
|
|
</ul>
|
|
</nav>
|
|
|
|
<br class="clear" />
|
|
|
|
<footer>
|
|
Documentation generated by
|
|
<a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Sun Dec 31
|
|
2023 15:19:11 GMT-0800 (Pacific Standard Time)
|
|
</footer>
|
|
|
|
<script>
|
|
prettyPrint();
|
|
</script>
|
|
<script src="scripts/linenumber.js"></script>
|
|
</body>
|
|
</html>
|