diff --git a/src/main.ts b/src/main.ts index 778fd99..b0454d5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,8 @@ import { UNIT_SYSTEM, DEFAULT_TILE_SERVER, getId, - OBSIDIAN_LEAFLET_POPOVER_SOURCE + OBSIDIAN_LEAFLET_POPOVER_SOURCE, + DEFAULT_ATTRIBUTION } from "./utils"; import { MapInterface, @@ -332,7 +333,7 @@ export default class ObsidianLeaflet extends Plugin { params, source ); - + const map = await renderer.getMap(); this.registerMapEvents(map); @@ -392,8 +393,42 @@ export default class ObsidianLeaflet extends Plugin { if ( this.data.version?.major != null && this.data.version?.major < 5 && - (this.data.defaultTile.contains("openstreetmap") || - this.data.defaultTileDark.contains("openstreetmap")) + (this.data.defaultTile.contains("stamen-tiles") || + this.data.defaultTileDark.contains("stamen-tiles")) + ) { + new Notice( + createFragment((e) => { + e.createSpan({ + text: "Obsidian Leaflet: Stamen has removed its map tile servers." + }); + e.createEl("br"); + e.createEl("br"); + e.createSpan({ + text: "Going forward, the default tile server will be " + }); + e.createEl("a", { + href: "https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png", + text: "CartoDB" + }); + e.createSpan({ text: "." }); + }), + 0 + ); + if (this.data.defaultTile.contains("stamen-tiles")) { + this.data.defaultTile = DEFAULT_TILE_SERVER; + } + if (this.data.defaultTileDark.contains("stamen-tiles")) { + this.data.defaultTileDark = DEFAULT_TILE_SERVER; + } + if (this.data.defaultAttribution.contains("Stamen Design")) { + this.data.defaultAttribution = DEFAULT_ATTRIBUTION; + } + } + if ( + this.data.version?.major != null && + this.data.version?.major < 6 && + (this.data.defaultTile.contains("stamen") || + this.data.defaultTileDark.contains("stamen")) ) { new Notice( createFragment((e) => { @@ -664,7 +699,10 @@ export default class ObsidianLeaflet extends Plugin { return ret; } - public async getLocalFileMarkers(file: TFile, markerFileName = "markers.json"): Promise { + public async getLocalFileMarkers( + file: TFile, + markerFileName = "markers.json" + ): Promise { if (!file) return []; const markerFilePath = `${file.parent.path}/${markerFileName}`; const markerFile = this.app.vault.getAbstractFileByPath(markerFilePath); @@ -673,7 +711,7 @@ export default class ObsidianLeaflet extends Plugin { const markerJson = await this.app.vault.read(markerFile); try { const icons = JSON.parse(markerJson); - markers.push(...icons.map((i: Icon) => this.parseIcon(i))) + markers.push(...icons.map((i: Icon) => this.parseIcon(i))); } catch { console.error(`Badly formatted marker file ${markerFilePath}`); } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 5b0d45f..351c005 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,22 +1,17 @@ import { Platform } from "obsidian"; -import { - BlockParameters, - LeafletMapOptions, - ObsidianAppData -} from "../types"; +import { BlockParameters, LeafletMapOptions, ObsidianAppData } from "../types"; export const OBSIDIAN_LEAFLET_POPOVER_SOURCE = "obsidian-leaflet"; export const VIEW_TYPE = "obsidian-leaflet-map-view"; export const DEFAULT_TILE_SERVER = - "https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png"; -export const DEFAULT_TILE_SUBDOMAINS = - "a,b,c"; -export const TILE_SUBDOMAINS_SPILT = ','; + "https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png"; +export const DEFAULT_TILE_SUBDOMAINS = "a,b,c,d"; +export const TILE_SUBDOMAINS_SPILT = ","; export const DEFAULT_ATTRIBUTION = - 'Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.'; + '© OpenStreetMap contributors © CARTO'; export const OVERLAY_TAG_REGEX = /^(\d+(?:\.\d+)?)\s?(\w*)/;