PageSourceSearch

https://ogaweb.org/wp-content/cache/speedycache/ogaweb.org/assets/67b1eb48ae84efc5-oum-map-styles.js

js ogaweb.org collected 2026-10-02 01:07:42 UTC 4,815 bytes, 140 lines download raw bytes

1(function(window){
2'use strict';
3const openFreeMapAttribution='<a href="https://openfreemap.org/" target="_blank" rel="noopener noreferrer">OpenFreeMap</a> &copy; <a href="https://openmaptiles.org/" target="_blank" rel="noopener noreferrer">OpenMapTiles</a> Data from <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap</a>';
4function getRegistry(){
5return window.oum_map_style_registry||{};}
6function getStyleKey(mapStyle){
7const normalizedStyle=String(mapStyle||'').toLowerCase();
8return Object.keys(getRegistry()).find(function(styleKey){
9return styleKey.toLowerCase()===normalizedStyle;
10})||'';
11}
12function getStyleDefinition(mapStyle){
13const styleKey=getStyleKey(mapStyle);
14if(styleKey){
15return getRegistry()[styleKey];
16}
17if(String(mapStyle||'').toLowerCase()==='customimage'){
18return {
19provider: 'custom_image'
20};}
21return getOpenFreeMapDefinition(mapStyle);
22}
23function getOpenFreeMapDefinition(mapStyle){
24const styleSlug=String(mapStyle||'').replace(/^OpenFreeMap\./i, '').toLowerCase();
25const openFreeMapStyleUrls={
26liberty: 'https://tiles.openfreemap.org/styles/liberty',
27bright: 'https://tiles.openfreemap.org/styles/bright',
28positron: 'https://tiles.openfreemap.org/styles/positron',
29dark: 'https://tiles.openfreemap.org/styles/dark',
30fiord: 'https://tiles.openfreemap.org/styles/fiord'
31};
32return openFreeMapStyleUrls[styleSlug]
33? {
34provider: 'openfreemap',
35url: openFreeMapStyleUrls[styleSlug]
36}
37: null;
38}
39function ensureLeafletZoomBounds(map){
40if(map&&typeof map.getMaxZoom==='function'&&!isFinite(map.getMaxZoom())&&typeof map.setMaxZoom==='function'){
41map.setMaxZoom(20);
42}}
43function getKey(options, key){
44return options&&options[key] ? options[key]:'';
45}
46function addCartoTileLayer(map, mapStyle, options){
47const cartoKey=getKey(options, 'cartoKey');
48if(!cartoKey){
49console.warn('Open User Map: This CARTO style requires an API key.');
50return null;
51}
52return window.L.tileLayer.provider(mapStyle, {
53apikey: cartoKey
54}).addTo(map);
55}
56function addCustomCartoLayers(map, style, options){
57const cartoKey=getKey(options, 'cartoKey');
58if(!cartoKey){
59console.warn('Open User Map: This CARTO style requires an API key.');
60return null;
61}
62const keyParam='?key=' + encodeURIComponent(cartoKey);
63window.L.tileLayer(style.carto_base_url + keyParam).addTo(map);
64return window.L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_only_labels/{z}/{x}/{y}{r}.png' + keyParam, {
65tileSize: 512,
66zoomOffset: -1
67}).addTo(map);
68}
69function addMapBoxLayer(map, style, options){
70const mapboxKey=getKey(options, 'mapboxKey');
71if(!mapboxKey){
72console.warn('Open User Map: This MapBox style requires an API key.');
73return null;
74}
75return window.L.tileLayer.provider('MapBox', {
76id: style.mapbox_id,
77accessToken: mapboxKey
78}).addTo(map);
79}
80function addCustomImageLayer(map, options){
81if(options&&typeof options.setupCustomImageLayer==='function'){
82options.setupCustomImageLayer();
83}
84if(options&&options.customImageHideTiles){
85const layer=window.L.tileLayer('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', {
86attribution: '',
87opacity: 0
88}).addTo(map);
89if(options.customImageBackgroundColor){
90map.getContainer().style.backgroundColor=options.customImageBackgroundColor;
91}
92return layer;
93}
94return window.L.tileLayer.provider('OpenStreetMap.Mapnik').addTo(map);
95}
96function addOpenFreeMapLayer(map, style){
97if(!window.L||typeof window.L.maplibreGL!=='function'){
98console.warn('Open User Map: MapLibre assets are required for OpenFreeMap styles.');
99return window.L&&window.L.tileLayer&&window.L.tileLayer.provider
100? window.L.tileLayer.provider('OpenStreetMap.Mapnik').addTo(map)
101: null;
102}
103ensureLeafletZoomBounds(map);
104return window.L.maplibreGL({
105style: style.url,
106attributionControl: {
107customAttribution: openFreeMapAttribution
108}}).addTo(map);
109}
110function addBaseLayer(map, mapStyle, options){
111const style=getStyleDefinition(mapStyle)||{};
112if(style.provider==='openfreemap'){
113return addOpenFreeMapLayer(map, style);
114}
115if(style.provider==='custom_image'){
116return addCustomImageLayer(map, options);
117}
118if(style.mapbox_id){
119return addMapBoxLayer(map, style, options);
120}
121if(style.carto_base_url){
122return addCustomCartoLayers(map, style, options);
123}
124if(style.provider==='carto'){
125return addCartoTileLayer(map, mapStyle, options);
126}
127return window.L.tileLayer.provider(mapStyle).addTo(map);
128}
129window.OUMMapStyles={
130getStyleDefinition: getStyleDefinition,
131isOpenFreeMapStyle: function(mapStyle){
132const style=getStyleDefinition(mapStyle);
133return !!style&&style.provider==='openfreemap';
134},
135addOpenFreeMapLayer: function(map, mapStyle){
136const style=getStyleDefinition(mapStyle);
137return style&&style.provider==='openfreemap' ? addOpenFreeMapLayer(map, style):null;
138},
139addBaseLayer: addBaseLayer
140};})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.