kopia lustrzana https://github.com/FacilMap/facilmap
Add HIDE_COMMERCIAL_MAP_LINKS config option (#186)
rodzic
8365cf252d
commit
54e5e9f00f
|
@ -21,7 +21,8 @@ The config of the FacilMap server can be set either by using environment variabl
|
|||
| `MAPZEN_TOKEN` | | | [Mapzen API key](https://mapzen.com/developers/sign_up). |
|
||||
| `MAXMIND_USER_ID` | | | [MaxMind user ID](https://www.maxmind.com/en/geolite2/signup). |
|
||||
| `MAXMIND_LICENSE_KEY` | | | MaxMind license key. |
|
||||
| `LIMA_LABS_TOKEN` | | | [Lima Labs](https://maps.lima-labs.com/) API key
|
||||
| `LIMA_LABS_TOKEN` | | | [Lima Labs](https://maps.lima-labs.com/) API key |
|
||||
| `HIDE_COMMERCIAL_MAP_LINKS` | | | Set to `1` to hide the links to Google/Bing Maps in the “Map style” menu. |
|
||||
|
||||
FacilMap makes use of several third-party services that require you to register (for free) and generate an API key:
|
||||
* Mapbox and OpenRouteService are used for calculating routes. Mapbox is used for basic routes, OpenRouteService is used when custom route mode settings are made. If these API keys are not defined, calculating routes will fail.
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
const props = withDefaults(defineProps<{
|
||||
baseUrl: string;
|
||||
appName?: string;
|
||||
hideCommercialMapLinks?: boolean;
|
||||
settings?: Partial<FacilMapSettings>;
|
||||
}>(), {
|
||||
appName: "FacilMap"
|
||||
|
@ -66,6 +67,7 @@
|
|||
id: idCounter++,
|
||||
baseUrl: toRef(() => props.baseUrl),
|
||||
appName: toRef(() => props.appName),
|
||||
hideCommercialMapLinks: toRef(() => props.hideCommercialMapLinks),
|
||||
isNarrow,
|
||||
settings: readonly(toRef(() => ({
|
||||
toolbox: true,
|
||||
|
|
|
@ -31,6 +31,7 @@ export interface WritableFacilMapContext {
|
|||
id: number;
|
||||
baseUrl: string;
|
||||
appName: string;
|
||||
hideCommercialMapLinks: boolean;
|
||||
isNarrow: boolean;
|
||||
settings: FacilMapSettings;
|
||||
components: FacilMapComponents;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
serverUrl: string;
|
||||
padId: string | undefined;
|
||||
appName?: string;
|
||||
hideCommercialMapLinks?: boolean;
|
||||
settings?: Partial<FacilMapSettings>;
|
||||
}>();
|
||||
|
||||
|
@ -68,6 +69,7 @@
|
|||
<FacilMapContextProvider
|
||||
:baseUrl="props.baseUrl"
|
||||
:appName="props.appName"
|
||||
:hideCommercialMapLinks="props.hideCommercialMapLinks"
|
||||
:settings="props.settings"
|
||||
ref="contextRef"
|
||||
>
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
>Open this on OpenStreetMap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li v-if="!context.hideCommercialMapLinks">
|
||||
<a
|
||||
class="dropdown-item"
|
||||
:href="links.google"
|
||||
|
@ -99,7 +99,7 @@
|
|||
>Open this on Google Maps</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li v-if="!context.hideCommercialMapLinks">
|
||||
<a
|
||||
class="dropdown-item"
|
||||
:href="links.googleSatellite"
|
||||
|
@ -108,7 +108,7 @@
|
|||
>Open this on Google Maps (Satellite)</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li v-if="!context.hideCommercialMapLinks">
|
||||
<a
|
||||
class="dropdown-item"
|
||||
:href="links.bing"
|
||||
|
|
|
@ -60,6 +60,7 @@ const Root = defineComponent({
|
|||
serverUrl: baseUrl,
|
||||
padId: padId.value,
|
||||
appName: config.appName,
|
||||
hideCommercialMapLinks: config.hideCommercialMapLinks,
|
||||
settings: {
|
||||
toolbox: toBoolean(queryParams.toolbox, true),
|
||||
search: toBoolean(queryParams.search, true),
|
||||
|
|
|
@ -24,6 +24,8 @@ export interface Config {
|
|||
maxmindUserId?: string;
|
||||
maxmindLicenseKey?: string;
|
||||
limaLabsToken?: string;
|
||||
/** Hide the "Open this on Google/Bing Maps" links in the map style menu */
|
||||
hideCommercialMapLinks?: boolean;
|
||||
}
|
||||
|
||||
const config: Config = {
|
||||
|
@ -55,7 +57,9 @@ const config: Config = {
|
|||
maxmindUserId: process.env.MAXMIND_USER_ID || "",
|
||||
maxmindLicenseKey: process.env.MAXMIND_LICENSE_KEY || "",
|
||||
|
||||
limaLabsToken: process.env.LIMA_LABS_TOKEN || "" // Get a token on https://maps.lima-labs.com/
|
||||
limaLabsToken: process.env.LIMA_LABS_TOKEN || "", // Get a token on https://maps.lima-labs.com/,
|
||||
|
||||
hideCommercialMapLinks: process.env.HIDE_COMMERCIAL_MAP_LINKS === "1",
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -62,6 +62,14 @@ async function getScripts(entry: "mapEntry" | "tableEntry"): Promise<Scripts> {
|
|||
}
|
||||
}
|
||||
|
||||
function getInjectedConfig(): InjectedConfig {
|
||||
return {
|
||||
appName: config.appName,
|
||||
limaLabsToken: config.limaLabsToken,
|
||||
hideCommercialMapLinks: config.hideCommercialMapLinks,
|
||||
};
|
||||
}
|
||||
|
||||
export interface RenderMapParams {
|
||||
padData: Pick<PadData, "name" | "description" | "searchEngines"> | undefined;
|
||||
isReadOnly: boolean;
|
||||
|
@ -75,10 +83,7 @@ export async function renderMap(params: RenderMapParams): Promise<string> {
|
|||
|
||||
return ejs.render(template, {
|
||||
appName: config.appName,
|
||||
config: {
|
||||
appName: config.appName,
|
||||
limaLabsToken: config.limaLabsToken
|
||||
} satisfies InjectedConfig,
|
||||
config: getInjectedConfig(),
|
||||
...injections,
|
||||
paths,
|
||||
...params
|
||||
|
|
|
@ -10,4 +10,5 @@ export function isPromise(object: any): object is Promise<unknown> {
|
|||
export interface InjectedConfig {
|
||||
appName: string;
|
||||
limaLabsToken?: string;
|
||||
hideCommercialMapLinks?: boolean;
|
||||
}
|
Ładowanie…
Reference in New Issue