Gathering detailed insights and metrics for ol-themes-ext
Gathering detailed insights and metrics for ol-themes-ext
Gathering detailed insights and metrics for ol-themes-ext
Gathering detailed insights and metrics for ol-themes-ext
npm install ol-themes-ext
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
3 Stars
64 Commits
1 Forks
2 Watchers
2 Branches
2 Contributors
Updated on Sep 23, 2022
Latest Version
0.1.32
Package Id
ol-themes-ext@0.1.32
Unpacked Size
152.04 kB
Size
31.52 kB
File Count
20
NPM Version
6.14.17
Node Version
14.19.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This package extends openlayers map objects to allow for a configuration driven addition of layers as well as some layer management.
This currently only supports ol 6.14. This package adds support to configure map layers into "themes" via json.
https://codesandbox.io/s/ol-themes-ext-v003-example-gvgr2
1import Map from 'ol/Map' 2import Themes from 'ol-themes-ext' 3 4let map = new Map({ 5 target: 'mapRoot', 6 layers: [ 7 // adding a background tiled layer 8 new TileLayer({ 9 source: new TileArcGISRest({ url: 'https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer' }) 10 // source: new OSM(), // tiles are served by OpenStreetMap 11 }), 12 ], 13 view: new View({ 14 center: fromLonLat([Number(-98.585522), 39.8333333]), 15 zoom: 2, 16 constrainResolution: true, 17 }), 18 }); 19 20let config = { 21 "layers": [ 22 { 23 "key": "lyr_auto_basemap", 24 "xyz": { 25 "endpoints": [ 26 { 27 "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}", 28 "zIndex": 10, 29 "zoom": { 30 "max": 8 31 } 32 }, 33 { 34 "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}", 35 "zIndex": 10, 36 "zoom": { 37 "min": 8 38 } 39 } 40 ] 41 }, 42 "name": "Light Gray to Topo", 43 "opacity": 1, 44 }, 45 { 46 "key": "lyr_esri_streets", 47 "xyz": { 48 "endpoints": [ 49 { 50 "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}", 51 "zIndex": 10 52 } 53 ] 54 }, 55 "name": "Streets", 56 "opacity": 1, 57 }, 58 { 59 "key": "lyr_esri_world_image", 60 "xyz": { 61 "endpoints": [ 62 { 63 "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", 64 "zIndex": 10, 65 } 66 ] 67 }, 68 "name": "Aerial", 69 "opacity": 1, 70 } 71 ], 72 "layerGroups": [ 73 { 74 "key": "grp_basemaps", 75 "name": null, 76 "layers": [ 77 "lyr_esri_streets", 78 "lyr_esri_world_image", 79 "lyr_auto_basemap" 80 ], 81 "openness": "closed" 82 }, 83 { 84 "key": "grp_reference", 85 "name": null, 86 "layers": [ 87 ], 88 "openness": "open" 89 } 90 ], 91 "layerCategories": [ 92 { 93 "key": "cat_basemaps", 94 "name": "Basemaps", 95 "hidden": false, 96 "infoIcon": { 97 "iconClass": "fa fa-info-circle fa-lg" 98 }, 99 "openness": "open", 100 "activeIcon": { 101 "iconClass": "fa fa-circle" 102 }, 103 "layerGroups": [ 104 "grp_basemaps" 105 ], 106 "multiphasic": false, 107 "transparency": 1, 108 "selectiveness": "monoselective", 109 "defaultSelection": [ 110 "lyr_esri_world_image" 111 ], 112 "usesRasterLegend": false, 113 "mustHaveSelection": false 114 } 115 ] 116} 117 118//Extend the open layers map with the themes extension 119map = new Themes(map); 120 121//Pass in the config and get an array of categories back 122let categories = map.themes.initCategories(config); 123 124let basemaps = map.getCategoryByKey("cat_basemaps"); 125 126//Map will add the 4 above layers in a layer group, the returned value is an array of the categories from the config 127 128//Additionally at this point the map should be displaying the esri world image layer 129 130//Select the auto basemap layer 131// This layer will switch from light grey to topo at zoom level 8 132basemaps.selectLayer("lyr_auto_basemap"); 133 134 135//For a MVT layer you can run this to get all the features currently rendered 136let featuresInView = my_mvt_layer.getFeaturesInView(); 137 138//For a MVT layer you can tie to a click event to get the features clicked on 139map.on('click', async function (evt) { 140 let featuresClickedOn = await my_mvt_layer.getFeaturesUnderPixel(evt.pixel); 141}); 142 143//Filtering 144// Suppose you have a category with a key of cat_test 145// In that category you have a layer with a key of lyr_test 146// The layer's features have a property named "County" 147// The property contains a string representation of the county in which the feature lies 148 149// One could filter the displayed features to a county named or containing "Iron" by doing the following 150window.map.themes.getCategoryByKey("cat_test").getLayerByKey("lyr_test").filter.when("County").contains("Iron"); 151 152// If you wanted only "Iron" exactly 153window.map.themes.getCategoryByKey("cat_test").getLayerByKey("lyr_test").filter.when("County").exactly("Iron"); 154 155// If you want to display any feature that was in Iron or Cache or any combination of the two 156window.map.themes.getCategoryByKey("cat_test").getLayerByKey("lyr_test").filter.when("County").containsAny([ "Iron", "Cache" ]); 157 158// If you later decide to remove the filter on the county field you can call clear on when 159window.map.themes.getCategoryByKey("cat_test").getLayerByKey("lyr_test").filter.when("County").clear(); 160 161// Or If you want to remove all filters 162window.map.themes.getCategoryByKey("cat_test").getLayerByKey("lyr_test").filter.clear(); 163
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
40 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More