@octostar/map-component 0.2.22 → 0.3.0

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/dist/index.mjs CHANGED
@@ -2637,6 +2637,148 @@ function useToast() {
2637
2637
  };
2638
2638
  return { toast };
2639
2639
  }
2640
+ const DEFAULT_ENDPOINTS = {
2641
+ streetsStyle: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
2642
+ darkStyle: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
2643
+ satelliteTiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
2644
+ satelliteAttribution: "Esri, Maxar, Earthstar Geographics",
2645
+ terrainTiles: ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],
2646
+ geocodingUrl: "https://nominatim.openstreetmap.org/search",
2647
+ glyphsUrl: "/fonts/{fontstack}/{range}.pbf"
2648
+ };
2649
+ const BUILT_IN_NAMES = {
2650
+ streets: "Streets",
2651
+ satellite: "Satellite",
2652
+ dark: "Dark"
2653
+ };
2654
+ const isOff = (value) => value === false || value === null;
2655
+ const nonEmpty = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
2656
+ const nonEmptyTiles = (tiles) => Array.isArray(tiles) ? tiles.filter((tile) => nonEmpty(tile) !== void 0) : [];
2657
+ function resolveVectorStyle(endpoint, defaultStyle) {
2658
+ if (isOff(endpoint)) return null;
2659
+ if (endpoint === void 0) return { style: defaultStyle };
2660
+ const style = nonEmpty(endpoint.style);
2661
+ return style ? { style, name: endpoint.name } : null;
2662
+ }
2663
+ function resolveGeocoder(endpoint) {
2664
+ if (isOff(endpoint)) return null;
2665
+ if (endpoint === void 0) return { url: DEFAULT_ENDPOINTS.geocodingUrl };
2666
+ if ("provider" in endpoint) return typeof endpoint.provider === "function" ? { provider: endpoint.provider } : null;
2667
+ const url = nonEmpty(endpoint.url);
2668
+ return url ? { url } : null;
2669
+ }
2670
+ function resolveEndpoints(endpoints) {
2671
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2672
+ const e = endpoints ?? {};
2673
+ const streets = resolveVectorStyle(e.streets, DEFAULT_ENDPOINTS.streetsStyle);
2674
+ const dark = resolveVectorStyle(e.dark, DEFAULT_ENDPOINTS.darkStyle);
2675
+ let satellite = null;
2676
+ let satelliteName;
2677
+ if (!isOff(e.satellite)) {
2678
+ const tiles = e.satellite === void 0 ? [...DEFAULT_ENDPOINTS.satelliteTiles] : nonEmptyTiles(e.satellite.tiles);
2679
+ if (tiles.length > 0) {
2680
+ satellite = {
2681
+ tiles,
2682
+ tileSize: ((_a = e.satellite) == null ? void 0 : _a.tileSize) ?? 256,
2683
+ minzoom: ((_b = e.satellite) == null ? void 0 : _b.minzoom) ?? 0,
2684
+ maxzoom: ((_c = e.satellite) == null ? void 0 : _c.maxzoom) ?? 22,
2685
+ attribution: e.satellite === void 0 ? DEFAULT_ENDPOINTS.satelliteAttribution : e.satellite.attribution ?? ""
2686
+ };
2687
+ satelliteName = (_d = e.satellite) == null ? void 0 : _d.name;
2688
+ }
2689
+ }
2690
+ let terrain = null;
2691
+ if (!isOff(e.terrain)) {
2692
+ const tiles = e.terrain === void 0 ? [...DEFAULT_ENDPOINTS.terrainTiles] : nonEmptyTiles(e.terrain.tiles);
2693
+ if (tiles.length > 0) {
2694
+ terrain = {
2695
+ tiles,
2696
+ encoding: ((_e = e.terrain) == null ? void 0 : _e.encoding) ?? "terrarium",
2697
+ tileSize: ((_f = e.terrain) == null ? void 0 : _f.tileSize) ?? 256,
2698
+ minzoom: ((_g = e.terrain) == null ? void 0 : _g.minzoom) ?? 0,
2699
+ maxzoom: ((_h = e.terrain) == null ? void 0 : _h.maxzoom) ?? 15,
2700
+ attribution: ((_i = e.terrain) == null ? void 0 : _i.attribution) ?? ""
2701
+ };
2702
+ }
2703
+ }
2704
+ const glyphs = e.glyphs;
2705
+ const adoptStyleGlyphs = glyphs === "from-style";
2706
+ const glyphsUrl = typeof glyphs === "object" && glyphs !== null && nonEmpty(glyphs.url) || DEFAULT_ENDPOINTS.glyphsUrl;
2707
+ const builtInBasemaps = [];
2708
+ if (streets) builtInBasemaps.push({ id: "streets", name: streets.name ?? BUILT_IN_NAMES.streets });
2709
+ if (satellite) builtInBasemaps.push({ id: "satellite", name: satelliteName ?? BUILT_IN_NAMES.satellite });
2710
+ if (dark) builtInBasemaps.push({ id: "dark", name: dark.name ?? BUILT_IN_NAMES.dark });
2711
+ return {
2712
+ vectorStyles: {
2713
+ ...streets ? { streets: streets.style } : {},
2714
+ ...dark ? { dark: dark.style } : {}
2715
+ },
2716
+ satellite,
2717
+ terrain,
2718
+ glyphsUrl,
2719
+ adoptStyleGlyphs,
2720
+ builtInBasemaps
2721
+ };
2722
+ }
2723
+ function builtInStyleUrl(resolved, id) {
2724
+ if (id === "streets") return resolved.vectorStyles.streets;
2725
+ if (id === "dark") return resolved.vectorStyles.dark;
2726
+ return void 0;
2727
+ }
2728
+ function isBuiltInBasemapEnabled(resolved, id) {
2729
+ return resolved.builtInBasemaps.some((basemap) => basemap.id === id);
2730
+ }
2731
+ const BUILT_IN_IDS = ["streets", "satellite", "dark"];
2732
+ function initialBasemapId(resolved, requested) {
2733
+ var _a;
2734
+ if (!BUILT_IN_IDS.includes(requested) || isBuiltInBasemapEnabled(resolved, requested)) return requested;
2735
+ return ((_a = resolved.builtInBasemaps[0]) == null ? void 0 : _a.id) ?? requested;
2736
+ }
2737
+ function createBaseStyle(resolved) {
2738
+ const sources = {};
2739
+ const layers = [
2740
+ { id: "background", type: "background", paint: { "background-color": "#f0f0f0" } }
2741
+ ];
2742
+ if (resolved.satellite) {
2743
+ sources["satellite-tiles"] = {
2744
+ type: "raster",
2745
+ tiles: resolved.satellite.tiles,
2746
+ tileSize: resolved.satellite.tileSize,
2747
+ minzoom: resolved.satellite.minzoom,
2748
+ maxzoom: resolved.satellite.maxzoom,
2749
+ attribution: resolved.satellite.attribution
2750
+ };
2751
+ layers.push({
2752
+ id: "satellite-layer",
2753
+ type: "raster",
2754
+ source: "satellite-tiles",
2755
+ minzoom: 0,
2756
+ maxzoom: 22,
2757
+ layout: { visibility: "none" }
2758
+ });
2759
+ }
2760
+ if (resolved.terrain) {
2761
+ sources["terrain-dem"] = {
2762
+ type: "raster-dem",
2763
+ tiles: resolved.terrain.tiles,
2764
+ tileSize: resolved.terrain.tileSize,
2765
+ minzoom: resolved.terrain.minzoom,
2766
+ maxzoom: resolved.terrain.maxzoom,
2767
+ encoding: resolved.terrain.encoding,
2768
+ attribution: resolved.terrain.attribution
2769
+ };
2770
+ }
2771
+ return { version: 8, sources, layers, glyphs: resolved.glyphsUrl };
2772
+ }
2773
+ async function geocodeAddress(geocoder, query, fetchImpl = fetch) {
2774
+ if ("provider" in geocoder) return geocoder.provider(query);
2775
+ const response = await fetchImpl(`${geocoder.url}?format=json&q=${encodeURIComponent(query)}&limit=1`);
2776
+ if (!response.ok) throw new Error("Search failed");
2777
+ const results = await response.json();
2778
+ if (!Array.isArray(results) || results.length === 0) return null;
2779
+ const { lon, lat, display_name } = results[0];
2780
+ return { lon: parseFloat(lon), lat: parseFloat(lat), displayName: display_name };
2781
+ }
2640
2782
  function ToolButton({ mode, activeMode, onModeChange, icon, label, shortcut, disabled, showShortcutHint = true }) {
2641
2783
  const isActive = activeMode === mode;
2642
2784
  const handleClick = () => {
@@ -2714,8 +2856,7 @@ function DrawingToolbar({
2714
2856
  onClearFilter,
2715
2857
  onFilterActiveChange,
2716
2858
  onSearchEngineRequest,
2717
- geocodingUrl = "https://nominatim.openstreetmap.org/search",
2718
- geocoderProvider,
2859
+ geocoder,
2719
2860
  showShortcutHints = true,
2720
2861
  expandSelectionTools = false,
2721
2862
  showFilterTool = false,
@@ -2729,6 +2870,7 @@ function DrawingToolbar({
2729
2870
  const [goToLng, setGoToLng] = useState("");
2730
2871
  const [goToAddress, setGoToAddress] = useState("");
2731
2872
  const [isSearching, setIsSearching] = useState(false);
2873
+ const resolvedGeocoder = useMemo(() => resolveGeocoder(geocoder), [geocoder]);
2732
2874
  const [filterActive, setFilterActive] = useState(false);
2733
2875
  const [isCompact, setIsCompact] = useState(false);
2734
2876
  const [featureSearchOpen, setFeatureSearchOpen] = useState(false);
@@ -2861,27 +3003,10 @@ function DrawingToolbar({
2861
3003
  setGoToLng("");
2862
3004
  };
2863
3005
  const handleAddressSearch = async () => {
2864
- if (!goToAddress.trim()) return;
3006
+ if (!resolvedGeocoder || !goToAddress.trim()) return;
2865
3007
  setIsSearching(true);
2866
3008
  try {
2867
- let result = null;
2868
- if (geocoderProvider) {
2869
- result = await geocoderProvider(goToAddress.trim());
2870
- } else {
2871
- const response = await fetch(
2872
- `${geocodingUrl}?format=json&q=${encodeURIComponent(goToAddress)}&limit=1`
2873
- );
2874
- if (!response.ok) throw new Error("Search failed");
2875
- const results = await response.json();
2876
- if (results.length > 0) {
2877
- const { lon, lat, display_name } = results[0];
2878
- result = {
2879
- lon: parseFloat(lon),
2880
- lat: parseFloat(lat),
2881
- displayName: display_name
2882
- };
2883
- }
2884
- }
3009
+ const result = await geocodeAddress(resolvedGeocoder, goToAddress.trim());
2885
3010
  if (!result) {
2886
3011
  toast({
2887
3012
  title: "Location not found",
@@ -3652,41 +3777,43 @@ function DrawingToolbar({
3652
3777
  /* @__PURE__ */ jsx(Navigation, { className: "w-3 h-3 text-muted-foreground" }),
3653
3778
  /* @__PURE__ */ jsx("span", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: "Navigate To" })
3654
3779
  ] }),
3655
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
3656
- /* @__PURE__ */ jsx(
3657
- Input,
3658
- {
3659
- placeholder: "Search address...",
3660
- value: goToAddress,
3661
- onChange: (e) => setGoToAddress(e.target.value),
3662
- onKeyDown: (e) => {
3663
- if (e.key === "Enter") handleAddressSearch();
3664
- },
3665
- disabled: isSearching,
3666
- size: "small",
3667
- prefix: /* @__PURE__ */ jsx(MapPin, { className: "w-3.5 h-3.5 opacity-50" }),
3668
- allowClear: true,
3669
- "data-testid": "input-goto-address"
3670
- }
3671
- ),
3672
- /* @__PURE__ */ jsx(
3673
- Button,
3674
- {
3675
- type: "primary",
3676
- size: "small",
3677
- onClick: handleAddressSearch,
3678
- disabled: isSearching || !goToAddress.trim(),
3679
- className: "shrink-0",
3680
- "data-testid": "button-search-address",
3681
- icon: isSearching ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }) : void 0,
3682
- children: isSearching ? "" : "Go"
3683
- }
3684
- )
3685
- ] }),
3686
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3687
- /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" }),
3688
- /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground shrink-0", children: "or coordinates" }),
3689
- /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" })
3780
+ resolvedGeocoder && /* @__PURE__ */ jsxs(Fragment, { children: [
3781
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
3782
+ /* @__PURE__ */ jsx(
3783
+ Input,
3784
+ {
3785
+ placeholder: "Search address...",
3786
+ value: goToAddress,
3787
+ onChange: (e) => setGoToAddress(e.target.value),
3788
+ onKeyDown: (e) => {
3789
+ if (e.key === "Enter") handleAddressSearch();
3790
+ },
3791
+ disabled: isSearching,
3792
+ size: "small",
3793
+ prefix: /* @__PURE__ */ jsx(MapPin, { className: "w-3.5 h-3.5 opacity-50" }),
3794
+ allowClear: true,
3795
+ "data-testid": "input-goto-address"
3796
+ }
3797
+ ),
3798
+ /* @__PURE__ */ jsx(
3799
+ Button,
3800
+ {
3801
+ type: "primary",
3802
+ size: "small",
3803
+ onClick: handleAddressSearch,
3804
+ disabled: isSearching || !goToAddress.trim(),
3805
+ className: "shrink-0",
3806
+ "data-testid": "button-search-address",
3807
+ icon: isSearching ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }) : void 0,
3808
+ children: isSearching ? "" : "Go"
3809
+ }
3810
+ )
3811
+ ] }),
3812
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3813
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" }),
3814
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground shrink-0", children: "or coordinates" }),
3815
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" })
3816
+ ] })
3690
3817
  ] }),
