// creates pins import { Feature } from "ol"; import { Icon, Style } from "ol/style"; import Point from "ol/geom/Point.js"; /** * @module makePin */ /** Makes pin feature from arguments * @param {number} lon - Longitude * @param {number} lat - Latitude * @param {string} storeName - Name of store * @param {string} cheapest - Cheapest item in store * @param {number} flozPrice - Price per fluid ounce of cheapest item in store * @returns {ol.Feature} - Created pin feature */ const makePin = (lon, lat, storeName, cheapest, flozPrice) => { // define pin graphics (since this is all inline) const pinSVG = ``; const pinSVGBlob = new Blob([pinSVG], { type: "image/svg+xml", }); const pinImageURL = URL.createObjectURL(pinSVGBlob); // define style for all pins const pinStyle = new Style({ image: new Icon({ src: pinImageURL, anchor: [0.5, 1], }), }); // create pin as feature const pin = new Feature({ geometry: new Point([lon, lat]), store: storeName, cheapestItem: cheapest, pricePerOz: flozPrice, }); // set style for pin pin.setStyle(pinStyle); return pin; }; export default makePin;