Skip to content

Commit

Permalink
Check ref before map events
Browse files Browse the repository at this point in the history
  • Loading branch information
seadeep42 committed Oct 19, 2024
1 parent 483faf9 commit d2cd94e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/selected-bus-details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const SelectedBusDetails = ({

useEffect(() => {
const currentRef = mapRef.current;
if(!currentRef) {
return;
}

const popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false,
Expand Down
3 changes: 3 additions & 0 deletions src/components/selected-stop-details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const SelectedStopDetails = ({

useEffect(() => {
const currentRef = mapRef.current;
if(!currentRef) {
return;
}

const addLayerAndEvents = () => {
const ALL_STOPS = _.union(
Expand Down
38 changes: 38 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// import _ from "lodash";
// import polyline from "google-polyline";

export const TABS = [
{
text: "To airport",
Expand Down Expand Up @@ -572,6 +575,41 @@ export const BUS_DATA = {
],
};

// const busRoutesPoints = _.map(BUS_DATA.from, ({ routename, route }) => ({
// routename,
// geojson: { "type": "FeatureCollection",
// "features": [
// { "type": "Feature",
// "geometry": {
// "type": "LineString",
// "coordinates": polyline.decode(decodeURIComponent(route)),
// },
// },
// ],
// },
// }));

// const downloadGeojson = (data, name) => {
// const geoJsonString = JSON.stringify(data, null, 2);

// const blob = new Blob([geoJsonString], {});
// const linkElement = document.createElement('a');

// const url = window.URL.createObjectURL(blob);
// linkElement.href = url;
// linkElement.download = `${name}.geojson`;
// linkElement.click();

// URL.revokeObjectURL(url);
// }

// // console.log(busRoutesPoints);

// busRoutesPoints.forEach(bus => {
// downloadGeojson(bus.geojson, bus.routename);
// });


const COLOR_HIGHLIGHT = "#4264fb";
const COLOR_MUTED = "#aaaaaa";

Expand Down

0 comments on commit d2cd94e

Please sign in to comment.