Skip to content

Commit

Permalink
fixed map
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ2LS committed Sep 30, 2024
1 parent 935770d commit e81da9e
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions freedata_gui/src/components/grid/grid_stations_map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ const drawMap = () => {
// Adjust pin size and line width with zoom
actualPinRadius = basePinRadius / event.transform.k;
svg.selectAll('.pin').attr('r', actualPinRadius);
svg.selectAll('.my-pin').attr('r', actualPinRadius);
svg.selectAll('.heard-pin').attr('r', actualPinRadius);
svg.selectAll('.connection-line').attr('stroke-width', 1 / event.transform.k);
svg.selectAll('.country-path').attr('stroke-width', 0.5 / event.transform.k);
Expand Down Expand Up @@ -123,7 +125,7 @@ const drawMap = () => {
// Draw the pin for your station
g.append('circle')
.attr('class', 'pin my-pin')
.attr('class', 'my-pin')
.attr('r', actualPinRadius + 2)
.attr('fill', 'blue')
.attr('cx', myX)
Expand Down Expand Up @@ -185,10 +187,12 @@ const drawMap = () => {
});
};
// Function to update pins and draw lines
// Function to update pins and draw lines
const updatePinsAndLines = (g) => {
// Remove existing pins and lines
g.selectAll('.pin').remove();
g.selectAll('.my-pin').remove();
g.selectAll('.heard-pin').remove();
g.selectAll('.connection-line').remove();
const heardStations = toRaw(state.heard_stations); // Ensure it's the raw data
Expand All @@ -210,7 +214,7 @@ const updatePinsAndLines = (g) => {
// Draw the pin for your station
g.append('circle')
.attr('class', 'pin my-pin')
.attr('class', 'my-pin')
.attr('r', actualPinRadius + 2)
.attr('fill', 'blue')
.attr('cx', myX)
Expand Down Expand Up @@ -238,11 +242,11 @@ const updatePinsAndLines = (g) => {
}
// Add pins for heard stations
g.selectAll('.pin')
g.selectAll('.heard-pin')
.data(points)
.enter()
.append('circle')
.attr('class', 'pin')
.attr('class', 'heard-pin')
.attr('r', actualPinRadius)
.attr('fill', 'red')
.attr('cx', d => projection([d.lon, d.lat])[0])
Expand All @@ -255,16 +259,6 @@ const updatePinsAndLines = (g) => {
});
};
// Zoom in function
const zoomIn = () => {
svg.transition().call(zoom.scaleBy, 1.2);
};
// Zoom out function
const zoomOut = () => {
svg.transition().call(zoom.scaleBy, 0.8);
};
// Center the map
const centerMap = () => {
let mygrid = settings.remote.STATION.mygrid;
Expand All @@ -288,6 +282,15 @@ const centerMap = () => {
);
};
// Zoom in function
const zoomIn = () => {
svg.transition().call(zoom.scaleBy, 1.2);
};
// Zoom out function
const zoomOut = () => {
svg.transition().call(zoom.scaleBy, 0.8);
};
// Lifecycle hooks
onMounted(async () => {
Expand All @@ -308,7 +311,13 @@ onBeforeUnmount(() => {
height: 400px;
}
.pin {
.my-pin {
fill: blue;
stroke: black;
stroke-width: 1px;
}
.heard-pin {
fill: red;
stroke: black;
stroke-width: 1px;
Expand All @@ -320,7 +329,7 @@ onBeforeUnmount(() => {
}
.connection-line {
stroke: blue;
stroke: red;
stroke-width: 1;
stroke-opacity: 0.5;
}
Expand Down

0 comments on commit e81da9e

Please sign in to comment.