Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 1x | import circle from "@turf/circle";
import type { Map } from "mapbox-gl";
import {
CURRENT_LOCATION_CIRCLE,
CURRENT_LOCATION_CIRCLE_LAYER,
CURRENT_LOCATION_RADIUS,
CURRENT_LOCATION_RADIUS_LAYER
} from "./consts";
export function drawCircle(
map: Map,
lng: number,
lat: number,
radiusSize: number
): Map {
const radiusCircle = circle([lng, lat], radiusSize, {
properties: { foo: "bar" },
steps: 26,
units: "feet"
});
map.addSource(CURRENT_LOCATION_RADIUS, {
data: radiusCircle,
type: "geojson"
});
const updatedMap = map.addLayer({
id: CURRENT_LOCATION_RADIUS_LAYER,
paint: {
"fill-color": "#888888",
"fill-opacity": 0.4
},
source: CURRENT_LOCATION_RADIUS,
type: "fill"
});
return updatedMap;
}
export function setCurrentLocationMarker(
map: Map,
lng: number,
lat: number,
radiusSize: number
): Map {
map.addSource(CURRENT_LOCATION_CIRCLE, {
data: {
geometry: {
coordinates: [lng, lat],
type: "Point"
},
properties: {},
type: "Feature"
},
type: "geojson"
});
map.addLayer({
id: CURRENT_LOCATION_CIRCLE_LAYER,
source: CURRENT_LOCATION_CIRCLE,
paint: {
"circle-emissive-strength": 1
},
type: "circle"
});
return drawCircle(map, lng, lat, radiusSize);
}
export function initializeCurrentLocationMarker(
map: Map,
lng: number,
lat: number,
radiusSize: number
) {
let updatedMap = map;
map.on("load", () => {
updatedMap = setCurrentLocationMarker(map, lng, lat, radiusSize);
});
return updatedMap;
}
|