Skip to content

Commit

Permalink
Bug fix for adding unserved point in editing tool
Browse files Browse the repository at this point in the history
Signed-off-by: ZhuoweiWen <[email protected]>
  • Loading branch information
ZhuoweiWen committed Nov 8, 2023
1 parent f59a462 commit cee3ccf
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions front-end/components/Editmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ function Editmap() {

const user = localStorage.getItem("username");
const tilesURL = mbtid
? `${backend_url}/tiles/${mbtid}/${user}/{z}/{x}/{y}.pbf`
: `${backend_url}/tiles/${user}/{z}/{x}/{y}.pbf`;
? `${backend_url}/tiles/${mbtid}/${user}/{z}/{x}/{y}.pbf`
: `${backend_url}/tiles/${user}/{z}/{x}/{y}.pbf`;
map.current.addSource("custom", {
type: "vector",
tiles: [tilesURL],
Expand Down Expand Up @@ -332,13 +332,14 @@ function Editmap() {

// Set the feature state for each updated marker
if (map.current && map.current.getSource("custom")) {
// Check if the marker's feature state has been previously set
// Check if the marker's feature state has been previously set and if served is true
const currentFeatureState = map.current.getFeatureState({
source: "custom",
sourceLayer: "data",
id: marker.id,
});
if (currentFeatureState.hasOwnProperty("served")) {

if (currentFeatureState.hasOwnProperty("served") && currentFeatureState.served === true) {
// Set the 'served' feature state to false
map.current.setFeatureState(
{
Expand All @@ -350,14 +351,17 @@ function Editmap() {
served: false,
}
);
selectedSingleMarkersRef.current.push(marker);
}
}
selectedSingleMarkersRef.current.push(marker);
// Push the updated marker to the ref for selected single markers

});
}
};



const setFeatureStateForMarkers = (markers) => {
markers.forEach((marker) => {
if (marker.served) {
Expand All @@ -383,10 +387,10 @@ function Editmap() {
allMarkersRef.current.length === 0
) {
setIsLoadingForUntimedEffect(true);
const url = mbtid
? `${backend_url}/served-data/${mbtid}`
: `${backend_url}/served-data/None`;
const url = mbtid
? `${backend_url}/served-data/${mbtid}`
: `${backend_url}/served-data/None`;

return fetch(url, {
method: "GET",
credentials: "include",
Expand Down

0 comments on commit cee3ccf

Please sign in to comment.