Skip to content

Commit

Permalink
Apply debug options to all endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeLonewolf committed May 15, 2024
1 parent 7469bb5 commit bd0993f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
11 changes: 1 addition & 10 deletions src/americana.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SampleControl from "openmapsamples-maplibre/OpenMapSamplesControl.js";
import { default as OpenMapTilesSamples } from "openmapsamples/samples/OpenMapTiles/index.js";

import { createMap, loadRTLPlugin, buildStyle } from "./js/map_builder.js";
import { debugOptions } from "./debug_config.js";

function upgradeLegacyHash() {
let hash = window.location.hash.substr(1);
Expand All @@ -28,16 +29,6 @@ upgradeLegacyHash();

loadRTLPlugin();

const debugOptions = {};

if (config.SHIELD_TEXT_HALO_COLOR_OVERRIDE) {
debugOptions.shieldTextHaloColor = config.SHIELD_TEXT_HALO_COLOR_OVERRIDE;
}

if (config.SHIELD_TEXT_BBOX_COLOR) {
debugOptions.shieldTextBboxColor = config.SHIELD_TEXT_BBOX_COLOR;
}

export const map = createMap(window, (shields) => shieldDefLoad(shields), {
container: "map", // container id
hash: "map",
Expand Down
3 changes: 2 additions & 1 deletion src/bare_americana.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import "maplibre-gl/dist/maplibre-gl.css";

import { createMap, loadRTLPlugin, buildStyle } from "./js/map_builder.js";
import { debugOptions } from "./debug_config.js";

loadRTLPlugin();

Expand All @@ -15,7 +16,7 @@ export const map = createMap(window, (shields) => shieldDefLoad(), {
zoom: 4,
fadeDuration: 0,
attributionControl: false,
});
}, debugOptions);

function shieldDefLoad() {
if (window.top === window.self) {
Expand Down
14 changes: 14 additions & 0 deletions src/debug_config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DebugOptions } from "@americana/maplibre-shield-generator/src/types.js";
import config from "./config.js";

export const debugOptions: DebugOptions = {};

if (config.SHIELD_TEXT_HALO_COLOR_OVERRIDE) {
debugOptions.shieldTextHaloColor = config.SHIELD_TEXT_HALO_COLOR_OVERRIDE;
}

if (config.SHIELD_TEXT_BBOX_COLOR) {
debugOptions.shieldTextBboxColor = config.SHIELD_TEXT_BBOX_COLOR;
}

export { debugOptions as default }
2 changes: 2 additions & 0 deletions src/shieldtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
networkPredicate,
routeParser,
} from "./js/shield_format.js";
import { debugOptions } from "./debug_config.js";

var getUrl = window.location;
var baseUrl = getUrl.protocol + "//" + getUrl.host + getUrl.pathname;
Expand All @@ -27,6 +28,7 @@ export const map = (window.map = new maplibregl.Map({
const shields = ShieldDef.loadShields();

const shieldRenderer = new ShieldRenderer(shields, routeParser)
.debugOptions(debugOptions)
.filterImageID(shieldPredicate)
.filterNetwork(networkPredicate)
.renderOnMaplibreGL(map);
Expand Down

0 comments on commit bd0993f

Please sign in to comment.