mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-22 01:31:25 -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
|
||||
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) {
|
||||
// Get the current selected feature's bounding box:
|
||||
const [minLng, minLat, maxLng, maxLat] = bbox(feature);
|
||||
|
||||
|
||||
// Set the selectedFeature ID
|
||||
if (feature.id !== selectedFeatureId) {
|
||||
setSelectedFeature(feature);
|
||||
|
@ -177,8 +191,9 @@ const J40Map = ({location}: IJ40Interface) => {
|
|||
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],
|
||||
[maxLng, maxLat],
|
||||
]);
|
||||
|
@ -239,7 +254,7 @@ const J40Map = ({location}: IJ40Interface) => {
|
|||
* @param {LngLatBoundsLike} bounds
|
||||
* @param {boolean} isTerritory
|
||||
*/
|
||||
const goToPlace = (bounds: LngLatBoundsLike, isTerritory = false ) => {
|
||||
const goToPlace = (bounds: LngLatBoundsLike, isTerritory = false) => {
|
||||
const newViewPort = new WebMercatorViewport({height: viewport.height!, width: viewport.width!});
|
||||
const {longitude, latitude, zoom} = newViewPort.fitBounds(
|
||||
bounds as [[number, number], [number, number]], {
|
||||
|
|
Loading…
Add table
Reference in a new issue