Skip to content

Commit

Permalink
DBC22-1130: Adjusted zoom level to show radius
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrel-oxd authored and ray-oxd committed Nov 1, 2023
1 parent 6ef1aa7 commit 8aafb39
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/frontend/src/Components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export default function MapWrapper({
},
},
});

const vectorLayer = new VectorTileLayer({
source: new VectorTileSource({
format: new MVT(),
Expand All @@ -291,7 +292,7 @@ export default function MapWrapper({
projection: 'EPSG:3857',
constrainResolution: true,
center: camera ? handleCenter() : fromLonLat(pan),
zoom: zoom,
zoom: isPreview ? 12 : zoom,
maxZoom: 15,
extent: transformedExtent
});
Expand Down
41 changes: 26 additions & 15 deletions src/frontend/src/Components/data/webcams.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import { post } from "./helper.js";
import { post, get } from './helper.js';

export function getWebcams(routePoints, url = null) {
const payload = routePoints ? { route: routePoints } : {};

return post(
url ? url : `${process.env.REACT_APP_API_HOST}/api/webcams/`,
payload,
{
headers: {
'Content-Type': 'application/json'
}
}

).then((data) => data)
.catch((error) => {
console.log(error);
});
if (routePoints) {
return post(
url ? url : `${process.env.REACT_APP_API_HOST}/api/webcams/`,
payload,
{
headers: {
'Content-Type': 'application/json',
},
},
)
.then(data => data)
.catch(error => {
console.log(error);
});
} else {
return get(
url ? url : `${process.env.REACT_APP_API_HOST}/api/webcams/`,
payload,
)
.then(data => data)
.catch(error => {
console.log(error);
});
}
}

export function getWebcamReplay(webcam) {
// TODO: error handling
return fetch(webcam.links.replayTheDay).then((response) => response.json());
return fetch(webcam.links.replayTheDay).then(response => response.json());
}
2 changes: 1 addition & 1 deletion src/frontend/src/pages/CameraDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function CameraDetailsPage() {
const nearby = <FontAwesomeIcon icon={faFlag} />;

async function initCamera() {
const camera = await getWebcams(null, `${process.env.REACT_APP_API_HOST}/api/webcams/${params.id}`);
const camera = await getWebcams(null, `${process.env.REACT_APP_API_HOST}/api/webcams/${params.id}/`);
// Camera data
setCamera(camera);

Expand Down

0 comments on commit 8aafb39

Please sign in to comment.