Compare commits
2
Commits
177b70631b
...
7301e9b543
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7301e9b543 | ||
|
|
46add3f003 |
No files matched your search
@@ -5,8 +5,6 @@ A [WordPress plugin](https://wordpress.org/plugins) that renders [OpenFreeMap](h
|
||||
## Installation
|
||||
1. Upload the plugin to your `/wp-plugins/` directory
|
||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
3. Go to "Settings > OpenFreemap" to configure the plugin
|
||||
|
||||
|
||||
## Basic Usage
|
||||
Once activated you can render [OpenFreeMap](https://openfreemap.org) map widgets using the shortcode
|
||||
@@ -21,9 +19,13 @@ The options are as follows
|
||||
- `zoom`
|
||||
Initial zoom of the map (default: `16.5`)
|
||||
- `color`
|
||||
Marker color in CSS notation (default: `#ff0000`)
|
||||
Marker color in hex notation, e.g. `#ff0000` (default: `#ff0000`)
|
||||
- `height`
|
||||
Height of the map widget in CSS notation (default: `450px`)
|
||||
- `popup_text`
|
||||
HTML content shown in a popup attached to the marker (default: none)
|
||||
- `style`
|
||||
Map style, one of `bright`, `dark`, `fiord`, `liberty`, `positron` (default: `bright`)
|
||||
|
||||
## Links
|
||||
- https://openfreemap.org
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
var openfreemapModuleUrl;
|
||||
var openfreemapStyleUrl;
|
||||
|
||||
if (document.querySelector('.openfreemap') && typeof openfreemapModuleUrl === 'string') {
|
||||
if (typeof openfreemapStyleUrl === 'string') {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = openfreemapStyleUrl;
|
||||
link.onerror = function () {
|
||||
console.error('[OpenFreeMap] Failed to load the map stylesheet.');
|
||||
};
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
import(openfreemapModuleUrl).catch(function (error) {
|
||||
console.error('[OpenFreeMap] Failed to load the map library.', error);
|
||||
});
|
||||
}
|
||||
+31
-10
@@ -1,23 +1,45 @@
|
||||
import * as maplibregl from '../vendor/maplibre-gl/maplibre-gl.mjs';
|
||||
|
||||
const NO_WEBGL_MESSAGE =
|
||||
'The map could not be displayed. Please enable WebGL or use a different browser.';
|
||||
|
||||
function readNumber(value, fallback) {
|
||||
const parsed = parseFloat(value);
|
||||
return Number.isFinite(parsed) ? parsed : fallback;
|
||||
}
|
||||
|
||||
document.querySelectorAll('.openfreemap').forEach((container) => {
|
||||
const center = [
|
||||
parseFloat(container.dataset.lon),
|
||||
parseFloat(container.dataset.lat)
|
||||
readNumber(container.dataset.lon, 12.3453356),
|
||||
readNumber(container.dataset.lat, 47.1092664)
|
||||
];
|
||||
const zoom = parseFloat(container.dataset.zoom);
|
||||
const map = new maplibregl.Map({
|
||||
style: container.dataset.style,
|
||||
center: center,
|
||||
zoom: zoom,
|
||||
container: container
|
||||
const zoom = readNumber(container.dataset.zoom, 16.5);
|
||||
const popupText = container.dataset.popup;
|
||||
|
||||
let map;
|
||||
try {
|
||||
map = new maplibregl.Map({
|
||||
style: container.dataset.style,
|
||||
center: center,
|
||||
zoom: zoom,
|
||||
container: container
|
||||
});
|
||||
} catch (error) {
|
||||
// MapLibre throws when WebGL is unavailable, leaving an empty box behind.
|
||||
console.error('[OpenFreeMap] Could not initialise the map.', error);
|
||||
container.textContent = NO_WEBGL_MESSAGE;
|
||||
return;
|
||||
}
|
||||
|
||||
map.on('error', (event) => {
|
||||
console.warn('[OpenFreeMap]', event.error);
|
||||
});
|
||||
|
||||
const marker = new maplibregl.Marker({
|
||||
color: container.dataset.color
|
||||
})
|
||||
.setLngLat(center)
|
||||
.addTo(map);
|
||||
const popupText = container.dataset.popup;
|
||||
if (popupText) {
|
||||
const popup = new maplibregl.Popup({
|
||||
closeOnClick: false
|
||||
@@ -27,4 +49,3 @@ document.querySelectorAll('.openfreemap').forEach((container) => {
|
||||
}
|
||||
map.addControl(new maplibregl.NavigationControl());
|
||||
});
|
||||
|
||||
+127
-40
@@ -2,9 +2,13 @@
|
||||
/*
|
||||
Plugin Name: OpenFreeMap
|
||||
Description: Add an OpenFreeMap widget via shortcode [openfreemap]
|
||||
Version: 0.2.0
|
||||
Version: 0.3.0
|
||||
Author: Erwin Nindl
|
||||
Author URI: https://nindl.net
|
||||
License: MIT
|
||||
Requires at least: 5.9
|
||||
Requires PHP: 7.4
|
||||
Text Domain: openfreemap
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
@@ -12,6 +16,79 @@ if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
|
||||
// Clamp a numeric shortcode attribute, falling back to $default when it is not a number
|
||||
function openfreemap_clamp_float($value, $default, $min, $max)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
return $default;
|
||||
}
|
||||
return max($min, min($max, (float) $value));
|
||||
}
|
||||
|
||||
|
||||
// Allow only plain CSS lengths so the value can be interpolated into a style attribute
|
||||
function openfreemap_sanitize_css_length($value, $default)
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
if (preg_match('/^\d+(?:\.\d+)?(?:px|pt|em|rem|ch|%|vh|vw|vmin|vmax)$/i', $value)) {
|
||||
return $value;
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
||||
// Read the release version from the plugin header, keeping the header authoritative
|
||||
function openfreemap_plugin_version()
|
||||
{
|
||||
static $version = null;
|
||||
if (null === $version) {
|
||||
$header = get_file_data(__FILE__, array('Version' => 'Version'), 'plugin');
|
||||
$version = isset($header['Version']) && $header['Version'] ? $header['Version'] : null;
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
|
||||
|
||||
// Append a cache busting query argument to a bundled asset URL. Every bundled
|
||||
// asset (vendored or not) shares the plugin's Version header, so bumping that
|
||||
// header on release is what invalidates caches -- including for vendored
|
||||
// files (e.g. a new MapLibre or OpenFreeMap style release) that don't carry
|
||||
// their own version number.
|
||||
function openfreemap_versioned_url($relative_path)
|
||||
{
|
||||
$url = plugin_dir_url(__FILE__) . $relative_path;
|
||||
$version = openfreemap_plugin_version();
|
||||
return $version ? add_query_arg('ver', $version, $url) : $url;
|
||||
}
|
||||
|
||||
|
||||
// URL of a bundled OpenFreeMap style, versioned like every other shipped asset
|
||||
function openfreemap_style_url($style)
|
||||
{
|
||||
return openfreemap_versioned_url('vendor/openfreemap/styles/' . sanitize_key($style));
|
||||
}
|
||||
|
||||
|
||||
// Styles bundled under vendor/openfreemap/styles/. Kept as an explicit allow-list
|
||||
// so the shortcode can't be used to probe for arbitrary files on disk.
|
||||
function openfreemap_available_styles()
|
||||
{
|
||||
return array('bright', 'dark', 'fiord', 'liberty', 'positron');
|
||||
}
|
||||
|
||||
|
||||
// Restrict the shortcode's style attribute to a known, bundled style
|
||||
function openfreemap_sanitize_style($value, $default)
|
||||
{
|
||||
$value = sanitize_key($value);
|
||||
if (in_array($value, openfreemap_available_styles(), true)) {
|
||||
return $value;
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
||||
// Register the shortcode
|
||||
function openfreemap_handler($atts)
|
||||
{
|
||||
@@ -21,16 +98,19 @@ function openfreemap_handler($atts)
|
||||
'popup_text' => '',
|
||||
'color' => '#ff0000',
|
||||
'height' => '450px',
|
||||
'zoom' => '16.5'
|
||||
'zoom' => '16.5',
|
||||
'style' => 'bright'
|
||||
), $atts, 'openfreemap');
|
||||
$lat = is_numeric($atts['lat']) ? (float) $atts['lat'] : 47.1092664;
|
||||
$lon = is_numeric($atts['lon']) ? (float) $atts['lon'] : 12.3453356;
|
||||
$zoom = is_numeric($atts['zoom']) ? (float) $atts['zoom'] : 16.5;
|
||||
$lat = openfreemap_clamp_float($atts['lat'], 47.1092664, -90, 90);
|
||||
$lon = openfreemap_clamp_float($atts['lon'], 12.3453356, -180, 180);
|
||||
$zoom = openfreemap_clamp_float($atts['zoom'], 16.5, 0, 22);
|
||||
$color = sanitize_hex_color($atts['color']);
|
||||
if (!$color) {
|
||||
$color = '#ff0000';
|
||||
}
|
||||
$height = sanitize_text_field($atts['height']);
|
||||
$height = openfreemap_sanitize_css_length($atts['height'], '450px');
|
||||
$popup_text = wp_kses_post($atts['popup_text']);
|
||||
$style = openfreemap_sanitize_style($atts['style'], 'bright');
|
||||
$map_id = wp_unique_id('openfreemap-');
|
||||
|
||||
ob_start();
|
||||
@@ -43,8 +123,8 @@ function openfreemap_handler($atts)
|
||||
data-lon="<?php echo esc_attr($lon); ?>"
|
||||
data-zoom="<?php echo esc_attr($zoom); ?>"
|
||||
data-color="<?php echo esc_attr($color); ?>"
|
||||
data-popup="<?php echo esc_attr($atts['popup_text']); ?>"
|
||||
data-style="<?php echo esc_url(plugin_dir_url(__FILE__) . 'vendor/openfreemap/styles/bright'); ?>"
|
||||
data-popup="<?php echo esc_attr($popup_text); ?>"
|
||||
data-style="<?php echo esc_url(openfreemap_style_url($style)); ?>"
|
||||
></div>
|
||||
<?php
|
||||
|
||||
@@ -53,45 +133,52 @@ function openfreemap_handler($atts)
|
||||
add_shortcode('openfreemap', 'openfreemap_handler');
|
||||
|
||||
|
||||
// Detect shortcode presence in post content
|
||||
function openfreemap_detect_shortcode($posts)
|
||||
// Enqueue the map stylesheet and a small loader
|
||||
function openfreemap_enqueue_assets()
|
||||
{
|
||||
if (empty($posts) || !is_array($posts)) {
|
||||
return $posts;
|
||||
static $enqueued = false;
|
||||
if ($enqueued) {
|
||||
return;
|
||||
}
|
||||
foreach ($posts as $post) {
|
||||
if (has_shortcode($post->post_content, 'openfreemap')) {
|
||||
add_action('wp_enqueue_scripts', 'openfreemap_enqueue_shortcode_assets');
|
||||
break; // Only need to enqueue once
|
||||
|
||||
// Skip entirely on singular posts/pages that have neither the shortcode
|
||||
// in their content nor a shortcode block. Widgets, template parts, and
|
||||
// secondary loops aren't covered by this check, so it's a partial
|
||||
// optimization, not a guarantee.
|
||||
if (is_singular()) {
|
||||
$post = get_post();
|
||||
if ($post && !has_shortcode($post->post_content, 'openfreemap') && !has_block('core/shortcode', $post)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return $posts;
|
||||
}
|
||||
add_filter('the_posts', 'openfreemap_detect_shortcode');
|
||||
|
||||
$enqueued = true;
|
||||
|
||||
// Enqueue scripts and styles only if shortcode is used
|
||||
function openfreemap_enqueue_shortcode_assets()
|
||||
{
|
||||
$plugin_url = plugin_dir_url(__FILE__);
|
||||
wp_enqueue_style(
|
||||
'openfreemap-style',
|
||||
$plugin_url . 'vendor/maplibre-gl/maplibre-gl.css'
|
||||
);
|
||||
$load_in_footer = false;
|
||||
// The loader is a classic script: it conditionally dynamic-imports the ES
|
||||
// module below and injects the stylesheet, so both the ~1 MB of MapLibre JS
|
||||
// and its CSS are only fetched on pages that actually render a map.
|
||||
// Detection happens in the DOM rather than in post content, which also
|
||||
// covers widgets, blocks, template parts and secondary loops. The
|
||||
// is_singular() check above is just a cheap best-effort early exit that
|
||||
// skips even the tiny loader request on obviously map-free singular pages;
|
||||
// it is not relied on for correctness.
|
||||
wp_enqueue_script(
|
||||
'openfreemap-script',
|
||||
$plugin_url . 'assets/openfreemap.js',
|
||||
'openfreemap-loader',
|
||||
plugin_dir_url(__FILE__) . 'assets/loader.js',
|
||||
array(),
|
||||
null,
|
||||
$load_in_footer
|
||||
openfreemap_plugin_version(),
|
||||
true
|
||||
);
|
||||
add_filter('script_loader_tag', function ($tag, $handle, $src) {
|
||||
if ($handle === 'openfreemap-script') {
|
||||
return '<script type="module" src="' . esc_url($src) . '"></script>';
|
||||
}
|
||||
return $tag;
|
||||
}, 10, 3);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'openfreemap_enqueue_shortcode_assets');
|
||||
|
||||
$module_url = openfreemap_versioned_url('assets/openfreemap.js');
|
||||
$style_href = openfreemap_versioned_url('vendor/maplibre-gl/maplibre-gl.css');
|
||||
|
||||
// JSON_HEX_TAG keeps the values from terminating the inline script early.
|
||||
wp_add_inline_script(
|
||||
'openfreemap-loader',
|
||||
'var openfreemapModuleUrl = ' . wp_json_encode($module_url, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES) . ';' .
|
||||
'var openfreemapStyleUrl = ' . wp_json_encode($style_href, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES) . ';',
|
||||
'before'
|
||||
);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'openfreemap_enqueue_assets');
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"maplibre-gl-shared.mjs","names":["unitBezier","create","glMatrix.ARRAY_TYPE","create","glMatrix.ARRAY_TYPE","clone","multiply","translate","scale","rotateX","rotateY","rotateZ","equals","create","glMatrix.ARRAY_TYPE","clone","length","fromValues","scale","normalize","dot","transformMat4","zero","forEach","create","glMatrix.ARRAY_TYPE","fromValues","multiply","scale","normalize","forEach","create","glMatrix.ARRAY_TYPE","fromValues","vec4.fromValues","vec4.normalize","vec3.create","vec3.fromValues","vec3.dot","vec3.len","mat3.create","glMatrix.ARRAY_TYPE","dot","EXTENT","EXTENT","mat3.determinant","vec3.cross","vec3.scale","clamp","unitBezierFactory","wrap","vec2.fromValues","vec2.dot","clamp","swap","classifyRings","types","mercatorXfromLng","mercatorYfromLat","latFromMercatorY","TinyQueue","TinyQueue","classifyRings","styleSpec","interpolates","createVisibilityExpression","paint","getPaint","styleSpec","properties","align","layout","members","size","alignment","clamp","murmur3","sort","swap","clamp","EXTENT","clamp","layoutAttributes","projectQueryGeometry","layout","getLayout","styleSpec","paint","getPaint","properties","projectQueryGeometry","paint","getPaint","styleSpec","properties","paint","getPaint","styleSpec","properties","paint","getPaint","styleSpec","properties","layout","members","size","alignment","signedArea","EXTENT","EARCUT_MAX_RINGS","layoutAttributes","classifyRings","layout","getLayout","styleSpec","paint","getPaint","properties","layout","members","size","alignment","EXTENT","wrap","EXTENT","clamp","EXTENT","addVertex","layoutAttributes","classifyRings","layout","getLayout","styleSpec","paint","getPaint","properties","clipPoints","clipLine","clipLines","addFeature","members","size","alignment","layoutAttributesExt","layoutAttributes","EXTENT","layout","getLayout","styleSpec","paint","getPaint","properties","TEXT_DECODER_MIN_LENGTH","utf8TextDecoder","readUtf8","interpolates","clamp","interpolates","Queue","EXTENT","classifyRings","murmur3","styleSpec","paint","getPaint","properties","styleSpec","properties","EXTENT","PAGE_SIZE","BYTE_CONTAINER_SIZE","decodeString","decodeString","decodeString","decodeString","decodeString","decodeString","decodeString","EXTENT"],"sources":["../node_modules/@mapbox/point-geometry/index.js","../node_modules/@mapbox/unitbezier/index.js","../src/util/offscreen_canvas_supported.ts","../src/util/offscreen_canvas_distorted.ts","../node_modules/gl-matrix/esm/common.js","../node_modules/gl-matrix/esm/mat3.js","../node_modules/gl-matrix/esm/mat4.js","../node_modules/gl-matrix/esm/vec3.js","../node_modules/gl-matrix/esm/vec4.js","../node_modules/gl-matrix/esm/quat.js","../node_modules/gl-matrix/esm/vec2.js","../src/data/extent.ts","../src/source/pixels_to_tile_units.ts","../src/util/util.ts","../src/util/abort_error.ts","../src/util/config.ts","../src/source/protocol_crud.ts","../src/util/ajax.ts","../src/util/evented.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/reference/v8.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/reference/latest.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/util/ref_properties.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/error/validation_error.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/color_spaces.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/util/get_own.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/parse_css_color.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/util/interpolate-primitives.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/color.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/formatted.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/padding.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/number_array.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/color_array.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/runtime_error.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/variable_anchor_offset_collection.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/resolved_image.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/projection_definition.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/types/collator.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/values.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/definitions/literal.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/evaluation_context.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/stops.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/expression/definitions/step.mLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"maplibre-gl-worker.mjs","names":[],"sources":["../node_modules/@maplibre/maplibre-gl-style-spec/dist/group_by_layout.mjs","../src/style/style_layer_index.ts","../src/render/glyph_atlas.ts","../src/source/worker_tile.ts","../src/source/worker_tile_state.ts","../src/util/request_performance.ts","../src/source/vector_tile_overzoomed.ts","../src/source/vector_tile_worker_source.ts","../src/source/raster_dem_tile_worker_source.ts","../src/source/geojson_worker_source.ts","../src/source/worker.ts"],"sourcesContent":["import { refProperties } from \"./util/ref_properties.mjs\";\n//#region src/group_by_layout.ts\nfunction stringify(obj) {\n\tconst type = typeof obj;\n\tif (type === \"number\" || type === \"boolean\" || type === \"string\" || obj === void 0 || obj === null) return JSON.stringify(obj);\n\tif (Array.isArray(obj)) {\n\t\tlet str = \"[\";\n\t\tfor (const val of obj) str += `${stringify(val)},`;\n\t\treturn `${str}]`;\n\t}\n\tconst keys = Object.keys(obj).sort();\n\tlet str = \"{\";\n\tfor (let i = 0; i < keys.length; i++) str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`;\n\treturn `${str}}`;\n}\nfunction getKey(layer) {\n\tlet key = \"\";\n\tfor (const k of refProperties) key += `/${stringify(layer[k])}`;\n\treturn key;\n}\n/**\n* Groups layers by their layout-affecting properties.\n* These are the properties that were formerly used by explicit `ref` mechanism\n* for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n* 'filter', and 'layout'.\n*\n* The input is not modified. The output layers are references to the\n* input layers.\n*\n* @param layers - an array of {@link LayerSpecification}.\n* @param cachedKeys - an object to keep already calculated keys.\n* @returns an array of arrays of {@link LayerSpecification} objects, where each inner array\n* contains layers that share the same layout-affecting properties.\n*/\nfunction groupByLayout(layers, cachedKeys) {\n\tconst groups = {};\n\tfor (let i = 0; i < layers.length; i++) {\n\t\tconst k = cachedKeys && cachedKeys[layers[i].id] || getKey(layers[i]);\n\t\tif (cachedKeys) cachedKeys[layers[i].id] = k;\n\t\tlet group = groups[k];\n\t\tif (!group) group = groups[k] = [];\n\t\tgroup.push(layers[i]);\n\t}\n\tconst result = [];\n\tfor (const k in groups) result.push(groups[k]);\n\treturn result;\n}\n//#endregion\nexport { groupByLayout };\n\n//# sourceMappingURL=group_by_layout.mjs.map","import {createStyleLayer} from './create_style_layer.ts';\nimport {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec';\nimport {GEOJSON_TILE_LAYER_NAME} from '../data/feature_index.ts';\n\nimport type {StyleLayer} from './style_layer.ts';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LayerConfigs = {[_: string]: LayerSpecification};\n\nexport class StyleLayerIndex {\n familiesBySource: {\n [source: string]: {\n [sourceLayer: string]: StyleLayer[][];\n };\n };\n keyCache: {[source: string]: string};\n\n _layerConfigs: LayerConfigs;\n _layers: {[_: string]: StyleLayer};\n\n constructor(layerConfigs?: LayerSpecification[] | null, globalState?: Record<string, any>) {\n this.keyCache = {};\n if (layerConfigs) {\n this.replace(layerConfigs, globalState);\n }\n }\n\n replace(layerConfigs: LayerSpecification[], globalState?: Record<string, any>): void {\n this._layerConfigs = {};\n this._layers = {};\n this.update(layerConfigs, [], globalState);\n }\n\n update(layerConfigs: LayerSpecification[], removedIds: string[], globalState?: Record<string, any>): void {\n for (const layerConfig of layerConfigs) {\n this._layerConfigs[layerConfig.id] = layerConfig;\n\n const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig, globalState);\n layer._featureFilter = featureFilter(layer.filter, `layers[${layerConfig.id}].filter`, globalState);\n if (this.keyCache[layerConfig.id])\n delete this.keyCache[layerConfig.id];\n }\n for (const id of removedIds) {\n delete this.keyCache[id];\n delete this._layerConfigs[id];\n delete this._layers[id];\n }\n\n this.familiesBySource = {};\n\n const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache);\n\n for (const layerConfigs of groups) {\n const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]);\n\n const layer = layers[0];\n if (layer.isHidden()) {\n continue;\n }\n\n const sourceId = layer.source || '';\n let sourceGroup = this.familiesBySource[sourceId];\n sourceGroup ||= this.familiesBySource[sourceId] = {};\n\n const sourceLayerId = layer.sourceLayer || GEOJSON_TILE_LAYER_NAME;\n let sourceLayerFamilies = sourceGroup[sourLine truncated
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"maplibre-gl.mjs","names":["create","glMatrix.ARRAY_TYPE","v8","properties","getProperties","styleSpec","getProperties","properties","getProperties","styleSpec","getProperties","mat4.create","mat4.multiply","determinant","mat2.determinant","deserializeBucket","vec3.scale","vec3.add","vec3.clone","vec3.sub","vec3.normalize","vec3.cross","vec3.dot","vec4.transformMat4","vec4.mul","vec3.length","vec3.len","vec4.scale","vec3.scale","vec3.add","vec2.sqrLen","createSource","mat4.create","mat2.create","vec2.create","vec2.length","symbolSize.evaluateSizeForZoom","symbolSize.evaluateSizeForFeature","intersectionTests.polygonIntersectsPolygon","mat4.identity","projection.getPitchedLabelPlaneMatrix","symbolSize.evaluateSizeForZoom","symbolSize.evaluateSizeForFeature","preludeFrag","preludeVert","projectionMercatorFrag","projectionMercatorVert","projectionGlobeFrag","projectionGlobeVert","backgroundFrag","backgroundVert","backgroundPatternFrag","backgroundPatternVert","circleFrag","circleVert","clippingMaskFrag","clippingMaskVert","heatmapFrag","heatmapVert","heatmapTextureFrag","heatmapTextureVert","collisionBoxFrag","collisionBoxVert","collisionCircleFrag","collisionCircleVert","colorReliefFrag","colorReliefVert","debugFrag","debugVert","depthVert","fillFrag","fillVert","fillOutlineFrag","fillOutlineVert","fillOutlinePatternFrag","fillOutlinePatternVert","fillPatternFrag","fillPatternVert","fillExtrusionFrag","fillExtrusionVert","fillExtrusionPatternFrag","fillExtrusionPatternVert","hillshadePrepareFrag","hillshadePrepareVert","hillshadeFrag","hillshadeVert","lineFrag","lineVert","lineGradientFrag","lineGradientVert","linePatternFrag","linePatternVert","lineSDFFrag","lineSDFVert","lineGradientSDFFrag","lineGradientSDFVert","layerOpacityFrag","layerOpacityVert","rasterFrag","rasterVert","symbolIconFrag","symbolIconVert","symbolSDFFrag","symbolSDFVert","symbolTextAndIconFrag","symbolTextAndIconVert","terrainFrag","terrainVert","terrainDepthFrag","terrainVertDepth","atmosphereFrag","atmosphereVert","skyFrag","skyVert","interpolates","mat2.create","mat4.identity","mat4.fromScaling","mat4.identity","interpolates","vec4.transformMat4","mat4.clone","mat4.scale","mat4.multiply","mat4.invert","vec3.clone","scale","interpolates","interpolates","styleSpec","dot","vec3.dot","vec4.transformMat4","quat.fromEuler","vec3.length","vec3.cross","quat.fromValues","quat.multiply","vec3.len","quat.fromEuler","vec3.transformQuat","vec3.scale","vec3.dot","vec3.scale","vec3.cross","dot","vec3.dot","vec3.length","mat4.clone","vec3.scale","vec3.subtract","distance","vec3.distance","vec3.dot","vec3.dot","vec3.length","interpolates","deepEqual","clone","diffStyles","mat4.exactEquals","layout","offsets","layout","offsets","mat3.create","mat4.create","mat4.create","deepEqual","ALWAYS","mat4.identity","mat4.create","mat4.identity","mat4.identity","mat4.create","mat4.equals","LEFT_BUTTON","RIGHT_BUTTON","defaultZoomRate","defaultOptions","defaultZoomRate","interpolates","interpolates","version","packageJSON.version","defaultOptions","Map","defaultOptions","defaultOptions","defaultOptions","packageJSON.version"],"sources":["../package.json","../node_modules/gl-matrix/esm/mat2.js","../src/util/browser.ts","../src/util/time_control.ts","../src/util/dom.ts","../src/util/image_request.ts","../src/util/request_manager.ts","../src/ui/events.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/deref.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/util/deep_equal.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/diff.mjs","../node_modules/@maplibre/maplibre-gl-style-spec/dist/empty.mjs","../src/util/style.ts","../src/style/load_sprite.ts","../src/render/image_manager.ts","../src/render/pattern_atlas.ts","../src/render/font_face_manager.ts","../node_modules/@mapbox/tiny-sdf/index.js","../src/render/glyph_manager.ts","../src/style/light_properties.g.ts","../src/style/light.ts","../src/style/sky_properties.g.ts","../src/style/sky.ts","../src/render/line_atlas.ts","../src/util/web_worker.ts","../src/util/worker_pool.ts","../src/util/global_worker_pool.ts","../src/util/dispatcher.ts","../src/source/query_features.ts","../src/source/load_tilejson.ts","../src/geo/lng_lat_bounds.ts","../src/tile/tile_bounds.ts","../src/source/vector_tile_source.ts","../src/source/raster_tile_source.ts","../src/source/raster_dem_tile_source.ts","../src/source/geojson_source_diff.ts","../src/util/geojson_bounds.ts","../src/tile/tile_id_to_lng_lat_bounds.ts","../src/source/geojson_source.ts","../src/webgl/program/raster_program.ts","../src/render/mesh.ts","../src/data/pos_attributes.ts","../src/util/create_tile_mesh.ts","../src/source/image_source.ts","../src/source/video_source.ts","../src/source/canvas_source.ts","../src/source/source.ts","../src/data/bucket.ts","../src/source/rtl_text_plugin_status.ts","../src/source/rtl_text_plugin_main_thread.ts","../src/tile/tile.ts","../src/source/source_state.ts","../src/util/primitives/aabb.ts",Line truncated
|
||||
Reference in new issue
Block a user