mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-22 17:44:20 -08:00
Remove zooming in on Alaska data point
This commit is contained in:
parent
e1b5c598da
commit
dc6f57a2a8
1 changed files with 18 additions and 3 deletions
|
@ -166,10 +166,24 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const feature = event.features && event.features[0];
|
const feature = event.features && event.features[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that Alaska has Points as their data type, we will not zoom into them when
|
||||||
|
* selected. In order to detect if a feature is a Point we will use Regex to determine
|
||||||
|
* the Alaska Point based on it's unique ID:
|
||||||
|
*
|
||||||
|
* E.g. {33FF6457-324C-4643-94E8-D543DD4339E0}
|
||||||
|
*
|
||||||
|
* The regex will test for any numeric, upper-case alpha with hyphens string enclosed
|
||||||
|
* in curly braces.
|
||||||
|
*/
|
||||||
|
const alaskaIDRegex = /\{[0-9,A-Z,-]+\}/g;
|
||||||
|
const isFeatureAlaskaPoint = alaskaIDRegex.test(feature.id);
|
||||||
|
|
||||||
if (feature) {
|
if (feature) {
|
||||||
// Get the current selected feature's bounding box:
|
// Get the current selected feature's bounding box:
|
||||||
const [minLng, minLat, maxLng, maxLat] = bbox(feature);
|
const [minLng, minLat, maxLng, maxLat] = bbox(feature);
|
||||||
|
|
||||||
|
|
||||||
// Set the selectedFeature ID
|
// Set the selectedFeature ID
|
||||||
if (feature.id !== selectedFeatureId) {
|
if (feature.id !== selectedFeatureId) {
|
||||||
setSelectedFeature(feature);
|
setSelectedFeature(feature);
|
||||||
|
@ -177,8 +191,9 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
setSelectedFeature(undefined);
|
setSelectedFeature(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go to the newly selected feature
|
|
||||||
goToPlace([
|
// Go to the newly selected feature (as long as it's not an Alaska Point)
|
||||||
|
!isFeatureAlaskaPoint && goToPlace([
|
||||||
[minLng, minLat],
|
[minLng, minLat],
|
||||||
[maxLng, maxLat],
|
[maxLng, maxLat],
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue