From fdae11f7cd76e3f0c3130fcdf0b26b5b13673b28 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 5 Mar 2026 17:46:13 +0000 Subject: [PATCH] Add ArcGIS map tile display. --- html/static/js/map-arcgis-tile.js | 8 +++----- sync/intelligence.go | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/html/static/js/map-arcgis-tile.js b/html/static/js/map-arcgis-tile.js index 2406460d..0f36837e 100644 --- a/html/static/js/map-arcgis-tile.js +++ b/html/static/js/map-arcgis-tile.js @@ -39,12 +39,11 @@ class MapArcgisTile extends HTMLElement { style: "https://tiles.stadiamaps.com/styles/osm_bright.json", zoom: 22, }); - /* + console.log("ArcGIS token", arcgis_access_token); const basemap_style = maplibreArcGIS.BasemapStyle.applyStyle(this._map, { style: "arcgis/light-gray", token: arcgis_access_token, }); - */ this._map.on("load", () => { console.log("map-arcgis-tile loaded"); if (organization_id != 0) { @@ -64,12 +63,12 @@ class MapArcgisTile extends HTMLElement { }, }); } - /* if (arcgis_access_token != "") { this._map.addSource("flyover", { type: "raster", tiles: [ - "https://tiles.arcgis.com/tiles/pV7SH1EgRc6tpxlJ/arcgis/rest/services/TrimmedFlyover2025/MapServer/tile/{z}/{y}/{x}?token=" + arcgis_access_token, + "https://tiles.arcgis.com/tiles/pV7SH1EgRc6tpxlJ/arcgis/rest/services/TrimmedFlyover2025/MapServer/tile/{z}/{y}/{x}?token=" + + arcgis_access_token, ], }); console.log("added arcgis tile source"); @@ -80,7 +79,6 @@ class MapArcgisTile extends HTMLElement { }); console.log("added arcgis tile layer"); } - */ this.dispatchEvent(new CustomEvent("load"), { bubbles: true, composed: true, // Allows event to cross shadow DOM boundary diff --git a/sync/intelligence.go b/sync/intelligence.go index 13f45635..17a4c841 100644 --- a/sync/intelligence.go +++ b/sync/intelligence.go @@ -4,13 +4,30 @@ import ( "context" "net/http" + "github.com/Gleipnir-Technology/nidus-sync/background" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/html" nhttp "github.com/Gleipnir-Technology/nidus-sync/http" + "github.com/rs/zerolog/log" ) -type contentIntelligenceRoot struct{} +type contentIntelligenceRoot struct { + ArcgisAccessToken string +} func getIntelligenceRoot(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*html.Response[contentIntelligenceRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/intelligence-root.html", contentIntelligenceRoot{}), nil + var oauth_token *models.ArcgisOauthToken + var err error + var access_token string + oauth_token, err = background.GetOAuthForOrg(ctx, org) + if err != nil { + log.Warn().Err(err).Msg("Failed to get oauth") + oauth_token = nil + access_token = "" + } else { + access_token = oauth_token.AccessToken + } + return html.NewResponse("sync/intelligence-root.html", contentIntelligenceRoot{ + ArcgisAccessToken: access_token, + }), nil }