3691
3818
  /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-end", children: [
3692
3819
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
@@ -3747,16 +3874,21 @@ function DrawingToolbar({
3747
3874
  );
3748
3875
  }
3749
3876
  const BUILT_IN_BASEMAP_IDS = ["streets", "satellite", "dark"];
3750
- const BUILT_IN_NAMES = {
3751
- streets: "Streets",
3752
- satellite: "Satellite",
3753
- dark: "Dark"
3754
- };
3755
- function resolveBasemapChoices(order, customBasemaps) {
3877
+ const isBuiltInId = (id) => BUILT_IN_BASEMAP_IDS.includes(id);
3878
+ function customBasemapsWithoutBuiltIns(customBasemaps) {
3879
+ if (!customBasemaps) return void 0;
3880
+ const ignored = Object.keys(customBasemaps).filter(isBuiltInId);
3881
+ if (ignored.length === 0) return customBasemaps;
3882
+ console.warn(
3883
+ `[map-component] customBasemaps entries for built-in ids are ignored (${ignored.join(", ")}); configure them through the endpoints prop.`
3884
+ );
3885
+ return Object.fromEntries(Object.entries(customBasemaps).filter(([id]) => !isBuiltInId(id)));
3886
+ }
3887
+ function resolveBasemapChoices(order, customBasemaps, builtIns) {
3756
3888
  const describe = (id) => {
3757
- if (BUILT_IN_BASEMAP_IDS.includes(id)) {
3758
- return { id, name: BUILT_IN_NAMES[id] ?? id, builtIn: true };
3759
- }
3889
+ const builtIn = builtIns.find((entry) => entry.id === id);
3890
+ if (builtIn) return { id, name: builtIn.name, builtIn: true };
3891
+ if (isBuiltInId(id)) return void 0;
3760
3892
  const custom = customBasemaps == null ? void 0 : customBasemaps[id];
3761
3893
  if (!custom) return void 0;
3762
3894
  return { id, name: custom.name || id, builtIn: false };
@@ -3764,13 +3896,8 @@ function resolveBasemapChoices(order, customBasemaps) {
3764
3896
  if (order) {
3765
3897
  return order.map(describe).filter((choice) => !!choice);
3766
3898
  }
3767
- const customIds = Object.keys(customBasemaps ?? {}).filter(
3768
- (id) => !BUILT_IN_BASEMAP_IDS.includes(id)
3769
- );
3770
- return [
3771
- ...BUILT_IN_BASEMAP_IDS.map((id) => describe(id)),
3772
- ...customIds.map(describe).filter((choice) => !!choice)
3773
- ];
3899
+ const customIds = Object.keys(customBasemaps ?? {}).filter((id) => !isBuiltInId(id));
3900
+ return [...builtIns.map((entry) => entry.id), ...customIds].map(describe).filter((choice) => !!choice);
3774
3901
  }
3775
3902
  const PRESET_COLORS$1 = [
3776
3903
  "#3b82f6",
@@ -8792,64 +8919,16 @@ function extract3DFlightPaths(features) {
8792
8919
  return paths;
8793
8920
  }
8794
8921
  const CAP_NOTICE_INTERVAL_MS = 5e3;
8795
- const DEFAULT_LOCAL_GLYPHS_URL = "/fonts/{fontstack}/{range}.pbf";
8796
8922
  function basemapInsertAnchor(map) {
8797
8923
  if (map.getLayer("satellite-layer")) return "satellite-layer";
8798
8924
  if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
8799
8925
  return void 0;
8800
8926
  }
8801
- function createBaseStyle(options) {
8802
- const sources = {};
8803
- const layers = [
8804
- {
8805
- id: "background",
8806
- type: "background",
8807
- paint: {
8808
- "background-color": "#f0f0f0"
8809
- }
8810
- }
8811
- ];
8812
- if (options.enableSatellite !== false) {
8813
- sources["satellite-tiles"] = {
8814
- type: "raster",
8815
- tiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
8816
- tileSize: 256,
8817
- attribution: "Esri, Maxar, Earthstar Geographics"
8818
- };
8819
- layers.push({
8820
- id: "satellite-layer",
8821
- type: "raster",
8822
- source: "satellite-tiles",
8823
- minzoom: 0,
8824
- maxzoom: 22,
8825
- layout: { visibility: "none" }
8826
- });
8827
- }
8828
- if (options.enableTerrain !== false) {
8829
- sources["terrain-dem"] = {
8830
- type: "raster-dem",
8831
- tiles: ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],
8832
- tileSize: 256,
8833
- maxzoom: 15,
8834
- encoding: "terrarium"
8835
- };
8836
- }
8837
- return {
8838
- version: 8,
8839
- sources,
8840
- layers,
8841
- glyphs: options.glyphsUrl || DEFAULT_LOCAL_GLYPHS_URL
8842
- };
8843
- }
8844
8927
  const BASEMAP_LAYER_PREFIXES = {
8845
8928
  streets: "streets-",
8846
8929
  satellite: "satellite-",
8847
8930
  dark: "dark-"
8848
8931
  };
8849
- const EXTERNAL_STYLE_URLS = {
8850
- streets: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
8851
- dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
8852
- };
8853
8932
  const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
8854
8933
  className,
8855
8934
  enableDrawing = true,
@@ -8869,8 +8948,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
8869
8948
  showDebugSidebar = false,
8870
8949
  initialCenter = [-74.006, 40.7128],
8871
8950
  initialZoom = 12,
8872
- baseMapStyle = "streets",
8873
- customBasemaps,
8951
+ baseMapStyle: requestedBaseMapStyle = "streets",
8952
+ endpoints,
8953
+ customBasemaps: customBasemapsProp,
8874
8954
  basemapOrder,
8875
8955
  initialDrawingMode,
8876
8956
  onFeatureSelect,
@@ -8887,8 +8967,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
8887
8967
  onClearFilter,
8888
8968
  showGoToButton = false,
8889
8969
  onDropPoint,
8890
- geocodingUrl,
8891
- geocoderProvider,
8892
8970
  onSearchEngineRequest,
8893
8971
  onWorkspaceLoad,
8894
8972
  onWorkspaceSave,
@@ -8903,12 +8981,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
8903
8981
  featureSaveProvider,
8904
8982
  featureRefreshProvider,
8905
8983
  tooltipProvider,
8906
- glyphsUrl,
8907
8984
  filterGeometry,
8908
- enableSatellite = true,
8909
- enableTerrain = true,
8910
- enableDark = true,
8911
- enable3D = true,
8912
8985
  hideBasemapSwitcher = false,
8913
8986
  externalPersistence = false,
8914
8987
  enableKeyboardShortcuts = true,
@@ -8929,6 +9002,18 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
8929
9002
  onEntityContextMenu
8930
9003
  }, ref) {
8931
9004
  const mapContainer = useRef(null);
9005
+ const [resolvedEndpoints] = useState(() => resolveEndpoints(endpoints));
9006
+ const [baseMapStyle] = useState(() => {
9007
+ if (!resolvedEndpoints.vectorStyles.streets) {
9008
+ console.warn("[map-component] streets is turned off in endpoints.");
9009
+ }
9010
+ const id = initialBasemapId(resolvedEndpoints, requestedBaseMapStyle);
9011
+ if (id !== requestedBaseMapStyle) {
9012
+ console.warn(`[map-component] basemap "${requestedBaseMapStyle}" is turned off in endpoints; opening on "${id}".`);
9013
+ }
9014
+ return id;
9015
+ });
9016
+ const customBasemaps = useMemo(() => customBasemapsWithoutBuiltIns(customBasemapsProp), [customBasemapsProp]);
8932
9017
  const map = useRef(null);
8933
9018
  const draw = useRef(null);
8934
9019
  const fileInputRef = useRef(null);
@@ -8945,19 +9030,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
8945
9030
  const readOnlyFeatures = useRef(/* @__PURE__ */ new Map());
8946
9031
  const layerTemporalCacheRef = useRef(/* @__PURE__ */ new Map());
8947
9032
  const timelineUpdateTimerRef = useRef(null);
8948
- const loadedBasemaps = useRef(new Set(enableSatellite ? ["satellite"] : []));
8949
- const basemapLayerIds = useRef(new Map(enableSatellite ? [["satellite", ["satellite-layer"]]] : []));
9033
+ const loadedBasemaps = useRef(new Set(resolvedEndpoints.satellite ? ["satellite"] : []));
9034
+ const basemapLayerIds = useRef(new Map(resolvedEndpoints.satellite ? [["satellite", ["satellite-layer"]]] : []));
8950
9035
  const availableBasemaps = useMemo(() => {
8951
9036
  const iconFor = (id) => {
8952
9037
  var _a;
8953
9038
  return ((_a = MAP_STYLES.find((style) => style.id === id)) == null ? void 0 : _a.icon) ?? Map$1;
8954
9039
  };
8955
- return resolveBasemapChoices(basemapOrder, customBasemaps).map((choice) => ({
9040
+ return resolveBasemapChoices(basemapOrder, customBasemaps, resolvedEndpoints.builtInBasemaps).map((choice) => ({
8956
9041
  id: choice.id,
8957
9042
  name: choice.name,
8958
9043
  icon: iconFor(choice.id)
8959
9044
  }));
8960
- }, [basemapOrder, customBasemaps]);
9045
+ }, [basemapOrder, customBasemaps, resolvedEndpoints]);
8961
9046
  const loadingBasemaps = useRef(/* @__PURE__ */ new Set());
8962
9047
  const customBasemapRegistry = useRef(/* @__PURE__ */ new Map());
8963
9048
  const clusterPieManagers = useRef(/* @__PURE__ */ new Map());
@@ -10200,11 +10285,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10200
10285
  if (!mapContainer.current || map.current) return;
10201
10286
  let removeDrawGateListeners;
10202
10287
  try {
10203
- const baseStyle = createBaseStyle({
10204
- glyphsUrl,
10205
- enableSatellite,
10206
- enableTerrain
10207
- });
10288
+ const baseStyle = createBaseStyle(resolvedEndpoints);
10208
10289
  const mapInstance = new maplibregl.Map({
10209
10290
  container: mapContainer.current,
10210
10291
  style: baseStyle,
@@ -10777,7 +10858,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10777
10858
  onMapLoad == null ? void 0 : onMapLoad(mapInstance);
10778
10859
  if (baseMapStyle !== "satellite") {
10779
10860
  const customDef = customBasemaps == null ? void 0 : customBasemaps[baseMapStyle];
10780
- const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style : EXTERNAL_STYLE_URLS[baseMapStyle];
10861
+ const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style : builtInStyleUrl(resolvedEndpoints, baseMapStyle);
10781
10862
  if (styleUrl) {
10782
10863
  const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
10783
10864
  fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
@@ -10791,8 +10872,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10791
10872
  return url;
10792
10873
  }
10793
10874
  };
10794
- const usingLocalGlyphs = !glyphsUrl || glyphsUrl === DEFAULT_LOCAL_GLYPHS_URL;
10795
- if (externalStyle.glyphs && !usingLocalGlyphs) {
10875
+ if (externalStyle.glyphs && resolvedEndpoints.adoptStyleGlyphs) {
10796
10876
  mapInstance.setGlyphs(resolveUrl(externalStyle.glyphs));
10797
10877
  }
10798
10878
  if (externalStyle.sprite) {
@@ -11849,6 +11929,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11849
11929
  // Basemap management methods
11850
11930
  registerBasemap: (id, definition) => {
11851
11931
  if (!map.current) return;
11932
+ if (BUILT_IN_BASEMAP_IDS.includes(id)) {
11933
+ console.warn(`[map-component] registerBasemap("${id}") ignored: built-in basemaps are configured through the endpoints prop.`);
11934
+ return;
11935
+ }
11852
11936
  customBasemapRegistry.current.set(id, definition);
11853
11937
  if (definition.type === "raster") {
11854
11938
  const sourceId = `custom-basemap-${id}`;
@@ -11875,8 +11959,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11875
11959
  },
11876
11960
  unregisterBasemap: (id) => {
11877
11961
  if (!map.current) return false;
11878
- const builtIn = ["streets", "satellite", "dark"];
11879
- if (builtIn.includes(id)) return false;
11962
+ if (BUILT_IN_BASEMAP_IDS.includes(id)) return false;
11880
11963
  customBasemapRegistry.current.delete(id);
11881
11964
  const layerIds = basemapLayerIds.current.get(id) || [];
11882
11965
  for (const layerId of layerIds) {
@@ -11900,7 +11983,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11900
11983
  return currentMapStyle;
11901
11984
  },
11902
11985
  listBasemaps: () => {
11903
- const builtIn = ["streets", "satellite", "dark"];
11986
+ const builtIn = resolvedEndpoints.builtInBasemaps.map((basemap) => basemap.id);
11904
11987
  const custom = Array.from(customBasemapRegistry.current.keys());
11905
11988
  return [...builtIn, ...custom];
11906
11989
  },
@@ -13026,7 +13109,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13026
13109
  if (!map.current) return [];
13027
13110
  const mapInstance = map.current;
13028
13111
  const prefix = BASEMAP_LAYER_PREFIXES[styleName] || `${styleName}-`;
13029
- const styleUrl = overrideStyleUrl || EXTERNAL_STYLE_URLS[styleName];
13112
+ const styleUrl = overrideStyleUrl || builtInStyleUrl(resolvedEndpoints, styleName);
13030
13113
  if (!styleUrl) {
13031
13114
  console.warn(`No external style URL for: ${styleName}`);
13032
13115
  return [];
@@ -13043,8 +13126,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13043
13126
  return url;
13044
13127
  }
13045
13128
  };
13046
- const usingLocalGlyphs = !glyphsUrl || glyphsUrl === DEFAULT_LOCAL_GLYPHS_URL;
13047
- if (externalStyle.glyphs && !usingLocalGlyphs) {
13129
+ if (externalStyle.glyphs && resolvedEndpoints.adoptStyleGlyphs) {
13048
13130
  mapInstance.setGlyphs(resolveUrl(externalStyle.glyphs));
13049
13131
  }
13050
13132
  if (externalStyle.sprite) {
@@ -13091,7 +13173,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13091
13173
  console.error(`Failed to load basemap style ${styleName}:`, e);
13092
13174
  return [];
13093
13175
  }
13094
- }, [moveLabelsBeforeBasemapSymbols]);
13176
+ }, [moveLabelsBeforeBasemapSymbols, resolvedEndpoints]);
13095
13177
  const setBasemapVisibility = useCallback((styleName, visible) => {
13096
13178
  if (!map.current) return;
13097
13179
  const mapInstance = map.current;
@@ -13105,6 +13187,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13105
13187
  const handleMapStyleChange = useCallback(async (style) => {
13106
13188
  if (!map.current) return;
13107
13189
  const mapInstance = map.current;
13190
+ if (BUILT_IN_BASEMAP_IDS.includes(style) && !isBuiltInBasemapEnabled(resolvedEndpoints, style)) {
13191
+ console.warn(`[map-component] basemap "${style}" is turned off in endpoints; ignoring the switch.`);
13192
+ return;
13193
+ }
13108
13194
  basemapLayerIds.current.forEach((_, basemapName) => {
13109
13195
  setBasemapVisibility(basemapName, false);
13110
13196
  });
@@ -13150,7 +13236,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13150
13236
  setBasemapVisibility(style, true);
13151
13237
  setCurrentMapStyle(style);
13152
13238
  moveLabelsBeforeBasemapSymbols();
13153
- }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
13239
+ }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols, resolvedEndpoints]);
13154
13240
  handleMapStyleChangeRef.current = handleMapStyleChange;
13155
13241
  const handleUpdateTraceConfig = useCallback((layerId, config) => {
13156
13242
  saveStateForUndo("trace config", { coalesceKey: `traceConfig:${layerId}` });
@@ -13500,7 +13586,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13500
13586
  }, [isEditMode]);
13501
13587
  const handleToggle3DTerrain = useCallback(() => {
13502
13588
  if (!map.current) return;
13503
- if (!enableTerrain || !enable3D) {
13589
+ if (!resolvedEndpoints.terrain) {
13504
13590
  toast({
13505
13591
  title: "3D Terrain Unavailable",
13506
13592
  description: "Terrain features are disabled for this configuration.",
@@ -13545,7 +13631,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13545
13631
  mapInstance.setLayoutProperty("terrain-hillshade", "visibility", "none");
13546
13632
  }
13547
13633
  }
13548
- }, [is3DTerrainEnabled, enableTerrain, enable3D, toast]);
13634
+ }, [is3DTerrainEnabled, resolvedEndpoints, toast]);
13549
13635
  const handleSelectionModeChange = useCallback((mode) => {
13550
13636
  setSelectionMode(mode);
13551
13637
  setSelectionPoints([]);
@@ -15869,8 +15955,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15869
15955
  showGoToButton,
15870
15956
  onFitToFeatures: handleFitToFeatures,
15871
15957
  onDropPoint,
15872
- geocodingUrl,
15873
- geocoderProvider,
15958
+ geocoder: endpoints == null ? void 0 : endpoints.geocoder,
15874
15959
  onSearchEngineRequest: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
15875
15960
  getAllFeatures,
15876
15961
  onFlyToFeature: (feature) => {
@@ -15990,9 +16075,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15990
16075
  onToggle3DTerrain: handleToggle3DTerrain,
15991
16076
  onUpdateAltitudeDisplayMode: handleUpdateAltitudeDisplayMode,
15992
16077
  availableBasemaps,
15993
- hideSatellite: !enableSatellite,
15994
- hideDark: !enableDark,
15995
- hideTerrain: !enableTerrain,
16078
+ hideSatellite: !resolvedEndpoints.satellite,
16079
+ hideDark: !resolvedEndpoints.vectorStyles.dark,
16080
+ hideTerrain: !resolvedEndpoints.terrain,
15996
16081
  hideBasemapSwitcher,
15997
16082
  externalPersistence,
15998
16083
  customGlobalMenuItems,