Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

ol-mapbox-style

Package Overview
Dependencies
Maintainers
4
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ol-mapbox-style - npm Package Compare versions

Comparing version 10.0.0 to 10.1.0

8

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

## 10.1.0
* New `removeMapboxLayer()` function
* Substantial fixes to the `addMapboxLayer()` function
* Manage OpenLayers layer visibility based on the visibility of its Mapbox layers
## 10.0.0

@@ -10,3 +16,3 @@

#### BBOX templates for `geojson` souurces
#### BBOX templates for `geojson` sources

@@ -13,0 +19,0 @@ Previously, the `{bbox-epsg-3857}` and `{bbox-epsg-[custom projection srs code]}` template replacement included the projection's SRS identifier, e.g. `1234,4567,4321,7654,EPSG:9876`. Now, the template replacement just includes the bounding box. This means that e.g. WFS source URLs need to be changed in the Mapbox style.

12

dist/apply.d.ts

@@ -180,4 +180,4 @@ /**

/**
* Add a new Mapbox Layer object to the style.
* @param {Map|LayerGroup} mapOrGroup Map or LayerGroup.
* Add a new Mapbox Layer object to the style. The map will be re-rendered.
* @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.
* @param {Object} mapboxLayer Mapbox Layer object.

@@ -189,6 +189,12 @@ * @param {string} [beforeLayerId] Optional id of the Mapbox Layer before the new layer that will be added.

* Update a Mapbox Layer object in the style. The map will be re-rendered with the new style.
* @param {Map|LayerGroup} mapOrGroup Map or LayerGroup.
* @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.
* @param {Object} mapboxLayer Updated Mapbox Layer object.
*/
export function updateMapboxLayer(mapOrGroup: Map | LayerGroup, mapboxLayer: any): void;
/**
* Remove a Mapbox Layer object from the style. The map will be re-rendered.
* @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.
* @param {string|Object} mapboxLayerIdOrLayer Mapbox Layer id or Mapbox Layer object.
*/
export function removeMapboxLayer(mapOrGroup: Map | LayerGroup, mapboxLayerIdOrLayer: string | any): void;
export { finalizeLayer as _finalizeLayer };

@@ -195,0 +201,0 @@ export type FeatureIdentifier = {

{
"name": "ol-mapbox-style",
"version": "10.0.0",
"version": "10.1.0",
"description": "Create OpenLayers maps from Mapbox Style objects",

@@ -5,0 +5,0 @@ "type": "module",

@@ -138,3 +138,3 @@ # ol-mapbox-style

Add a new Mapbox Layer object to the style.
Add a new Mapbox Layer object to the style. The map will be re-rendered.

@@ -145,3 +145,3 @@ ##### Parameters

| :--------------- | :-------------------- | :----------------------------------------------------------------------- |
| `mapOrGroup` | `Map` \| `LayerGroup` | Map or LayerGroup. |
| `mapOrGroup` | `Map` \| `LayerGroup` | The Map or LayerGroup `apply` was called on. |
| `mapboxLayer` | `any` | Mapbox Layer object. |

@@ -539,6 +539,6 @@ | `beforeLayerId?` | `string` | Optional id of the Mapbox Layer before the new layer that will be added. |

| Name | Type | Description |
| :------------ | :-------------------- | :--------------------------- |
| `mapOrGroup` | `Map` \| `LayerGroup` | Map or LayerGroup. |
| `mapboxLayer` | `any` | Updated Mapbox Layer object. |
| Name | Type | Description |
| :------------ | :-------------------- | :------------------------------------------- |
| `mapOrGroup` | `Map` \| `LayerGroup` | The Map or LayerGroup `apply` was called on. |
| `mapboxLayer` | `any` | Updated Mapbox Layer object. |

@@ -545,0 +545,0 @@ ##### Returns

@@ -23,2 +23,3 @@ /*

import View from 'ol/View.js';
import derefLayers from '@mapbox/mapbox-gl-style-spec/deref.js';
import {

@@ -808,2 +809,23 @@ METERS_PER_UNIT,

function manageVisibility(layer, mapOrGroup) {
layer.on('change', function () {
const mapboxLayers = derefLayers(mapOrGroup.get('mapbox-style').layers);
const layerMapboxLayerids = layer.get('mapbox-layers');
const visible = mapboxLayers
.filter(function (mapboxLayer) {
return layerMapboxLayerids.includes(mapboxLayer.id);
})
.some(function (mapboxLayer) {
return (
!mapboxLayer.layout ||
!mapboxLayer.layout.visibility ||
mapboxLayer.layout.visibility === 'visible'
);
});
if (layer.get('visible') !== visible) {
layer.setVisible(visible);
}
});
}
/**

@@ -889,2 +911,3 @@ * @param {*} glStyle Mapbox Style.

layer = setupVectorLayer(glSource, styleUrl, options);
manageVisibility(layer, mapOrGroup);
} else if (glSource.type == 'raster') {

@@ -902,2 +925,3 @@ layerIds = [];

layer = setupGeoJSONLayer(glSource, styleUrl, options);
manageVisibility(layer, mapOrGroup);
} else if (

@@ -1316,4 +1340,4 @@ glSource.type == 'raster-dem' &&

/**
* Add a new Mapbox Layer object to the style.
* @param {Map|LayerGroup} mapOrGroup Map or LayerGroup.
* Add a new Mapbox Layer object to the style. The map will be re-rendered.
* @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.
* @param {Object} mapboxLayer Mapbox Layer object.

@@ -1344,2 +1368,9 @@ * @param {string} [beforeLayerId] Optional id of the Mapbox Layer before the new layer that will be added.

mapboxLayers.splice(index, 0, mapboxLayer);
const layer = getLayer(mapOrGroup, mapboxLayers[index - 1].id);
const layerMapboxLayers = layer.get('mapbox-layers');
const layerIndex = beforeLayerId
? layerMapboxLayers.indexOf(beforeLayerId)
: layerMapboxLayers.length;
layerMapboxLayers.splice(layerIndex, 0, mapboxLayer.id);
layer.changed();
}

@@ -1349,3 +1380,3 @@

* Update a Mapbox Layer object in the style. The map will be re-rendered with the new style.
* @param {Map|LayerGroup} mapOrGroup Map or LayerGroup.
* @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.
* @param {Object} mapboxLayer Updated Mapbox Layer object.

@@ -1374,2 +1405,29 @@ */

/**
* Remove a Mapbox Layer object from the style. The map will be re-rendered.
* @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.
* @param {string|Object} mapboxLayerIdOrLayer Mapbox Layer id or Mapbox Layer object.
*/
export function removeMapboxLayer(mapOrGroup, mapboxLayerIdOrLayer) {
const mapboxLayerId =
typeof mapboxLayerIdOrLayer === 'string'
? mapboxLayerIdOrLayer
: mapboxLayerIdOrLayer.id;
const layer = getLayer(mapOrGroup, mapboxLayerId);
/** @type {Array<Object>} */
const layerMapboxLayers = layer.get('mapbox-layers');
if (layerMapboxLayers.length === 1) {
throw new Error(
'Cannot remove last Mapbox layer from an OpenLayers layer.'
);
}
layerMapboxLayers.splice(layerMapboxLayers.indexOf(mapboxLayerId), 1);
const layers = mapOrGroup.get('mapbox-style').layers;
layers.splice(
layers.findIndex((layer) => layer.id === mapboxLayerId),
1
);
layer.changed();
}
export {finalizeLayer as _finalizeLayer};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc