@xgis/xgis-components 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/components/Basemap/BasemapComponent.d.ts +2 -0
- package/dist/components/Basemap/BasemapIcon.d.ts +6 -0
- package/dist/components/Basemap/BasemapView.d.ts +2 -0
- package/dist/components/Basemap/index.d.ts +2 -0
- package/dist/components/LayerPanel/LayerPanelComponent.d.ts +2 -0
- package/dist/components/LayerPanel/LayerPanelView.d.ts +2 -0
- package/dist/components/LayerPanel/index.d.ts +2 -0
- package/dist/components/MapSwitch/MapSwitchButtons.d.ts +3 -0
- package/dist/components/MapSwitch/MapSwitchComponent.d.ts +2 -0
- package/dist/components/MapSwitch/MapSwitchDesktop.d.ts +1 -0
- package/dist/components/MapSwitch/MapSwitchMobile.d.ts +1 -0
- package/dist/components/MapSwitch/index.d.ts +2 -0
- package/dist/components/Navigation/CompassButtons.d.ts +2 -0
- package/dist/components/Navigation/HistoryButtons.d.ts +2 -0
- package/dist/components/Navigation/LocationButtons.d.ts +2 -0
- package/dist/components/Navigation/NavigationButtons.d.ts +7 -0
- package/dist/components/Navigation/NavigationComponent.d.ts +2 -0
- package/dist/components/Navigation/ZoomButtons.d.ts +2 -0
- package/dist/components/Navigation/compassUtils.d.ts +11 -0
- package/dist/components/Navigation/geolocationUtils.d.ts +9 -0
- package/dist/components/Navigation/hooks/useGeolocation.d.ts +9 -0
- package/dist/components/Navigation/hooks/useLiveRotation.d.ts +1 -0
- package/dist/components/Navigation/hooks/useNavigationHistory.d.ts +8 -0
- package/dist/components/Navigation/index.d.ts +6 -0
- package/dist/components/Notification/NotificationComponent.d.ts +2 -0
- package/dist/components/Notification/NotificationToasts.d.ts +2 -0
- package/dist/components/Notification/index.d.ts +2 -0
- package/dist/components/SidePanel/MobileSidePanel.d.ts +1 -0
- package/dist/components/SidePanel/SidePanelComponent.d.ts +7 -0
- package/dist/components/SidePanel/SidePanelView.d.ts +2 -0
- package/dist/components/SidePanel/index.d.ts +3 -0
- package/dist/components/TopicList/TopicListComponent.d.ts +2 -0
- package/dist/components/TopicList/TopicListView.d.ts +2 -0
- package/dist/components/TopicList/TopicPicker.d.ts +1 -0
- package/dist/components/TopicList/TopicRow.d.ts +8 -0
- package/dist/components/TopicList/TopicSelect.d.ts +1 -0
- package/dist/components/TopicList/TopicTrigger.d.ts +1 -0
- package/dist/components/TopicList/index.d.ts +5 -0
- package/dist/components/TopicList/topicSearch.d.ts +3 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1199 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +113 -0
- package/package.json +58 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
import { useMapViewStore, modeForSide, useBasemapStore, useBasemapTree, useComponentTranslate, BASEMAP_COMPONENT_ID, useTranslate, resolveActiveBasemapNode, useBasemapAvailability, basemapNodeIcon, BaseMapErrors, layerKey, SLOTS, useLayoutStore, Slot, SIDEPANEL_COMPONENT_ID, useUiStore, useTopicStore, useLayerStore, LAYERPANEL_COMPONENT_ID, MAPSWITCH_COMPONENT_ID, useConfigStore, wrapToRange, RADIANS_TO_DEGREES, useCapability, NAVIGATION_COMPONENT_ID, useParallelViewSync, activeEngine, useNavigationHistoryStore, extentCenter, selectSyncedGroup, wgs84ToEpsg3301, containsPoint, clampPointToBounds, epsg3301ToWgs84, translate, componentKey, DEGREES_TO_RADIANS, useGeolocationStore, useMapBusEmit, useUserMarkerStore, useZoomFloor, MAX_ZOOM, useMapBusEvent, NOTIFICATION_COMPONENT_ID, TOPICLIST_COMPONENT_ID } from '@xgis/xgis-common';
|
|
2
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { Tabs, Toggle, ButtonGroup, Button, Icon, Text, sendNotification, ToastContainer, CardButton, Card, Collapse, TextField, Row, Col, Select } from '@tedi-design-system/react/tedi';
|
|
4
|
+
import { BaseMapSelection, MapAccordion, MapButton, ButtonGroup as ButtonGroup$1 } from '@tedi-design-system/react/community';
|
|
5
|
+
import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
const defaultBasemapIconUrl = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2067%2067'%20width='67'%20height='67'%3e%3cpath%20d='M3.33%200.06C13.98%200.06%2024.64%200.06%2035.29%200.06C33.78%206.45%2022.37%201.27%2017.58%203.12C15.49%203.93%2014.39%208.25%2012.5%209.68C9.44%206.47%206.39%203.26%203.33%200.06ZM33.17%205.04C31.94%209.01%2030.72%2012.99%2029.5%2016.97C27.55%2017.77%2023.89%2015.84%2021.5%2016.03C18.7%2016.25%2016.98%2018.47%2014.5%2019.15C13.41%2018.27%2012.33%2017.38%2011.24%2016.5C13.66%2012.68%2016.08%208.86%2018.5%205.04C23.39%205.04%2028.28%205.04%2033.17%205.04ZM40.83%205.16C42.51%207.05%2042.63%2011.3%2043.15%2013.72C43.84%2016.97%2045.97%2021.17%2045.75%2024.5C45.37%2030.09%2037.91%2032.94%2033.32%2031.5C33.89%2026.89%2034.42%2023.31%2031.13%2019.5C31.32%2017.87%2035.15%205.78%2036.06%205.22C37.17%204.56%2039.62%204.98%2040.83%205.16ZM51.5%2011.63C52.28%2016.63%2053.06%2021.62%2053.83%2026.62C46.34%2025.68%2047.33%2019.16%2045.24%2013.5C46.88%2011.91%2049.32%2011.85%2051.5%2011.63ZM21.25%2018.14C32.51%2016.04%2035.99%2033.16%2024.91%2035.8C13.55%2038.51%209.84%2020.26%2021.25%2018.14ZM9.5%2019.02C10.65%2018.92%2013.12%2020.01%2013.2%2021.51C13.42%2025.2%2010.46%2026.37%2013.13%2032.06C15.35%2036.79%2018.77%2035.79%2021.93%2038.24C23.18%2039.21%2023.48%2043%2023.87%2044.5C22.69%2045.72%2015.54%2047.45%2014.41%2046.09C13.06%2044.47%2012.53%2041.03%2011.82%2039.02C10.48%2035.27%206.46%2028.2%206.33%2024.49C6.28%2022.89%208.61%2020.28%209.5%2019.02ZM0.06%2025C1.22%2025.01%203.17%2024.62%204.16%2025.33C5.21%2026.1%209.45%2038.18%209.59%2039.83C6.41%2038.88%203.23%2037.93%200.06%2036.97C0.06%2032.98%200.06%2028.99%200.06%2025ZM39.97%2033.5C39.75%2034.71%2035.35%2042.3%2034.4%2042.86C32.15%2044.18%2028.94%2043.82%2026.5%2044.59C25.8%2042.56%2025.11%2040.53%2024.41%2038.5C27.82%2036.01%2035.85%2031.95%2039.97%2033.5ZM66.94%2039.28C66.94%2047.51%2066.94%2055.74%2066.94%2063.97C62.15%2062.34%2061.72%2045.39%2060.63%2040.5C62.73%2040.09%2064.84%2039.69%2066.94%2039.28ZM53.98%2066.94C44.99%2066.94%2036.01%2066.94%2027.02%2066.94C28.23%2057.72%2052.77%2057.72%2053.98%2066.94ZM63.31%2066.94C60.87%2066.94%2058.44%2066.94%2056%2066.94C55.27%2065.13%2054.53%2063.31%2053.79%2061.5C54.36%2060.97%2054.93%2060.43%2055.5%2059.9C58.1%2062.25%2060.71%2064.59%2063.31%2066.94Z'%20fill='%23539964'%20fill-rule='evenodd'%20stroke='%23539964'%20stroke-width='0.25'%20stroke-linejoin='round'/%3e%3cpath%20d='M0.08%200.08C1.16%200.07%202.25%200.06%203.33%200.06C6.39%203.26%209.44%206.47%2012.5%209.68C14.39%208.25%2015.49%203.93%2017.58%203.12C22.37%201.27%2033.78%206.45%2035.29%200.06C41.54%200.06%2047.8%200.06%2054.05%200.06C56.19%2012.65%2058.33%2025.24%2060.47%2037.83C62.63%2037.56%2064.79%2037.29%2066.94%2037.01C66.94%2037.77%2066.94%2038.53%2066.94%2039.28C64.84%2039.69%2062.73%2040.09%2060.63%2040.5C61.72%2045.39%2062.15%2062.34%2066.94%2063.97C66.94%2064.95%2066.93%2065.93%2066.92%2066.92C65.71%2066.93%2064.51%2066.94%2063.31%2066.94C60.71%2064.59%2058.1%2062.25%2055.5%2059.9C54.93%2060.43%2054.36%2060.97%2053.79%2061.5C54.53%2063.31%2055.27%2065.13%2056%2066.94C55.33%2066.94%2054.66%2066.94%2053.98%2066.94C52.77%2057.72%2028.23%2057.72%2027.02%2066.94C26.34%2066.94%2025.66%2066.94%2024.98%2066.94C24.83%2055.64%2045.09%2057.81%2051.5%2060.28C52.04%2059.68%2052.58%2059.09%2053.13%2058.5C47.58%2053.65%2042.04%2048.8%2036.5%2043.95C33.31%2047.36%2020.16%2047.24%2015.17%2049.17C13.79%2055.09%2012.42%2061.02%2011.05%2066.94C10.36%2066.94%209.67%2066.94%208.99%2066.94C9.07%2061.17%2015.55%2047.77%2010.86%2043.31C9.5%2042.02%206.67%2041.51%204.92%2040.88C3.31%2040.3%201.73%2039.37%200.06%2039.03C0.06%2038.35%200.06%2037.66%200.06%2036.97C3.23%2037.93%206.41%2038.88%209.59%2039.83C9.45%2038.18%205.21%2026.1%204.16%2025.33C3.17%2024.62%201.22%2025.01%200.06%2025C0.06%2021.46%200.06%2017.91%200.06%2014.37C1.54%2015.63%203.02%2016.89%204.5%2018.15C6.09%2016.71%208.24%2015.55%208.32%2013.17C5.57%2010.89%202.81%208.62%200.06%206.34C0.06%204.26%200.07%202.17%200.08%200.08ZM50.21%203.67C48.69%203.67%2047.18%203.67%2045.67%203.67C45.67%205.22%2045.67%206.78%2045.67%208.33C47.18%208.33%2048.69%208.33%2050.21%208.33C50.21%206.78%2050.21%205.22%2050.21%203.67ZM33.17%205.04C28.28%205.04%2023.39%205.04%2018.5%205.04C16.08%208.86%2013.66%2012.68%2011.24%2016.5C12.33%2017.38%2013.41%2018.27%2014.5%2019.15C16.98%2018.47%2018.7%2016.25%2021.5%2016.03C23.89%2015.84%2027.55%2017.77%2029.5%2016.97C30.72%2012.99%2031.94%209.01%2033.17%205.04ZM40.83%205.16C39.62%204.98%2037.17%204.56%2036.06%205.22C35.15%205.78%2031.32%2017.87%2031.13%2019.5C34.42%2023.31%2033.89%2026.89%2033.32%2031.5C37.91%2032.94%2045.37%2030.09%2045.75%2024.5C45.97%2021.17%2043.84%2016.97%2043.15%2013.72C42.63%2011.3%2042.51%207.05%2040.83%205.16ZM51.5%2011.63C49.32%2011.85%2046.88%2011.91%2045.24%2013.5C47.33%2019.16%2046.34%2025.68%2053.83%2026.62C53.06%2021.62%2052.28%2016.63%2051.5%2011.63ZM21.25%2018.14C9.84%2020.26%2013.55%2038.51%2024.91%2035.8C35.99%2033.16%2032.51%2016.04%2021.25%2018.14ZM9.5%2019.02C8.61%2020.28%206.28%2022.89%206.33%2024.49C6.46%2028.2%2010.48%2035.27%2011.82%2039.02C12.53%2041.03%2013.06%2044.47%2014.41%2046.09C15.54%2047.45%2022.69%2045.72%2023.87%2044.5C23.48%2043%2023.18%2039.21%2021.93%2038.24C18.77%2035.79%2015.35%2036.79%2013.13%2032.06C10.46%2026.37%2013.42%2025.2%2013.2%2021.51C13.12%2020.01%2010.65%2018.92%209.5%2019.02ZM47.5%2026.65C44.72%2030.99%2041.94%2035.33%2039.17%2039.66C45.63%2045.39%2052.09%2051.11%2058.55%2056.83C59.41%2055.04%2058.18%2052.76%2058%2050.83C57.49%2045.45%2056.6%2039.75%2055.36%2034.48C55.03%2033.07%2055.37%2030.9%2054.43%2029.74C53.17%2028.19%2049.37%2027.28%2047.5%2026.65ZM39.97%2033.5C35.85%2031.95%2027.82%2036.01%2024.41%2038.5C25.11%2040.53%2025.8%2042.56%2026.5%2044.59C28.94%2043.82%2032.15%2044.18%2034.4%2042.86C35.35%2042.3%2039.75%2034.71%2039.97%2033.5Z'%20fill='%23eaecec'%20fill-rule='evenodd'%20stroke='%23eaecec'%20stroke-width='0.25'%20stroke-linejoin='round'/%3e%3cpath%20d='M54.05%200.06C58.34%200.06%2062.63%200.07%2066.92%200.08C66.93%200.72%2066.94%201.36%2066.94%202C64.35%202.09%2061.76%202.17%2059.17%202.25C59.2%207.11%2059.22%2011.97%2059.25%2016.83C60.78%2016.97%2062.31%2017.1%2063.83%2017.24C63.97%2018.44%2064.11%2019.64%2064.25%2020.83C65.15%2020.89%2066.05%2020.94%2066.94%2021C66.94%2023.77%2066.94%2026.53%2066.94%2029.3C64.97%2029.7%2062.99%2030.1%2061.01%2030.5C61.17%2032.1%2061.34%2033.7%2061.5%2035.3C63.31%2035.11%2065.13%2034.91%2066.94%2034.72C66.94%2035.48%2066.94%2036.25%2066.94%2037.01C64.79%2037.29%2062.63%2037.56%2060.47%2037.83C58.33%2025.24%2056.19%2012.65%2054.05%200.06ZM47.5%2026.65C49.37%2027.28%2053.17%2028.19%2054.43%2029.74C55.37%2030.9%2055.03%2033.07%2055.36%2034.48C56.6%2039.75%2057.49%2045.45%2058%2050.83C58.18%2052.76%2059.41%2055.04%2058.55%2056.83C52.09%2051.11%2045.63%2045.39%2039.17%2039.66C41.94%2035.33%2044.72%2030.99%2047.5%2026.65ZM52.97%2034.04C50.99%2034.04%2049.01%2034.04%2047.03%2034.04C47.03%2037.35%2047.03%2040.65%2047.03%2043.96C49.01%2043.96%2050.99%2043.96%2052.97%2043.96C52.97%2040.65%2052.97%2037.35%2052.97%2034.04ZM0.06%2039.03C1.73%2039.37%203.31%2040.3%204.92%2040.88C6.67%2041.51%209.5%2042.02%2010.86%2043.31C15.55%2047.77%209.07%2061.17%208.99%2066.94C6.02%2066.94%203.05%2066.93%200.08%2066.92C0.07%2066.52%200.06%2066.12%200.06%2065.72C0.95%2065.76%201.85%2065.79%202.75%2065.83C4.07%2062.17%203.04%2056.98%206.83%2055.46C7.38%2052.81%207.93%2050.15%208.48%2047.5C6.89%2045.58%207.32%2044.91%206.99%2042.5C5.45%2042.28%203.91%2042.06%202.36%2041.83C1.59%2044.76%200.83%2047.69%200.06%2050.62C0.06%2046.76%200.06%2042.9%200.06%2039.03ZM24.98%2066.94C20.34%2066.94%2015.69%2066.94%2011.05%2066.94C12.42%2061.02%2013.79%2055.09%2015.17%2049.17C20.16%2047.24%2033.31%2047.36%2036.5%2043.95C42.04%2048.8%2047.58%2053.65%2053.13%2058.5C52.58%2059.09%2052.04%2059.68%2051.5%2060.28C45.09%2057.81%2024.83%2055.64%2024.98%2066.94ZM38.5%2047.8C37.36%2049.03%2036.22%2050.27%2035.08%2051.5C36.55%2052.73%2038.03%2053.97%2039.5%2055.2C40.64%2053.97%2041.78%2052.73%2042.92%2051.5C41.45%2050.27%2039.97%2049.03%2038.5%2047.8ZM25.97%2050.04C24.31%2050.04%2022.66%2050.04%2021%2050.04C21%2050.7%2021%2051.36%2021%2052.02C19.36%2052.02%2017.72%2052.02%2016.07%2052.02C16.07%2053.02%2016.07%2054.01%2016.07%2055.01C17.72%2055.01%2019.37%2055.01%2021.01%2055.01C21.01%2057.66%2021.01%2060.31%2021.01%2062.96C22.66%2062.96%2024.32%2062.96%2025.97%2062.96C25.97%2058.65%2025.97%2054.35%2025.97%2050.04ZM31.93%2050.1C31.31%2050.1%2030.69%2050.1%2030.07%2050.1C30.07%2051.03%2030.07%2051.97%2030.07%2052.9C30.69%2052.9%2031.31%2052.9%2031.93%2052.9C31.93%2051.97%2031.93%2051.03%2031.93%2050.1Z'%20fill='%23cacecc'%20fill-rule='evenodd'%20stroke='%23cacecc'%20stroke-width='0.25'%20stroke-linejoin='round'/%3e%3cpath%20d='M38%200%2050%200%2051%209%2045%2011%2045%2010%2044%2010%2043%203%2037%203ZM0%203%2010%2012%2010%2015%209%2015%209%2017%207%2018%207%2020%205%2021%205%2023%200%2023Z'%20fill='%23cacecc'%20fill-rule='evenodd'%20stroke='%23cacecc'%20stroke-width='0.25'%20stroke-linejoin='round'/%3e%3cpath%20d='M66.94%202C66.94%208.33%2066.94%2014.67%2066.94%2021C66.05%2020.94%2065.15%2020.89%2064.25%2020.83C64.11%2019.64%2063.97%2018.44%2063.83%2017.24C62.31%2017.1%2060.78%2016.97%2059.25%2016.83C59.22%2011.97%2059.2%207.11%2059.17%202.25C61.76%202.17%2064.35%202.09%2066.94%202ZM50.21%203.67C50.21%205.22%2050.21%206.78%2050.21%208.33C48.69%208.33%2047.18%208.33%2045.67%208.33C45.67%206.78%2045.67%205.22%2045.67%203.67C47.18%203.67%2048.69%203.67%2050.21%203.67ZM0.06%206.34C2.81%208.62%205.57%2010.89%208.32%2013.17C8.24%2015.55%206.09%2016.71%204.5%2018.15C3.02%2016.89%201.54%2015.63%200.06%2014.37C0.06%2011.69%200.06%209.02%200.06%206.34ZM66.94%2029.3C66.94%2031.11%2066.94%2032.91%2066.94%2034.72C65.13%2034.91%2063.31%2035.11%2061.5%2035.3C61.34%2033.7%2061.17%2032.1%2061.01%2030.5C62.99%2030.1%2064.97%2029.7%2066.94%2029.3ZM52.97%2034.04C52.97%2037.35%2052.97%2040.65%2052.97%2043.96C50.99%2043.96%2049.01%2043.96%2047.03%2043.96C47.03%2040.65%2047.03%2037.35%2047.03%2034.04C49.01%2034.04%2050.99%2034.04%2052.97%2034.04ZM0.06%2065.72C0.06%2060.69%200.06%2055.66%200.06%2050.62C0.83%2047.69%201.59%2044.76%202.36%2041.83C3.91%2042.06%205.45%2042.28%206.99%2042.5C7.32%2044.91%206.89%2045.58%208.48%2047.5C7.93%2050.15%207.38%2052.81%206.83%2055.46C3.04%2056.98%204.07%2062.17%202.75%2065.83C1.85%2065.79%200.95%2065.76%200.06%2065.72ZM38.5%2047.8C39.97%2049.03%2041.45%2050.27%2042.92%2051.5C41.78%2052.73%2040.64%2053.97%2039.5%2055.2C38.03%2053.97%2036.55%2052.73%2035.08%2051.5C36.22%2050.27%2037.36%2049.03%2038.5%2047.8ZM25.97%2050.04C25.97%2054.35%2025.97%2058.65%2025.97%2062.96C24.32%2062.96%2022.66%2062.96%2021.01%2062.96C21.01%2060.31%2021.01%2057.66%2021.01%2055.01C19.37%2055.01%2017.72%2055.01%2016.07%2055.01C16.07%2054.01%2016.07%2053.02%2016.07%2052.02C17.72%2052.02%2019.36%2052.02%2021%2052.02C21%2051.36%2021%2050.7%2021%2050.04C22.66%2050.04%2024.31%2050.04%2025.97%2050.04ZM31.93%2050.1C31.93%2051.03%2031.93%2051.97%2031.93%2052.9C31.31%2052.9%2030.69%2052.9%2030.07%2052.9C30.07%2051.97%2030.07%2051.03%2030.07%2050.1C30.69%2050.1%2031.31%2050.1%2031.93%2050.1Z'%20fill='%239faca3'%20fill-rule='evenodd'%20stroke='%239faca3'%20stroke-width='0.25'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
8
|
+
|
|
9
|
+
function BasemapIcon({ src, alt }) {
|
|
10
|
+
const [failedSrc, setFailedSrc] = useState();
|
|
11
|
+
const resolved = src && src !== failedSrc ? src : defaultBasemapIconUrl;
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
"img",
|
|
14
|
+
{
|
|
15
|
+
alt,
|
|
16
|
+
src: resolved,
|
|
17
|
+
onError: () => {
|
|
18
|
+
if (resolved !== defaultBasemapIconUrl) {
|
|
19
|
+
setFailedSrc(src);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function optionTooltip(status, failed, t) {
|
|
27
|
+
if (status?.reason) {
|
|
28
|
+
return t(`unavailable.${status.reason}`);
|
|
29
|
+
}
|
|
30
|
+
if (failed) {
|
|
31
|
+
return t(`unavailable.${BaseMapErrors.SERVICE}`);
|
|
32
|
+
}
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
function nodeTitle(node, t) {
|
|
36
|
+
const key = node.kind === "folder" ? `${node.id}.label` : layerKey(node.id, "name.label");
|
|
37
|
+
const title = t(key);
|
|
38
|
+
return !title || title === key ? node.id : title;
|
|
39
|
+
}
|
|
40
|
+
function BasemapView({ componentId }) {
|
|
41
|
+
const activeMap = useMapViewStore((s) => s.mode);
|
|
42
|
+
const activeParallellMap = useMapViewStore((s) => modeForSide(s.parallelPrimary));
|
|
43
|
+
const activeBasemap2d = useBasemapStore((s) => s.activeBasemap2d);
|
|
44
|
+
const activeBasemap3d = useBasemapStore((s) => s.activeBasemap3d);
|
|
45
|
+
const opacity2d = useBasemapStore((s) => s.opacity2d);
|
|
46
|
+
const opacity3d = useBasemapStore((s) => s.opacity3d);
|
|
47
|
+
const failedBasemap2d = useBasemapStore((s) => s.failedBasemap2d);
|
|
48
|
+
const failedBasemap3d = useBasemapStore((s) => s.failedBasemap3d);
|
|
49
|
+
const engine = activeMap === "parallel" ? activeParallellMap : activeMap;
|
|
50
|
+
const tree = useBasemapTree(engine, componentId);
|
|
51
|
+
const activeBasemap = engine === "3d" ? activeBasemap3d : activeBasemap2d;
|
|
52
|
+
const basemapOpacity = engine === "3d" ? opacity3d : opacity2d;
|
|
53
|
+
const failedBasemap = engine === "3d" ? failedBasemap3d : failedBasemap2d;
|
|
54
|
+
const setActiveBasemap = useBasemapStore((s) => s.setActiveBasemap);
|
|
55
|
+
const setBasemapOpacity = useBasemapStore((s) => s.setBasemapOpacity);
|
|
56
|
+
const t = useComponentTranslate(BASEMAP_COMPONENT_ID);
|
|
57
|
+
const tRoot = useTranslate();
|
|
58
|
+
const activeNode = resolveActiveBasemapNode(tree, activeBasemap);
|
|
59
|
+
const availability = useBasemapAvailability(engine);
|
|
60
|
+
const handleSelect = (id) => {
|
|
61
|
+
setActiveBasemap(id, engine);
|
|
62
|
+
};
|
|
63
|
+
const handleOpacityChange = (opacity) => {
|
|
64
|
+
setBasemapOpacity(opacity, engine);
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { "data-testid": "basemap", children: /* @__PURE__ */ jsx(
|
|
67
|
+
BaseMapSelection,
|
|
68
|
+
{
|
|
69
|
+
transparency: basemapOpacity,
|
|
70
|
+
onTransparencyChange: handleOpacityChange,
|
|
71
|
+
id: "basemap-button",
|
|
72
|
+
title: t("title"),
|
|
73
|
+
multiple: tree.length > 1,
|
|
74
|
+
showTransparency: true,
|
|
75
|
+
content: /* @__PURE__ */ jsx(
|
|
76
|
+
BasemapIcon,
|
|
77
|
+
{
|
|
78
|
+
alt: "Selected base map",
|
|
79
|
+
src: activeNode ? basemapNodeIcon(activeNode) : void 0
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
children: tree.map((node) => {
|
|
83
|
+
const id = node.id;
|
|
84
|
+
const status = availability.get(id);
|
|
85
|
+
const disabled = Boolean(status && !status.available && !status.pending);
|
|
86
|
+
const tooltip = optionTooltip(status, id === failedBasemap, t);
|
|
87
|
+
const title = nodeTitle(node, tRoot);
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
BaseMapSelection.Option,
|
|
90
|
+
{
|
|
91
|
+
content: /* @__PURE__ */ jsx(BasemapIcon, { alt: id, src: basemapNodeIcon(node) }),
|
|
92
|
+
title,
|
|
93
|
+
id,
|
|
94
|
+
disabled,
|
|
95
|
+
multiple: node.kind === "folder",
|
|
96
|
+
selected: id === activeBasemap,
|
|
97
|
+
tooltipText: tooltip,
|
|
98
|
+
tooltipType: "error",
|
|
99
|
+
onSelect: () => {
|
|
100
|
+
handleSelect(id);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
id
|
|
104
|
+
);
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
) }) });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const title$1 = "Base maps";
|
|
111
|
+
const enMessages$5 = {
|
|
112
|
+
title: title$1,
|
|
113
|
+
"unavailable.crsUnsupported": "Not available in 3D",
|
|
114
|
+
"unavailable.capabilitiesFailed": "Base map service is unavailable",
|
|
115
|
+
"unavailable.outOfScale": "Unavailable at the current zoom level",
|
|
116
|
+
"unavailable.layerUnavailable": "Base map could not be loaded",
|
|
117
|
+
"unavailable.serviceError": "Map service has errors",
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const title = "Aluskaardid";
|
|
121
|
+
const etMessages$5 = {
|
|
122
|
+
title,
|
|
123
|
+
"unavailable.crsUnsupported": "Aluskaart ei toeta 3D vaadet",
|
|
124
|
+
"unavailable.capabilitiesFailed": "Kaarditeenus ei ole kättesaadav",
|
|
125
|
+
"unavailable.outOfScale": "Aluskaart ei ole nähtavusulatuses",
|
|
126
|
+
"unavailable.layerUnavailable": "Aluskaardi laadimine ebaõnnestus",
|
|
127
|
+
"unavailable.serviceError": "Kaarditeenuses esineb tõrkeid",
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const BasemapComponent = {
|
|
131
|
+
id: BASEMAP_COMPONENT_ID,
|
|
132
|
+
messages: {
|
|
133
|
+
et: etMessages$5,
|
|
134
|
+
en: enMessages$5
|
|
135
|
+
},
|
|
136
|
+
ui: {
|
|
137
|
+
[SLOTS.BASEMAPS]: { Component: BasemapView }
|
|
138
|
+
},
|
|
139
|
+
bookmark: {
|
|
140
|
+
serialize: () => {
|
|
141
|
+
const state = useBasemapStore.getState();
|
|
142
|
+
return {
|
|
143
|
+
render: true,
|
|
144
|
+
settings: {
|
|
145
|
+
activeBasemap2d: state.activeBasemap2d,
|
|
146
|
+
activeBasemap3d: state.activeBasemap3d
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
deserialize: (data) => {
|
|
151
|
+
const settings = data.settings;
|
|
152
|
+
if (!settings) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const { setActiveBasemap } = useBasemapStore.getState();
|
|
156
|
+
if (settings.activeBasemap2d) {
|
|
157
|
+
setActiveBasemap(settings.activeBasemap2d, "2d");
|
|
158
|
+
}
|
|
159
|
+
if (settings.activeBasemap3d) {
|
|
160
|
+
setActiveBasemap(settings.activeBasemap3d, "3d");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const panel = "_panel_15hft_1";
|
|
167
|
+
const styles$3 = {
|
|
168
|
+
panel: panel
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const enMessages$4 = {
|
|
172
|
+
"tabs.aria": "Layer views",
|
|
173
|
+
"tabs.topic": "Theme map",
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const etMessages$4 = {
|
|
177
|
+
"tabs.aria": "Kihtide vaated",
|
|
178
|
+
"tabs.topic": "Teemakaart",
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
function SidePanelView(_props) {
|
|
182
|
+
const layout = useLayoutStore((s) => s.mode);
|
|
183
|
+
if (layout === "mobile") {
|
|
184
|
+
return /* @__PURE__ */ jsx(MobileSidePanel, {});
|
|
185
|
+
}
|
|
186
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
187
|
+
/* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.TOPICLIST }),
|
|
188
|
+
/* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.LAYERS }),
|
|
189
|
+
/* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.BOOKMARKS })
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const SIDE_PANEL_SLOTS = {
|
|
194
|
+
LAYERS: "xgis.sidePanel.layers",
|
|
195
|
+
BOOKMARKS: "xgis.sidePanel.bookmarks",
|
|
196
|
+
TOPICLIST: "xgis.sidePanel.topiclist"
|
|
197
|
+
};
|
|
198
|
+
const SidePanelComponent = {
|
|
199
|
+
id: SIDEPANEL_COMPONENT_ID,
|
|
200
|
+
messages: {
|
|
201
|
+
et: etMessages$4,
|
|
202
|
+
en: enMessages$4
|
|
203
|
+
},
|
|
204
|
+
ui: {
|
|
205
|
+
[SLOTS.SIDE_PANEL]: { Component: SidePanelView }
|
|
206
|
+
},
|
|
207
|
+
slots: [
|
|
208
|
+
{ id: SIDE_PANEL_SLOTS.LAYERS, description: "Layer list area" },
|
|
209
|
+
{ id: SIDE_PANEL_SLOTS.BOOKMARKS, description: "Bookmarks area" },
|
|
210
|
+
{ id: SIDE_PANEL_SLOTS.TOPICLIST, description: "Topic list area" }
|
|
211
|
+
]
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const TOPIC_TAB_ID = "side-panel-topic";
|
|
215
|
+
function MobileSidePanel() {
|
|
216
|
+
const isTopicPickerOpen = useUiStore((s) => s.topicPickerOpen);
|
|
217
|
+
const topics = useTopicStore((s) => s.topics);
|
|
218
|
+
const activeTopicId = useTopicStore((s) => s.activeTopicId);
|
|
219
|
+
const t = useComponentTranslate(SIDEPANEL_COMPONENT_ID);
|
|
220
|
+
if (isTopicPickerOpen) {
|
|
221
|
+
return /* @__PURE__ */ jsx("div", { className: styles$3.panel, "data-testid": "mobile-side-panel", children: /* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.TOPICLIST }) });
|
|
222
|
+
}
|
|
223
|
+
const activeTopicTitle = topics.find((topic) => topic.id === activeTopicId)?.title;
|
|
224
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$3.panel, "data-testid": "mobile-side-panel", children: [
|
|
225
|
+
/* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.TOPICLIST }),
|
|
226
|
+
/* @__PURE__ */ jsxs(Tabs, { defaultValue: TOPIC_TAB_ID, children: [
|
|
227
|
+
/* @__PURE__ */ jsx(Tabs.List, { "aria-label": t("tabs.aria"), overflowMode: "scroll", children: /* @__PURE__ */ jsx(Tabs.Trigger, { id: TOPIC_TAB_ID, children: activeTopicTitle ?? t("tabs.topic") }) }),
|
|
228
|
+
/* @__PURE__ */ jsxs(Tabs.Content, { id: TOPIC_TAB_ID, children: [
|
|
229
|
+
/* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.LAYERS }),
|
|
230
|
+
/* @__PURE__ */ jsx(Slot, { id: SIDE_PANEL_SLOTS.BOOKMARKS })
|
|
231
|
+
] })
|
|
232
|
+
] })
|
|
233
|
+
] });
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const layers$1 = "Layers";
|
|
237
|
+
const enMessages$3 = {
|
|
238
|
+
layers: layers$1,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const layers = "Kihid";
|
|
242
|
+
const etMessages$3 = {
|
|
243
|
+
layers,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const layerList = "_layerList_tas8u_3";
|
|
247
|
+
const layerRow = "_layerRow_tas8u_11";
|
|
248
|
+
const styles$2 = {
|
|
249
|
+
layerList: layerList,
|
|
250
|
+
layerRow: layerRow
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
function layerLabel(layer, t) {
|
|
254
|
+
const key = layerKey(layer.fatLayerId ?? layer.id, "name.label");
|
|
255
|
+
const label = t(key);
|
|
256
|
+
return !label || label === key ? layer.id : label;
|
|
257
|
+
}
|
|
258
|
+
function filterByMode(layers, mode) {
|
|
259
|
+
return layers.filter((l) => {
|
|
260
|
+
if (mode === "parallel" || !l.supportedEngines) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
const engine = mode === "2d" ? "2d" : "3d";
|
|
264
|
+
return l.supportedEngines.includes(engine);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function LayerPanelView(_props) {
|
|
268
|
+
const mode = useMapViewStore((s) => s.mode);
|
|
269
|
+
const layers = useLayerStore((s) => s.layers);
|
|
270
|
+
const setLayerVisibility = useLayerStore((s) => s.setLayerVisibility);
|
|
271
|
+
const t = useComponentTranslate(LAYERPANEL_COMPONENT_ID);
|
|
272
|
+
const tRoot = useTranslate();
|
|
273
|
+
const displayLayers = filterByMode(layers, mode);
|
|
274
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": "layer-panel", children: /* @__PURE__ */ jsx(MapAccordion, { defaultOpenItem: ["kihid"], children: /* @__PURE__ */ jsxs(MapAccordion.Item, { id: "kihid", children: [
|
|
275
|
+
/* @__PURE__ */ jsx(MapAccordion.Header, { title: t("layers") }),
|
|
276
|
+
/* @__PURE__ */ jsx(MapAccordion.Content, { children: /* @__PURE__ */ jsx("div", { className: styles$2.layerList, children: displayLayers.map((layer) => {
|
|
277
|
+
const label = layerLabel(layer, tRoot);
|
|
278
|
+
return /* @__PURE__ */ jsx("div", { className: styles$2.layerRow, "data-layer-id": layer.id, children: /* @__PURE__ */ jsx(
|
|
279
|
+
Toggle,
|
|
280
|
+
{
|
|
281
|
+
id: layer.id,
|
|
282
|
+
label,
|
|
283
|
+
labelPosition: "right",
|
|
284
|
+
checked: layer.visible,
|
|
285
|
+
onChange: (checked) => {
|
|
286
|
+
setLayerVisibility(layer.id, checked);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
) }, layer.id);
|
|
290
|
+
}) }) })
|
|
291
|
+
] }) }) });
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const LayerPanelComponent = {
|
|
295
|
+
id: LAYERPANEL_COMPONENT_ID,
|
|
296
|
+
messages: {
|
|
297
|
+
et: etMessages$3,
|
|
298
|
+
en: enMessages$3
|
|
299
|
+
},
|
|
300
|
+
contributions: [{ target: SIDE_PANEL_SLOTS.LAYERS, Component: LayerPanelView }],
|
|
301
|
+
bookmark: {
|
|
302
|
+
serialize: () => ({ render: true }),
|
|
303
|
+
deserialize: () => void 0
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const ariaLabel$1 = "Map mode";
|
|
308
|
+
const parallel$1 = "Parallel view";
|
|
309
|
+
const enMessages$2 = {
|
|
310
|
+
ariaLabel: ariaLabel$1,
|
|
311
|
+
"2d": "2D",
|
|
312
|
+
"3d": "3D",
|
|
313
|
+
parallel: parallel$1,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const ariaLabel = "Kaardirežiim";
|
|
317
|
+
const parallel = "Paralleelvaade";
|
|
318
|
+
const etMessages$2 = {
|
|
319
|
+
ariaLabel,
|
|
320
|
+
"2d": "2D",
|
|
321
|
+
"3d": "3D",
|
|
322
|
+
parallel,
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
function MapSwitchDesktop() {
|
|
326
|
+
const t = useComponentTranslate(MAPSWITCH_COMPONENT_ID);
|
|
327
|
+
const mode = useMapViewStore((s) => s.mode);
|
|
328
|
+
const setMode = useMapViewStore((s) => s.setMode);
|
|
329
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": "map-switch-desktop", style: { display: "contents" }, children: /* @__PURE__ */ jsx(ButtonGroup, { ariaLabel: t("ariaLabel"), children: MODES.map((value) => /* @__PURE__ */ jsx(
|
|
330
|
+
Button,
|
|
331
|
+
{
|
|
332
|
+
id: value,
|
|
333
|
+
isActive: mode === value,
|
|
334
|
+
onClick: () => setMode(value),
|
|
335
|
+
iconLeft: value === "parallel" ? "split_scene" : void 0,
|
|
336
|
+
children: /* @__PURE__ */ jsx("span", { "data-testid": `map-switch-mode-${value}`, children: t(value) })
|
|
337
|
+
},
|
|
338
|
+
value
|
|
339
|
+
)) }) });
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function MapSwitchMobile() {
|
|
343
|
+
const t = useComponentTranslate(MAPSWITCH_COMPONENT_ID);
|
|
344
|
+
const mode = useMapViewStore((s) => s.mode);
|
|
345
|
+
const setMode = useMapViewStore((s) => s.setMode);
|
|
346
|
+
const isParallel = mode === "parallel";
|
|
347
|
+
const modeItems = MODES.map((value) => ({
|
|
348
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
349
|
+
value === "parallel" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
350
|
+
/* @__PURE__ */ jsx(Icon, { name: "split_scene_2", size: 16, display: "inline" }),
|
|
351
|
+
" "
|
|
352
|
+
] }) : null,
|
|
353
|
+
/* @__PURE__ */ jsx("span", { "data-testid": `map-switch-mode-${value}`, children: t(value) })
|
|
354
|
+
] }),
|
|
355
|
+
isActive: value === mode,
|
|
356
|
+
onClick: () => setMode(value)
|
|
357
|
+
}));
|
|
358
|
+
return /* @__PURE__ */ jsx(
|
|
359
|
+
MapButton,
|
|
360
|
+
{
|
|
361
|
+
size: "small",
|
|
362
|
+
hideLabel: isParallel,
|
|
363
|
+
icon: isParallel ? "split_scene_2" : void 0,
|
|
364
|
+
dropdownItems: modeItems,
|
|
365
|
+
"data-testid": "map-switch-mobile",
|
|
366
|
+
children: /* @__PURE__ */ jsx("span", { "data-testid": "map-switch-mobile-trigger", children: t(mode) })
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const MODES = ["2d", "3d", "parallel"];
|
|
372
|
+
function MapSwitchButtons({ layout }) {
|
|
373
|
+
const mapModeConfig = useConfigStore((s) => s.config?.mapMode) ?? "both";
|
|
374
|
+
if (mapModeConfig !== "both") {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
if (layout === "mobile") {
|
|
378
|
+
return /* @__PURE__ */ jsx(MapSwitchMobile, {});
|
|
379
|
+
}
|
|
380
|
+
return /* @__PURE__ */ jsx(MapSwitchDesktop, {});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const MapSwitchComponent = {
|
|
384
|
+
id: MAPSWITCH_COMPONENT_ID,
|
|
385
|
+
messages: {
|
|
386
|
+
et: etMessages$2,
|
|
387
|
+
en: enMessages$2
|
|
388
|
+
},
|
|
389
|
+
ui: {
|
|
390
|
+
[SLOTS.MAP_SWITCH]: { Component: MapSwitchButtons }
|
|
391
|
+
},
|
|
392
|
+
bookmark: {
|
|
393
|
+
serialize: () => ({ render: true }),
|
|
394
|
+
deserialize: () => void 0
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const compassIconUrl = "data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_604_38579)'%3e%3cpath%20d='M14.1209%2014.1214L9.8783%209.87872L17.6565%206.34318L14.1209%2014.1214Z'%20fill='%23005AA3'/%3e%3cpath%20d='M13.0609%2013.0607L9.1718%2014.8285L10.9396%2010.9394L9.87891%209.87872L6.34337%2017.6569L14.1215%2014.1214L13.0609%2013.0607Z'%20fill='%23005AA3'/%3e%3cpath%20d='M4.22183%2019.7782C-0.0667771%2015.4896%20-0.0667774%208.51044%204.22183%204.22184C8.51043%20-0.0667636%2015.4896%20-0.0667636%2019.7782%204.22184C24.0668%208.51044%2024.0668%2015.4896%2019.7782%2019.7782C15.4896%2024.0668%208.51043%2024.0668%204.22183%2019.7782ZM18.364%205.63605C14.8553%202.12739%209.1447%202.12739%205.63604%205.63605C2.12667%209.14542%202.12738%2014.8553%205.63604%2018.364C9.14541%2021.8733%2014.8546%2021.8733%2018.364%2018.364C21.8726%2014.8553%2021.8733%209.14542%2018.364%205.63605Z'%20fill='%23005AA3'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_604_38579'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
|
|
399
|
+
|
|
400
|
+
const FULL_CIRCLE_DEGREES = 360;
|
|
401
|
+
const COMPASS_ICON_REST_OFFSET_DEGREES = 45;
|
|
402
|
+
function rotationToCompassDegrees(rotation) {
|
|
403
|
+
const degrees = Math.round(rotation * RADIANS_TO_DEGREES);
|
|
404
|
+
return wrapToRange(degrees, FULL_CIRCLE_DEGREES);
|
|
405
|
+
}
|
|
406
|
+
function compassIconRotationDegrees(compassDegrees) {
|
|
407
|
+
return compassDegrees - COMPASS_ICON_REST_OFFSET_DEGREES;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function useLiveRotation() {
|
|
411
|
+
const settled = useMapViewStore((s) => s.rotation);
|
|
412
|
+
const camera2d = useCapability("camera", "2d");
|
|
413
|
+
const camera3d = useCapability("camera", "3d");
|
|
414
|
+
const [live, setLive] = useState(settled);
|
|
415
|
+
const [prevSettled, setPrevSettled] = useState(settled);
|
|
416
|
+
if (settled !== prevSettled) {
|
|
417
|
+
setPrevSettled(settled);
|
|
418
|
+
setLive(settled);
|
|
419
|
+
}
|
|
420
|
+
useEffect(() => {
|
|
421
|
+
const onRotation = (rotation) => {
|
|
422
|
+
if (Number.isFinite(rotation)) {
|
|
423
|
+
setLive(rotation);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const unsubs = [];
|
|
427
|
+
if (camera2d) {
|
|
428
|
+
unsubs.push(camera2d.onRotationChange(onRotation));
|
|
429
|
+
}
|
|
430
|
+
if (camera3d) {
|
|
431
|
+
unsubs.push(camera3d.onRotationChange(onRotation));
|
|
432
|
+
}
|
|
433
|
+
return () => {
|
|
434
|
+
unsubs.forEach((unsub) => unsub());
|
|
435
|
+
};
|
|
436
|
+
}, [camera2d, camera3d]);
|
|
437
|
+
return live;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const compassIcon = "_compassIcon_xk9dx_1";
|
|
441
|
+
const menuIcon = "_menuIcon_xk9dx_7";
|
|
442
|
+
const styles$1 = {
|
|
443
|
+
compassIcon: compassIcon,
|
|
444
|
+
menuIcon: menuIcon
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
const NORTH_ROTATION = 0;
|
|
448
|
+
const TOP_DOWN_PITCH = -Math.PI / 2;
|
|
449
|
+
const NORTH_ICON_REST_ROTATION_DEG = compassIconRotationDegrees(0);
|
|
450
|
+
function CompassButtons(_props) {
|
|
451
|
+
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
452
|
+
const rotation = useLiveRotation();
|
|
453
|
+
const defaultView = useMapViewStore((s) => s.defaultView);
|
|
454
|
+
const { available, coupled, toggle } = useParallelViewSync();
|
|
455
|
+
const compassDeg = rotationToCompassDegrees(rotation);
|
|
456
|
+
const restoreInitialView = () => {
|
|
457
|
+
const { rotation: rotation2, pitch } = defaultView;
|
|
458
|
+
if (defaultView.kind === "fit") {
|
|
459
|
+
useMapViewStore.setState({ rotation: rotation2, pitch, fitBboxIntent: { bbox: defaultView.bbox } });
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
useMapViewStore.setState({
|
|
463
|
+
rotation: rotation2,
|
|
464
|
+
pitch,
|
|
465
|
+
zoomToIntent: { center: defaultView.center, zoom: defaultView.zoom }
|
|
466
|
+
});
|
|
467
|
+
};
|
|
468
|
+
const resetNorth = () => {
|
|
469
|
+
useMapViewStore.setState({ rotation: NORTH_ROTATION, pitch: TOP_DOWN_PITCH });
|
|
470
|
+
};
|
|
471
|
+
const northMenuItems = available ? [
|
|
472
|
+
{
|
|
473
|
+
children: /* @__PURE__ */ jsxs(Text, { element: "span", children: [
|
|
474
|
+
/* @__PURE__ */ jsx(
|
|
475
|
+
"span",
|
|
476
|
+
{
|
|
477
|
+
"aria-hidden": "true",
|
|
478
|
+
className: styles$1.menuIcon,
|
|
479
|
+
style: {
|
|
480
|
+
"--menu-icon-url": `url("${compassIconUrl}")`,
|
|
481
|
+
transform: `rotate(${NORTH_ICON_REST_ROTATION_DEG}deg)`
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
),
|
|
485
|
+
" ",
|
|
486
|
+
/* @__PURE__ */ jsx("span", { "data-testid": "nav-restore-north", children: t("restoreNorth") })
|
|
487
|
+
] }),
|
|
488
|
+
onClick: resetNorth
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
children: /* @__PURE__ */ jsxs(Text, { element: "span", children: [
|
|
492
|
+
/* @__PURE__ */ jsx(
|
|
493
|
+
Icon,
|
|
494
|
+
{
|
|
495
|
+
name: coupled ? "lock_open" : "lock",
|
|
496
|
+
size: 16,
|
|
497
|
+
display: "inline",
|
|
498
|
+
color: "inherit"
|
|
499
|
+
}
|
|
500
|
+
),
|
|
501
|
+
" ",
|
|
502
|
+
/* @__PURE__ */ jsx("span", { "data-testid": "nav-view-sync-toggle", children: coupled ? t("decoupleViews") : t("coupleViews") })
|
|
503
|
+
] }),
|
|
504
|
+
onClick: toggle
|
|
505
|
+
}
|
|
506
|
+
] : void 0;
|
|
507
|
+
return /* @__PURE__ */ jsxs(
|
|
508
|
+
ButtonGroup$1,
|
|
509
|
+
{
|
|
510
|
+
direction: "vertical",
|
|
511
|
+
ariaLabel: t("orientationControls"),
|
|
512
|
+
suffix: `${compassDeg}°`,
|
|
513
|
+
children: [
|
|
514
|
+
/* @__PURE__ */ jsx(
|
|
515
|
+
MapButton,
|
|
516
|
+
{
|
|
517
|
+
size: "small",
|
|
518
|
+
hideLabel: true,
|
|
519
|
+
icon: "restart_alt",
|
|
520
|
+
onClick: restoreInitialView,
|
|
521
|
+
"data-testid": "nav-default-view",
|
|
522
|
+
children: t("defaultView")
|
|
523
|
+
}
|
|
524
|
+
),
|
|
525
|
+
/* @__PURE__ */ jsx(
|
|
526
|
+
MapButton,
|
|
527
|
+
{
|
|
528
|
+
size: "small",
|
|
529
|
+
hideLabel: true,
|
|
530
|
+
icon: "explore",
|
|
531
|
+
onClick: available ? void 0 : resetNorth,
|
|
532
|
+
dropdownItems: northMenuItems,
|
|
533
|
+
"data-testid": "nav-north",
|
|
534
|
+
className: styles$1.compassIcon,
|
|
535
|
+
style: {
|
|
536
|
+
"--compass-rotation": `${compassIconRotationDegrees(compassDeg)}deg`,
|
|
537
|
+
"--compass-icon-url": `url("${compassIconUrl}")`
|
|
538
|
+
},
|
|
539
|
+
children: available ? t("north") : t("restoreNorth")
|
|
540
|
+
}
|
|
541
|
+
)
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function useNavigationHistory() {
|
|
548
|
+
const mode = useMapViewStore((s) => s.mode);
|
|
549
|
+
const parallelPrimary = useMapViewStore((s) => s.parallelPrimary);
|
|
550
|
+
const engine = activeEngine(mode, parallelPrimary);
|
|
551
|
+
const stack = useNavigationHistoryStore((s) => s.stacks[engine]);
|
|
552
|
+
const canGoBack = stack.pointer > 0;
|
|
553
|
+
const canGoForward = stack.pointer < stack.entries.length - 1;
|
|
554
|
+
const replayTo = useCallback(
|
|
555
|
+
(target) => {
|
|
556
|
+
const { stacks, moveTo, setReplayPending } = useNavigationHistoryStore.getState();
|
|
557
|
+
const entry = stacks[engine].entries[target];
|
|
558
|
+
if (entry === void 0) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
const center = extentCenter(entry.bbox);
|
|
562
|
+
setReplayPending(true);
|
|
563
|
+
for (const member of selectSyncedGroup(useMapViewStore.getState())) {
|
|
564
|
+
moveTo(member, target);
|
|
565
|
+
}
|
|
566
|
+
useMapViewStore.setState({
|
|
567
|
+
rotation: entry.rotation,
|
|
568
|
+
pitch: entry.pitch,
|
|
569
|
+
zoomToIntent: { center, zoom: entry.zoom }
|
|
570
|
+
});
|
|
571
|
+
},
|
|
572
|
+
[engine]
|
|
573
|
+
);
|
|
574
|
+
const back = useCallback(() => {
|
|
575
|
+
const current = useNavigationHistoryStore.getState().stacks[engine];
|
|
576
|
+
if (current.pointer <= 0) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
replayTo(current.pointer - 1);
|
|
580
|
+
}, [engine, replayTo]);
|
|
581
|
+
const forward = useCallback(() => {
|
|
582
|
+
const current = useNavigationHistoryStore.getState().stacks[engine];
|
|
583
|
+
if (current.pointer >= current.entries.length - 1) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
replayTo(current.pointer + 1);
|
|
587
|
+
}, [engine, replayTo]);
|
|
588
|
+
return { canGoBack, canGoForward, back, forward };
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function HistoryButtons(_props) {
|
|
592
|
+
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
593
|
+
const { canGoBack, canGoForward, back, forward } = useNavigationHistory();
|
|
594
|
+
return /* @__PURE__ */ jsxs(ButtonGroup$1, { direction: "vertical", ariaLabel: t("historyControls"), children: [
|
|
595
|
+
/* @__PURE__ */ jsx(
|
|
596
|
+
MapButton,
|
|
597
|
+
{
|
|
598
|
+
size: "small",
|
|
599
|
+
hideLabel: true,
|
|
600
|
+
icon: "arrow_back",
|
|
601
|
+
disabled: !canGoBack,
|
|
602
|
+
onClick: back,
|
|
603
|
+
"data-testid": "nav-history-back",
|
|
604
|
+
children: t("back")
|
|
605
|
+
}
|
|
606
|
+
),
|
|
607
|
+
/* @__PURE__ */ jsx(
|
|
608
|
+
MapButton,
|
|
609
|
+
{
|
|
610
|
+
size: "small",
|
|
611
|
+
hideLabel: true,
|
|
612
|
+
icon: "arrow_forward",
|
|
613
|
+
disabled: !canGoForward,
|
|
614
|
+
onClick: forward,
|
|
615
|
+
"data-testid": "nav-history-forward",
|
|
616
|
+
children: t("forward")
|
|
617
|
+
}
|
|
618
|
+
)
|
|
619
|
+
] });
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const zoomIn$1 = "Zoom in";
|
|
623
|
+
const zoomOut$1 = "Zoom out";
|
|
624
|
+
const back$3 = "Back";
|
|
625
|
+
const forward$1 = "Forward";
|
|
626
|
+
const myLocation$1 = "My location";
|
|
627
|
+
const trackLocation$1 = "Track location";
|
|
628
|
+
const north$1 = "North";
|
|
629
|
+
const defaultView$1 = "Default view";
|
|
630
|
+
const locationError$1 = "Location could not be determined";
|
|
631
|
+
const locationDenied$1 = "Location access was denied";
|
|
632
|
+
const locationOutsideBounds$1 = "Your location is outside the map area";
|
|
633
|
+
const zoomControls$1 = "Zoom controls";
|
|
634
|
+
const historyControls$1 = "Map navigation history";
|
|
635
|
+
const locationControls$1 = "Location controls";
|
|
636
|
+
const orientationControls$1 = "Map orientation controls";
|
|
637
|
+
const locationRationale$1 = "Your location is used only to centre the map on you. Your browser will ask for permission.";
|
|
638
|
+
const locationRationaleTooltip$1 = "Find your location";
|
|
639
|
+
const restoreNorth$1 = "Restore north";
|
|
640
|
+
const coupleViews$1 = "Lock map views";
|
|
641
|
+
const decoupleViews$1 = "Unlock";
|
|
642
|
+
const enMessages$1 = {
|
|
643
|
+
zoomIn: zoomIn$1,
|
|
644
|
+
zoomOut: zoomOut$1,
|
|
645
|
+
back: back$3,
|
|
646
|
+
forward: forward$1,
|
|
647
|
+
myLocation: myLocation$1,
|
|
648
|
+
trackLocation: trackLocation$1,
|
|
649
|
+
north: north$1,
|
|
650
|
+
defaultView: defaultView$1,
|
|
651
|
+
locationError: locationError$1,
|
|
652
|
+
locationDenied: locationDenied$1,
|
|
653
|
+
locationOutsideBounds: locationOutsideBounds$1,
|
|
654
|
+
zoomControls: zoomControls$1,
|
|
655
|
+
historyControls: historyControls$1,
|
|
656
|
+
locationControls: locationControls$1,
|
|
657
|
+
orientationControls: orientationControls$1,
|
|
658
|
+
locationRationale: locationRationale$1,
|
|
659
|
+
locationRationaleTooltip: locationRationaleTooltip$1,
|
|
660
|
+
restoreNorth: restoreNorth$1,
|
|
661
|
+
coupleViews: coupleViews$1,
|
|
662
|
+
decoupleViews: decoupleViews$1,
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
const zoomIn = "Suumi sisse";
|
|
666
|
+
const zoomOut = "Suumi välja";
|
|
667
|
+
const back$2 = "Navigeeri tagasi";
|
|
668
|
+
const forward = "Navigeeri edasi";
|
|
669
|
+
const myLocation = "Minu asukoht";
|
|
670
|
+
const trackLocation = "Jälgi asukohta";
|
|
671
|
+
const north = "Põhjasuund";
|
|
672
|
+
const defaultView = "Algvaade";
|
|
673
|
+
const locationError = "Asukoha tuvastamine ebaõnnestus";
|
|
674
|
+
const locationDenied = "Asukoha tuvastamine pole lubatud";
|
|
675
|
+
const locationOutsideBounds = "Teie asukoht on kaardialast väljaspool";
|
|
676
|
+
const zoomControls = "Suurendamise juhtnupud";
|
|
677
|
+
const historyControls = "Kaardi liikumise ajalugu";
|
|
678
|
+
const locationControls = "Asukoha juhtnupud";
|
|
679
|
+
const orientationControls = "Kaardi orientatsiooni juhtnupud";
|
|
680
|
+
const locationRationale = "Kasutame teie asukohta ainult selleks, et seada kaart teie juurde keskele. Brauser küsib selleks luba.";
|
|
681
|
+
const locationRationaleTooltip = "Positsioneeri";
|
|
682
|
+
const restoreNorth = "Taasta põhjasuund";
|
|
683
|
+
const coupleViews = "Lukusta kaardivaated";
|
|
684
|
+
const decoupleViews = "Lukusta lahti";
|
|
685
|
+
const etMessages$1 = {
|
|
686
|
+
zoomIn,
|
|
687
|
+
zoomOut,
|
|
688
|
+
back: back$2,
|
|
689
|
+
forward,
|
|
690
|
+
myLocation,
|
|
691
|
+
trackLocation,
|
|
692
|
+
north,
|
|
693
|
+
defaultView,
|
|
694
|
+
locationError,
|
|
695
|
+
locationDenied,
|
|
696
|
+
locationOutsideBounds,
|
|
697
|
+
zoomControls,
|
|
698
|
+
historyControls,
|
|
699
|
+
locationControls,
|
|
700
|
+
orientationControls,
|
|
701
|
+
locationRationale,
|
|
702
|
+
locationRationaleTooltip,
|
|
703
|
+
restoreNorth,
|
|
704
|
+
coupleViews,
|
|
705
|
+
decoupleViews,
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
const PERMISSION_DENIED = 1;
|
|
709
|
+
const MOVEMENT_THRESHOLD = 1e-4;
|
|
710
|
+
function hasMovedEnough(previous, next) {
|
|
711
|
+
return !previous || Math.abs(previous.lon - next.lon) > MOVEMENT_THRESHOLD || Math.abs(previous.lat - next.lat) > MOVEMENT_THRESHOLD;
|
|
712
|
+
}
|
|
713
|
+
function headingToRotation(headingDegrees) {
|
|
714
|
+
return -headingDegrees * DEGREES_TO_RADIANS;
|
|
715
|
+
}
|
|
716
|
+
function geolocationErrorMessage(error) {
|
|
717
|
+
const key = error.code === PERMISSION_DENIED ? "locationDenied" : "locationError";
|
|
718
|
+
return translate(componentKey(NAVIGATION_COMPONENT_ID, key));
|
|
719
|
+
}
|
|
720
|
+
function constrainToBounds(position, constraintBbox) {
|
|
721
|
+
if (!constraintBbox) {
|
|
722
|
+
return { position, outsideBounds: false };
|
|
723
|
+
}
|
|
724
|
+
const point = wgs84ToEpsg3301(position);
|
|
725
|
+
if (containsPoint(point, constraintBbox)) {
|
|
726
|
+
return { position, outsideBounds: false };
|
|
727
|
+
}
|
|
728
|
+
const [x, y] = clampPointToBounds(point, constraintBbox);
|
|
729
|
+
return { position: epsg3301ToWgs84(x, y), outsideBounds: true };
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const LOCATE_ZOOM = 14;
|
|
733
|
+
const RATIONALE_FLAG = "xgis.gpsRationaleShown";
|
|
734
|
+
function hasShownRationale() {
|
|
735
|
+
try {
|
|
736
|
+
return localStorage.getItem(RATIONALE_FLAG) === "true";
|
|
737
|
+
} catch {
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function markRationaleShown() {
|
|
742
|
+
try {
|
|
743
|
+
localStorage.setItem(RATIONALE_FLAG, "true");
|
|
744
|
+
} catch {
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function useGeolocation() {
|
|
748
|
+
const isLocated = useGeolocationStore((s) => s.isLocated);
|
|
749
|
+
const isTracking = useGeolocationStore((s) => s.isTracking);
|
|
750
|
+
const emit = useMapBusEmit();
|
|
751
|
+
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
752
|
+
const setMarker = useUserMarkerStore((s) => s.setMarker);
|
|
753
|
+
const trackingOutsideBounds = useRef(false);
|
|
754
|
+
const resolvePosition = useCallback(
|
|
755
|
+
(position) => {
|
|
756
|
+
const constraintBbox = useMapViewStore.getState().constraintBbox;
|
|
757
|
+
const { position: bounded, outsideBounds } = constrainToBounds(position, constraintBbox);
|
|
758
|
+
if (outsideBounds && !trackingOutsideBounds.current) {
|
|
759
|
+
emit("showToast", { message: t("locationOutsideBounds"), severity: "error" });
|
|
760
|
+
}
|
|
761
|
+
trackingOutsideBounds.current = outsideBounds;
|
|
762
|
+
return bounded;
|
|
763
|
+
},
|
|
764
|
+
[emit, t]
|
|
765
|
+
);
|
|
766
|
+
const showRationaleOnce = useCallback(() => {
|
|
767
|
+
if (hasShownRationale()) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
emit("showToast", { message: t("locationRationale"), severity: "info" });
|
|
771
|
+
markRationaleShown();
|
|
772
|
+
}, [emit, t]);
|
|
773
|
+
const stopWatch = useCallback(() => {
|
|
774
|
+
const watchId = useGeolocationStore.getState().watchId;
|
|
775
|
+
if (watchId !== null) {
|
|
776
|
+
navigator.geolocation.clearWatch(watchId);
|
|
777
|
+
useGeolocationStore.getState().setWatchId(null);
|
|
778
|
+
}
|
|
779
|
+
}, []);
|
|
780
|
+
const deactivate = useCallback(() => {
|
|
781
|
+
stopWatch();
|
|
782
|
+
useGeolocationStore.getState().setPrevPosition(null);
|
|
783
|
+
setMarker(null);
|
|
784
|
+
useNavigationHistoryStore.getState().setExternalControl(false);
|
|
785
|
+
useGeolocationStore.getState().setLocated(false);
|
|
786
|
+
useGeolocationStore.getState().setTracking(false);
|
|
787
|
+
}, [setMarker, stopWatch]);
|
|
788
|
+
const locate = useCallback(() => {
|
|
789
|
+
showRationaleOnce();
|
|
790
|
+
navigator.geolocation.getCurrentPosition(
|
|
791
|
+
({ coords }) => {
|
|
792
|
+
const position = { lon: coords.longitude, lat: coords.latitude };
|
|
793
|
+
trackingOutsideBounds.current = false;
|
|
794
|
+
const bounded = resolvePosition(position);
|
|
795
|
+
setMarker(position);
|
|
796
|
+
useMapViewStore.getState().flyToPosition(bounded, LOCATE_ZOOM);
|
|
797
|
+
useGeolocationStore.getState().setLocated(true);
|
|
798
|
+
},
|
|
799
|
+
(error) => {
|
|
800
|
+
emit("showToast", { message: geolocationErrorMessage(error), severity: "error" });
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
}, [emit, resolvePosition, setMarker, showRationaleOnce]);
|
|
804
|
+
const handleTrackingPosition = useCallback(
|
|
805
|
+
({ coords }) => {
|
|
806
|
+
const position = { lon: coords.longitude, lat: coords.latitude };
|
|
807
|
+
const bounded = resolvePosition(position);
|
|
808
|
+
setMarker(position);
|
|
809
|
+
const prevPosition = useGeolocationStore.getState().prevPosition;
|
|
810
|
+
const moved = hasMovedEnough(prevPosition, position);
|
|
811
|
+
const hasHeading = coords.heading !== null && !Number.isNaN(coords.heading);
|
|
812
|
+
if (!moved && !hasHeading) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
const next = {};
|
|
816
|
+
if (moved) {
|
|
817
|
+
next.flyToPositionIntent = { position: bounded, zoom: LOCATE_ZOOM };
|
|
818
|
+
}
|
|
819
|
+
if (hasHeading) {
|
|
820
|
+
next.rotation = headingToRotation(coords.heading);
|
|
821
|
+
}
|
|
822
|
+
useMapViewStore.setState(next);
|
|
823
|
+
if (moved) {
|
|
824
|
+
useGeolocationStore.getState().setPrevPosition(position);
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
[resolvePosition, setMarker]
|
|
828
|
+
);
|
|
829
|
+
const startTracking = useCallback(() => {
|
|
830
|
+
showRationaleOnce();
|
|
831
|
+
const watchId = navigator.geolocation.watchPosition(handleTrackingPosition);
|
|
832
|
+
useGeolocationStore.getState().setWatchId(watchId);
|
|
833
|
+
useNavigationHistoryStore.getState().setExternalControl(true);
|
|
834
|
+
useGeolocationStore.getState().setTracking(true);
|
|
835
|
+
}, [handleTrackingPosition, showRationaleOnce]);
|
|
836
|
+
const stopTracking = useCallback(() => {
|
|
837
|
+
stopWatch();
|
|
838
|
+
useNavigationHistoryStore.getState().setExternalControl(false);
|
|
839
|
+
useGeolocationStore.getState().setTracking(false);
|
|
840
|
+
}, [stopWatch]);
|
|
841
|
+
const toggleTracking = useCallback(() => {
|
|
842
|
+
if (isTracking) {
|
|
843
|
+
stopTracking();
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
startTracking();
|
|
847
|
+
}, [isTracking, startTracking, stopTracking]);
|
|
848
|
+
return {
|
|
849
|
+
isLocated,
|
|
850
|
+
isTracking,
|
|
851
|
+
locate,
|
|
852
|
+
toggleTracking,
|
|
853
|
+
deactivate
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function LocationButtons(_props) {
|
|
858
|
+
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
859
|
+
const { isLocated, isTracking, locate, toggleTracking, deactivate } = useGeolocation();
|
|
860
|
+
return /* @__PURE__ */ jsxs(ButtonGroup$1, { direction: "vertical", ariaLabel: t("locationControls"), children: [
|
|
861
|
+
/* @__PURE__ */ jsx(
|
|
862
|
+
MapButton,
|
|
863
|
+
{
|
|
864
|
+
size: "small",
|
|
865
|
+
hideLabel: true,
|
|
866
|
+
icon: "my_location",
|
|
867
|
+
tooltipContent: t("locationRationaleTooltip"),
|
|
868
|
+
isActive: isLocated,
|
|
869
|
+
onClick: isLocated ? deactivate : locate,
|
|
870
|
+
children: t("myLocation")
|
|
871
|
+
}
|
|
872
|
+
),
|
|
873
|
+
isLocated && /* @__PURE__ */ jsx(
|
|
874
|
+
MapButton,
|
|
875
|
+
{
|
|
876
|
+
size: "small",
|
|
877
|
+
hideLabel: true,
|
|
878
|
+
icon: "emergency_share",
|
|
879
|
+
isActive: isTracking,
|
|
880
|
+
onClick: toggleTracking,
|
|
881
|
+
children: t("trackLocation")
|
|
882
|
+
}
|
|
883
|
+
)
|
|
884
|
+
] });
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function ZoomButtons(_props) {
|
|
888
|
+
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
889
|
+
const zoom = useMapViewStore((s) => s.zoom);
|
|
890
|
+
const setZoom = useMapViewStore((s) => s.setZoom);
|
|
891
|
+
const zoomFloor = useZoomFloor();
|
|
892
|
+
return /* @__PURE__ */ jsxs(ButtonGroup$1, { direction: "vertical", ariaLabel: t("zoomControls"), children: [
|
|
893
|
+
/* @__PURE__ */ jsx(
|
|
894
|
+
MapButton,
|
|
895
|
+
{
|
|
896
|
+
size: "small",
|
|
897
|
+
hideLabel: true,
|
|
898
|
+
icon: "add",
|
|
899
|
+
disabled: zoom >= MAX_ZOOM,
|
|
900
|
+
onClick: () => setZoom(zoom + 1),
|
|
901
|
+
"data-testid": "nav-zoom-in",
|
|
902
|
+
children: t("zoomIn")
|
|
903
|
+
}
|
|
904
|
+
),
|
|
905
|
+
/* @__PURE__ */ jsx(
|
|
906
|
+
MapButton,
|
|
907
|
+
{
|
|
908
|
+
size: "small",
|
|
909
|
+
hideLabel: true,
|
|
910
|
+
icon: "remove",
|
|
911
|
+
disabled: zoom <= zoomFloor,
|
|
912
|
+
onClick: () => setZoom(Math.max(zoom - 1, zoomFloor)),
|
|
913
|
+
"data-testid": "nav-zoom-out",
|
|
914
|
+
children: t("zoomOut")
|
|
915
|
+
}
|
|
916
|
+
)
|
|
917
|
+
] });
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
const NavigationComponent = {
|
|
921
|
+
id: NAVIGATION_COMPONENT_ID,
|
|
922
|
+
messages: {
|
|
923
|
+
et: etMessages$1,
|
|
924
|
+
en: enMessages$1
|
|
925
|
+
},
|
|
926
|
+
ui: {
|
|
927
|
+
[SLOTS.NAVIGATION_ZOOM]: { Component: ZoomButtons },
|
|
928
|
+
[SLOTS.NAVIGATION_HISTORY]: { Component: HistoryButtons },
|
|
929
|
+
[SLOTS.NAVIGATION_LOCATION]: { Component: LocationButtons },
|
|
930
|
+
[SLOTS.NAVIGATION_COMPASS]: { Component: CompassButtons }
|
|
931
|
+
},
|
|
932
|
+
bookmark: {
|
|
933
|
+
serialize: () => ({ render: true }),
|
|
934
|
+
deserialize: () => void 0
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
const SEVERITY_TO_ALERT_TYPE = {
|
|
939
|
+
info: "info",
|
|
940
|
+
warning: "warning",
|
|
941
|
+
error: "danger"
|
|
942
|
+
};
|
|
943
|
+
function NotificationToasts(_props) {
|
|
944
|
+
useMapBusEvent(
|
|
945
|
+
"showToast",
|
|
946
|
+
useCallback(({ message, severity }) => {
|
|
947
|
+
sendNotification({ type: SEVERITY_TO_ALERT_TYPE[severity], children: message });
|
|
948
|
+
}, [])
|
|
949
|
+
);
|
|
950
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": "notification-toasts", style: { pointerEvents: "auto" }, children: /* @__PURE__ */ jsx(ToastContainer, {}) });
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
const NotificationComponent = {
|
|
954
|
+
id: NOTIFICATION_COMPONENT_ID,
|
|
955
|
+
alwaysOn: true,
|
|
956
|
+
ui: {
|
|
957
|
+
[SLOTS.OVERLAY]: { Component: NotificationToasts }
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
const label$1 = "Theme map";
|
|
962
|
+
const readMore$1 = "Read more";
|
|
963
|
+
const readLess$1 = "Close";
|
|
964
|
+
const back$1 = "Back";
|
|
965
|
+
const enMessages = {
|
|
966
|
+
label: label$1,
|
|
967
|
+
"search.label": "Search theme maps",
|
|
968
|
+
"search.placeholder": "Search",
|
|
969
|
+
"search.empty": "No theme maps found",
|
|
970
|
+
readMore: readMore$1,
|
|
971
|
+
readLess: readLess$1,
|
|
972
|
+
back: back$1,
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
const label = "Teemakaart";
|
|
976
|
+
const readMore = "Loe lisaks";
|
|
977
|
+
const readLess = "Sulge";
|
|
978
|
+
const back = "Tagasi";
|
|
979
|
+
const etMessages = {
|
|
980
|
+
label,
|
|
981
|
+
"search.label": "Otsi teemakaarti",
|
|
982
|
+
"search.placeholder": "Otsi",
|
|
983
|
+
"search.empty": "Ühtegi teemakaarti ei leitud",
|
|
984
|
+
readMore,
|
|
985
|
+
readLess,
|
|
986
|
+
back,
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
const menuPortal = "_menuPortal_mdk9k_1";
|
|
990
|
+
const trigger = "_trigger_mdk9k_5";
|
|
991
|
+
const picker = "_picker_mdk9k_9";
|
|
992
|
+
const pickerList = "_pickerList_mdk9k_16";
|
|
993
|
+
const pickerSearch = "_pickerSearch_mdk9k_22";
|
|
994
|
+
const pickerEmpty = "_pickerEmpty_mdk9k_26";
|
|
995
|
+
const row = "_row_mdk9k_30";
|
|
996
|
+
const rowActive = "_rowActive_mdk9k_35";
|
|
997
|
+
const rowOpenNotActive = "_rowOpenNotActive_mdk9k_39";
|
|
998
|
+
const rowDescription = "_rowDescription_mdk9k_53";
|
|
999
|
+
const pickerFooter = "_pickerFooter_mdk9k_57";
|
|
1000
|
+
const styles = {
|
|
1001
|
+
menuPortal: menuPortal,
|
|
1002
|
+
trigger: trigger,
|
|
1003
|
+
picker: picker,
|
|
1004
|
+
pickerList: pickerList,
|
|
1005
|
+
pickerSearch: pickerSearch,
|
|
1006
|
+
pickerEmpty: pickerEmpty,
|
|
1007
|
+
row: row,
|
|
1008
|
+
rowActive: rowActive,
|
|
1009
|
+
rowOpenNotActive: rowOpenNotActive,
|
|
1010
|
+
rowDescription: rowDescription,
|
|
1011
|
+
pickerFooter: pickerFooter
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
function rowBackground(isActive, isOpen) {
|
|
1015
|
+
if (isActive) {
|
|
1016
|
+
return "brand-primary";
|
|
1017
|
+
}
|
|
1018
|
+
if (isOpen) {
|
|
1019
|
+
return "brand-quaternary";
|
|
1020
|
+
}
|
|
1021
|
+
return "primary";
|
|
1022
|
+
}
|
|
1023
|
+
function rowClassName(isActive, isOpen) {
|
|
1024
|
+
if (!isActive && isOpen) {
|
|
1025
|
+
return `${styles.row} ${styles.rowOpenNotActive}`;
|
|
1026
|
+
}
|
|
1027
|
+
if (isActive) {
|
|
1028
|
+
return `${styles.row} ${styles.rowActive}`;
|
|
1029
|
+
}
|
|
1030
|
+
if (isOpen) {
|
|
1031
|
+
return `${styles.row} ${styles.rowOpen}`;
|
|
1032
|
+
}
|
|
1033
|
+
return styles.row;
|
|
1034
|
+
}
|
|
1035
|
+
function TopicRow({ topic, isActive, onSelect }) {
|
|
1036
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1037
|
+
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1038
|
+
const background = rowBackground(isActive, isOpen);
|
|
1039
|
+
const textColor = isActive ? "white" : "primary";
|
|
1040
|
+
const title = /* @__PURE__ */ jsx(CardButton, { onClick: () => onSelect(topic.id), children: /* @__PURE__ */ jsx(Card, { borderless: true, background, children: /* @__PURE__ */ jsx(Card.Content, { padding: { vertical: 0.75, horizontal: 1 }, background, children: /* @__PURE__ */ jsx(Text, { color: textColor, children: topic.title }) }) }) });
|
|
1041
|
+
if (!topic.description) {
|
|
1042
|
+
return /* @__PURE__ */ jsx("div", { className: rowClassName(isActive, false), "data-topic-id": topic.id, children: title });
|
|
1043
|
+
}
|
|
1044
|
+
return /* @__PURE__ */ jsx("div", { className: rowClassName(isActive, isOpen), "data-topic-id": topic.id, children: /* @__PURE__ */ jsx(
|
|
1045
|
+
Collapse,
|
|
1046
|
+
{
|
|
1047
|
+
id: `topic-description-${topic.id}`,
|
|
1048
|
+
title,
|
|
1049
|
+
open: isOpen,
|
|
1050
|
+
onToggle: setIsOpen,
|
|
1051
|
+
openText: t("readMore"),
|
|
1052
|
+
closeText: t("readLess"),
|
|
1053
|
+
inverted: isActive,
|
|
1054
|
+
underline: false,
|
|
1055
|
+
size: "small",
|
|
1056
|
+
children: /* @__PURE__ */ jsx("div", { className: styles.rowDescription, children: /* @__PURE__ */ jsx(Text, { color: textColor, modifiers: "small", children: topic.description }) })
|
|
1057
|
+
}
|
|
1058
|
+
) });
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
function filterTopics(topics, query) {
|
|
1062
|
+
const needle = query.trim().toLowerCase();
|
|
1063
|
+
if (!needle) {
|
|
1064
|
+
return [...topics];
|
|
1065
|
+
}
|
|
1066
|
+
return topics.filter((topic) => topic.title.toLowerCase().includes(needle));
|
|
1067
|
+
}
|
|
1068
|
+
function useFilteredTopics(query) {
|
|
1069
|
+
const topics = useTopicStore((s) => s.topics);
|
|
1070
|
+
return useMemo(() => filterTopics(topics, query), [topics, query]);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function TopicPicker() {
|
|
1074
|
+
const [query, setQuery] = useState("");
|
|
1075
|
+
const activeTopicId = useTopicStore((s) => s.activeTopicId);
|
|
1076
|
+
const setActiveTopicId = useTopicStore((s) => s.setActiveTopicId);
|
|
1077
|
+
const setTopicPickerOpen = useUiStore((s) => s.setTopicPickerOpen);
|
|
1078
|
+
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1079
|
+
const topics = useFilteredTopics(query);
|
|
1080
|
+
function handleSelect(topicId) {
|
|
1081
|
+
setActiveTopicId(topicId);
|
|
1082
|
+
setTopicPickerOpen(false);
|
|
1083
|
+
}
|
|
1084
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.picker, "data-testid": "topic-picker", children: [
|
|
1085
|
+
/* @__PURE__ */ jsx("div", { className: styles.pickerSearch, children: /* @__PURE__ */ jsx(
|
|
1086
|
+
TextField,
|
|
1087
|
+
{
|
|
1088
|
+
id: "topic-search",
|
|
1089
|
+
label: t("search.label"),
|
|
1090
|
+
hideLabel: true,
|
|
1091
|
+
placeholder: t("search.placeholder"),
|
|
1092
|
+
icon: "search",
|
|
1093
|
+
value: query,
|
|
1094
|
+
onChange: setQuery,
|
|
1095
|
+
isClearable: true
|
|
1096
|
+
}
|
|
1097
|
+
) }),
|
|
1098
|
+
/* @__PURE__ */ jsxs("div", { className: styles.pickerList, children: [
|
|
1099
|
+
topics.length === 0 && /* @__PURE__ */ jsx(Text, { color: "secondary", className: styles.pickerEmpty, children: t("search.empty") }),
|
|
1100
|
+
topics.map((topic) => /* @__PURE__ */ jsx(
|
|
1101
|
+
TopicRow,
|
|
1102
|
+
{
|
|
1103
|
+
topic,
|
|
1104
|
+
isActive: topic.id === activeTopicId,
|
|
1105
|
+
onSelect: handleSelect
|
|
1106
|
+
},
|
|
1107
|
+
topic.id
|
|
1108
|
+
))
|
|
1109
|
+
] }),
|
|
1110
|
+
/* @__PURE__ */ jsx("div", { className: styles.pickerFooter, children: /* @__PURE__ */ jsx(Button, { visualType: "link", iconLeft: "arrow_back", onClick: () => setTopicPickerOpen(false), children: t("back") }) })
|
|
1111
|
+
] });
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
function TopicSelect() {
|
|
1115
|
+
const topics = useTopicStore((s) => s.topics);
|
|
1116
|
+
const activeTopicId = useTopicStore((s) => s.activeTopicId);
|
|
1117
|
+
const setActiveTopicId = useTopicStore((s) => s.setActiveTopicId);
|
|
1118
|
+
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1119
|
+
const options = useMemo(
|
|
1120
|
+
() => topics.map((item) => ({
|
|
1121
|
+
value: item.id,
|
|
1122
|
+
label: item.title,
|
|
1123
|
+
customData: item
|
|
1124
|
+
})),
|
|
1125
|
+
[topics]
|
|
1126
|
+
);
|
|
1127
|
+
const selectedOption = useMemo(
|
|
1128
|
+
() => options.find((option) => option.value === activeTopicId) ?? null,
|
|
1129
|
+
[options, activeTopicId]
|
|
1130
|
+
);
|
|
1131
|
+
function handleChange(selected) {
|
|
1132
|
+
if (!selected) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
const option = selected;
|
|
1136
|
+
setActiveTopicId(option.value);
|
|
1137
|
+
}
|
|
1138
|
+
return /* @__PURE__ */ jsx(Card, { borderless: true, children: /* @__PURE__ */ jsx(Card.Content, { padding: 0.5, children: /* @__PURE__ */ jsx(Row, { gutterY: 2, children: /* @__PURE__ */ jsxs(Col, { children: [
|
|
1139
|
+
/* @__PURE__ */ jsx(Text, { color: "secondary", children: t("label") }),
|
|
1140
|
+
/* @__PURE__ */ jsx(
|
|
1141
|
+
Select,
|
|
1142
|
+
{
|
|
1143
|
+
value: selectedOption,
|
|
1144
|
+
options,
|
|
1145
|
+
id: "topic-list",
|
|
1146
|
+
label: "",
|
|
1147
|
+
onChange: handleChange,
|
|
1148
|
+
classNames: { menuPortal: styles.menuPortal }
|
|
1149
|
+
}
|
|
1150
|
+
)
|
|
1151
|
+
] }) }) }) });
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
function TopicTrigger() {
|
|
1155
|
+
const setTopicPickerOpen = useUiStore((s) => s.setTopicPickerOpen);
|
|
1156
|
+
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1157
|
+
return /* @__PURE__ */ jsx("div", { className: styles.trigger, "data-testid": "topic-trigger", children: /* @__PURE__ */ jsx(CardButton, { onClick: () => setTopicPickerOpen(true), children: /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Card.Content, { padding: 0.75, children: /* @__PURE__ */ jsxs(Row, { justifyContent: "between", alignItems: "center", wrap: "nowrap", children: [
|
|
1158
|
+
/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Text, { children: t("label") }) }),
|
|
1159
|
+
/* @__PURE__ */ jsx(Col, { width: "auto", children: /* @__PURE__ */ jsx(Icon, { name: "arrow_forward" }) })
|
|
1160
|
+
] }) }) }) }) });
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
function TopicListView(_props) {
|
|
1164
|
+
const layout = useLayoutStore((s) => s.mode);
|
|
1165
|
+
const isPickerOpen = useUiStore((s) => s.topicPickerOpen);
|
|
1166
|
+
if (layout !== "mobile") {
|
|
1167
|
+
return /* @__PURE__ */ jsx(TopicSelect, {});
|
|
1168
|
+
}
|
|
1169
|
+
if (isPickerOpen) {
|
|
1170
|
+
return /* @__PURE__ */ jsx(TopicPicker, {});
|
|
1171
|
+
}
|
|
1172
|
+
return /* @__PURE__ */ jsx(TopicTrigger, {});
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
const TopicListComponent = {
|
|
1176
|
+
id: TOPICLIST_COMPONENT_ID,
|
|
1177
|
+
messages: {
|
|
1178
|
+
et: etMessages,
|
|
1179
|
+
en: enMessages
|
|
1180
|
+
},
|
|
1181
|
+
contributions: [{ target: SIDE_PANEL_SLOTS.TOPICLIST, Component: TopicListView }],
|
|
1182
|
+
bookmark: {
|
|
1183
|
+
serialize: () => ({ render: true }),
|
|
1184
|
+
deserialize: () => void 0
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1188
|
+
const XGIS_COMPONENTS = [
|
|
1189
|
+
SidePanelComponent,
|
|
1190
|
+
LayerPanelComponent,
|
|
1191
|
+
MapSwitchComponent,
|
|
1192
|
+
NavigationComponent,
|
|
1193
|
+
TopicListComponent,
|
|
1194
|
+
BasemapComponent,
|
|
1195
|
+
NotificationComponent
|
|
1196
|
+
];
|
|
1197
|
+
|
|
1198
|
+
export { BasemapComponent, LayerPanelComponent, MapSwitchComponent, NavigationComponent, NotificationComponent, SIDE_PANEL_SLOTS, SidePanelComponent, TopicListComponent, XGIS_COMPONENTS };
|
|
1199
|
+
//# sourceMappingURL=index.js.map
|