Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes
File renamed without changes
File renamed without changes
28 changes: 19 additions & 9 deletions frontend/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import './index.css';
import L from 'leaflet';
import roverImage from '/images/rover.png';
import roverShadowImage from '/images/rover-shadow.png';
import markerIcon from 'leaflet/dist/images/marker-icon.png';
import markerShadow from 'leaflet/dist/images/marker-shadow.png';
import { map } from './map.js';
import { toggleCircles, clearCircles, circleOnPoint } from './circleTools';
import { toggleMarkers, clearPaths } from './pathTools';
Expand All @@ -15,6 +20,11 @@ import {
} from './helpers.js';
import { startGPSClient } from './gps-client.js'; // This now returns the WebSocket

L.Icon.Default.prototype._getIconUrl = function (name) {
if (name === 'icon') return markerIcon;
if (name === 'shadow') return markerShadow;
};

// Event listeners
window.toggleCircles = toggleCircles;
window.clearCircles = clearCircles;
Expand All @@ -36,14 +46,14 @@ let currentPositionMarker = null;
window.onload = () => {
// Initialize rover icon
var roverIcon = L.icon({
iconUrl: 'rover.png',
shadowUrl: 'rover-shadow.png',
iconSize: [30, 30], // size of the icon
shadowSize: [30, 30], // size of the shadow
iconAnchor: [0, 0], // point of the icon which will correspond to marker's location
iconUrl: roverImage,
shadowUrl: roverShadowImage,

iconSize: [30, 30], // size of the icon
shadowSize: [30, 30], // size of the shadow
iconAnchor: [0, 0], // point of the icon which will correspond to marker's location
shadowAnchor: [-2, 1], // the same for the shadow
popupAnchor: [50, 50] // point from which the popup should open relative to the iconAnchor
popupAnchor: [50, 50] // point from which the popup should open relative to the iconAnchor
});

window.addWayPoint = () => {
Expand All @@ -63,8 +73,8 @@ window.onload = () => {
if (currentPositionMarker) {
currentPositionMarker.setLatLng([lat, lon]);
} else {
currentPositionMarker = L.marker([lat, lon], {icon: roverIcon}).addTo(map);
currentPositionMarker = L.marker([lat, lon], { icon: roverIcon }).addTo(map);

map.setView([lat, lon], 15); // Center map around Rover initial position
}
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
import placeholderImage from '/images/map-placeholder.png'

export const map = L.map('map').setView([38.4375, -110.8125], 17);

Expand All @@ -13,7 +14,7 @@ const tileLayer = L.tileLayer('/utah-tiles-2/{z}/{x}/{y}.png', {

tileLayer.on('tileerror', function (e) {
const img = e.tile;
img.src = '../map-placeholder.png'; // placeholder image for if tiles don't load
img.src = placeholderImage; // placeholder image for if tiles don't load
});

tileLayer.addTo(map);
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.