Skip to content

Commit

Permalink
Merge pull request activist-org#900 from rabelmervin/four
Browse files Browse the repository at this point in the history
direction arrow added
  • Loading branch information
andrewtavis authored Jun 30, 2024
2 parents ded83cb + 87eeb18 commit e0261fa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions frontend/components/media/MediaMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const props = defineProps<{
const i18n = useI18n();
const colorMode = useColorMode();
const bikeDirectionsIcon = `/icons/map/bike_directions_${colorMode.value}.png`;
const walkDirectionsIcon = `/icons/map/walk_directions_${colorMode.value}.png`;
const isTouchDevice =
// Note: `maxTouchPoints` isn't recognized by TS. Safe to ignore.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -49,6 +46,11 @@ function isWebglSupported() {
return false;
}
// MARK: Routing
const bikeDirectionsIcon = `/icons/map/bike_directions_${colorMode.value}.png`;
const walkDirectionsIcon = `/icons/map/walk_directions_${colorMode.value}.png`;
interface RouteProfileOption {
FOOT: string;
BIKE: string;
Expand Down Expand Up @@ -142,6 +144,8 @@ const setSelectedRoute = () => {
return selectedRoute;
};
// MARK: Map Creation
onMounted(() => {
const nominatimLocationRequest =
"https://nominatim.openstreetmap.org/search?q=Brandenburg%20Gate%20Berlin&format=json";
Expand Down Expand Up @@ -189,6 +193,8 @@ onMounted(() => {
pitch: 20,
});
// MARK: Basic Controls
map.addControl(
new maplibregl.NavigationControl({
visualizePitch: true,
Expand Down Expand Up @@ -227,12 +233,50 @@ onMounted(() => {
.setPopup(popup)
.addTo(map);
// Arrow icon for directions.
map
.loadImage("/icons/from_library/bootstrap_arrow_right.png")
.then((image) => {
console.log("Here1");
if (image) {
map.addImage("route-direction-arrow", image.data);
}
console.log("Here2", image.data);
});
map.on("load", () => {
const layers = layersFactory(
isTouchDevice ? 1.5 : 1,
isTouchDevice ? 2 : 1
);
// MARK: Directions Layer
// Add arrow to directions layer.
layers.push({
id: "maplibre-gl-directions-route-line-direction-arrow",
type: "symbol",
source: "maplibre-gl-directions",
layout: {
"symbol-placement": "line-center",
"icon-image": "route-direction-arrow",
"icon-size": [
"interpolate",
["exponential", 1.5],
["zoom"],
12,
0.85,
18,
1.4,
],
},
paint: {
"icon-opacity": 1,
},
filter: ["==", ["get", "route"], "SELECTED"],
});
let directions = new MapLibreGlDirections(map, {
...(selectedRoute = setSelectedRoute()),
requestOptions: {
Expand All @@ -250,6 +294,8 @@ onMounted(() => {
directions.interactive = true;
});
// MARK: Profile Switcher
map.addControl(
{
onAdd: function () {
Expand Down Expand Up @@ -297,6 +343,8 @@ onMounted(() => {
"top-right"
);
// MARK: Clear Directions
const clearDirectionsControl = `
<div style="
background-color: rgba(255, 255, 255, 1);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0261fa

Please sign in to comment.