Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error handler on main map layer initialize #2024

Merged
merged 50 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9e544e5
2182 2183 2185
yzlucas May 22, 2024
b3bd17d
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 23, 2024
d697bf5
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 23, 2024
2e692b3
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 28, 2024
896a337
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 28, 2024
d673075
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 29, 2024
4aea20d
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 30, 2024
50285c6
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas May 30, 2024
1c69208
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 3, 2024
46eb032
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 4, 2024
7e8eb2e
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 4, 2024
e5582cf
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 5, 2024
123f7af
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 5, 2024
8af8fd3
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 6, 2024
ca81fef
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 6, 2024
0556734
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 10, 2024
c9281a5
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 12, 2024
cbdb47b
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 12, 2024
b35ee1f
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 13, 2024
6c7690d
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 13, 2024
d454e38
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 13, 2024
8cd5766
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 14, 2024
86dda9f
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 14, 2024
0d9a3cf
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 14, 2024
6ba2cd1
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 14, 2024
b5a0920
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 14, 2024
6700b00
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 14, 2024
059ab54
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 19, 2024
fb14d63
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 20, 2024
ee86646
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 25, 2024
a87dee4
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jun 28, 2024
180933d
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 2, 2024
e5eca9d
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 2, 2024
b88ca21
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 4, 2024
59f1a54
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 5, 2024
87dc70a
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 10, 2024
0607ec4
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 11, 2024
5aefe50
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 11, 2024
762a542
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 11, 2024
961c459
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 11, 2024
8996243
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 12, 2024
04e8a0a
2305
yzlucas Jul 12, 2024
53e1a08
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 12, 2024
0fe464b
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 12, 2024
e582c15
Merge branch '2.3.0' into wfnews-2305
yzlucas Jul 12, 2024
1b739b1
make scrollbar always visable
yzlucas Jul 12, 2024
a5de6e8
make scrollbar always visable
yzlucas Jul 12, 2024
f903350
Merge branch 'bcgov:2.3.0' into 2.3.0
yzlucas Jul 12, 2024
4b1f696
Merge branch '2.3.0' into wfnews-2305
yzlucas Jul 12, 2024
0cc7fc1
more error handler
yzlucas Jul 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ export class ActiveWildfireMapComponent implements OnInit, AfterViewInit {
.then(() => {
const deviceConfig = { viewer: { device: 'desktop' } };
this.mapConfig = [...mapConfig, deviceConfig, 'theme=wf', '?'];
this.isMapLoaded = true;
})
.catch((error) => {
console.error('Error loading map:', error);
this.isMapLoaded = false;
});
});
this.activedRouter.queryParams.subscribe((params: ParamMap) => {
Expand Down Expand Up @@ -822,75 +827,84 @@ async onSelectIncidents(incidentRefs) {
}
}

async initializeLayers() {
async initializeLayers() {
try {
const selectedLayer = await Preferences.get({ key: 'selectedLayer' });
this.selectedLayer =
(selectedLayer.value as SelectedLayer) || 'wildfire-stage-of-control';
this.selectedLayer = (selectedLayer.value as SelectedLayer) || 'wildfire-stage-of-control';
this.onSelectLayer(this.selectedLayer);
this.isMapLoaded = true;
this.notificationService
.getUserNotificationPreferences()
.then((response) => {
const SMK = window['SMK'];
const map = getActiveMap(SMK).$viewer.map;

if (!response.notifications) {
return;
}

map.on('zoomend', () => {
this.updateSavedLocationLabelVisibility();
});
try {
const SMK = window['SMK'];
const map = getActiveMap(SMK).$viewer.map;

this.resizeObserver = new ResizeObserver(() => {
map.invalidateSize();
});
if (!response.notifications) {
return;
}

this.resizeObserver.observe(map._container);

for (const smkMap in SMK.MAP) {
if (Object.hasOwn(SMK.MAP, smkMap)) {
const savedLocationMarker = {
icon: L.icon({
iconUrl:
'/assets/images/svg-icons/blue-white-location-icon.svg',
iconSize: [32, 32],
iconAnchor: [16, 32],
popupAnchor: [0, -32],
}),
draggable: false,
};
for (const item of response.notifications) {
L.marker(
[item.point.coordinates[1], item.point.coordinates[0]],
savedLocationMarker,
).addTo(getActiveMap(this.SMK).$viewer.map);
const label = L.marker(
[item.point.coordinates[1], item.point.coordinates[0]],
{
icon: L.divIcon({
className: 'marker-label',
html: `<div class="custom-marker"
map.on('zoomend', () => {
this.updateSavedLocationLabelVisibility();
});

this.resizeObserver = new ResizeObserver(() => {
map.invalidateSize();
});

this.resizeObserver.observe(map._container);

for (const smkMap in SMK.MAP) {
if (Object.hasOwn(SMK.MAP, smkMap)) {
const savedLocationMarker = {
icon: L.icon({
iconUrl: '/assets/images/svg-icons/blue-white-location-icon.svg',
iconSize: [32, 32],
iconAnchor: [16, 32],
popupAnchor: [0, -32],
}),
draggable: false,
};
for (const item of response.notifications) {
try {
L.marker(
[item.point.coordinates[1], item.point.coordinates[0]],
savedLocationMarker,
).addTo(getActiveMap(this.SMK).$viewer.map);
const label = L.marker(
[item.point.coordinates[1], item.point.coordinates[0]],
{
icon: L.divIcon({
className: 'marker-label',
html: `<div class="custom-marker"
style="margin-top: -20px; margin-left: 25px; height: 1.2em; text-wrap: nowrap; display:flex; align-items: center; justify-content: left; text-align: center; color: #000; font-family: 'BCSans', 'Open Sans', Verdana, Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: 600;">
${item.notificationName}
</div>`,
}),
},
);
label.addTo(getActiveMap(this.SMK).$viewer.map);
this.savedLocationlabels.push(label);
this.savedLocationlabelsToShow.push(label);
}),
},
);
label.addTo(getActiveMap(this.SMK).$viewer.map);
this.savedLocationlabels.push(label);
this.savedLocationlabelsToShow.push(label);
} catch (markerError) {
console.error('Error adding marker or label:', markerError);
}
}
}
}
map.invalidateSize();
} catch (smkError) {
console.error('Error in SMK setup:', smkError);
}
map.invalidateSize();
})
.catch((error) => {
console.error(error);
.catch((notificationError) => {
console.error('Error fetching user notification preferences:', notificationError);
});
this.cdr.detectChanges();
} catch (initializationError) {
console.error('Error during layer initialization:', initializationError);
}

}
private updateSavedLocationLabelVisibility() {
// showing the savedLocation label only start with zoom level 5
const map = getActiveMap(this.SMK).$viewer.map;
Expand Down Expand Up @@ -977,61 +991,63 @@ async onSelectIncidents(incidentRefs) {
{ itemId: 'radar-1km-rrai--radarurpprecipr14-linear', visible: false },
{ itemId: 'weather-stations', visible: true },
];

switch (this.selectedLayer) {
case 'evacuation-orders-and-alerts':
layers[1].visible = true;
layers[2].visible = true;
break;

case 'area-restrictions':
layers[6].visible = true;
// gives a 404 error from SMK
// layers[7].visible = true;
break;

case 'bans-and-prohibitions':
layers[5].visible = true;
layers[19].visible = true;
layers[20].visible = true;
layers[21].visible = true;
break;

case 'smoke-forecast':
layers[14].visible = true;
break;

case 'fire-danger':
layers[0].visible = true;
layers[3].visible = true;
break;

case 'local-authorities':
layers[15].visible = true;
layers[16].visible = true;
layers[17].visible = true;
layers[18].visible = true;
break;

case 'routes-impacted':
layers[11].visible = true;
break;

case 'out-fires':
layers[9].visible = true;
break;

case 'all-layers':
break;

default:
layers[0].visible = true;
layers[22].visible = true;
layers[23].visible = true;
layers[24].visible = true;
layers[25].visible = true;
try {
switch (this.selectedLayer) {
case 'evacuation-orders-and-alerts':
layers[1].visible = true;
layers[2].visible = true;
break;

case 'area-restrictions':
layers[6].visible = true;
// gives a 404 error from SMK
// layers[7].visible = true;
break;

case 'bans-and-prohibitions':
layers[5].visible = true;
layers[19].visible = true;
layers[20].visible = true;
layers[21].visible = true;
break;

case 'smoke-forecast':
layers[14].visible = true;
break;

case 'fire-danger':
layers[0].visible = true;
layers[3].visible = true;
break;

case 'local-authorities':
layers[15].visible = true;
layers[16].visible = true;
layers[17].visible = true;
layers[18].visible = true;
break;

case 'routes-impacted':
layers[11].visible = true;
break;

case 'out-fires':
layers[9].visible = true;
break;

case 'all-layers':
break;

default:
layers[0].visible = true;
layers[22].visible = true;
layers[23].visible = true;
layers[24].visible = true;
layers[25].visible = true;
}
} catch (error) {
console.error('Error activating layers:', error);
}

// initialize smkApi if undefined
if (!this.smkApi) {
let event: Event;
Expand Down
Loading