mapbox-gl-controls
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -24,7 +24,9 @@ function _classCallCheck(instance, Constructor) { | ||
var stylesDefault = [{ | ||
name: 'Streets', | ||
url: 'mapbox://styles/mapbox/streets-v9' | ||
label: 'Streets', | ||
styleName: 'Mapbox Streets', | ||
styleUrl: 'mapbox://styles/mapbox/streets-v9' | ||
}, { | ||
name: 'Satellite', | ||
url: 'mapbox://styles/mapbox/satellite-v9' | ||
label: 'Satellite', | ||
styleName: 'Satellite', | ||
styleUrl: 'mapbox://styles/mapbox/satellite-v9' | ||
}]; | ||
@@ -53,7 +55,7 @@ | ||
var node = document.createElement('button'); | ||
node.textContent = style.name; | ||
node.textContent = style.label; | ||
node.addEventListener('click', function () { | ||
if (node.classList.contains('-active')) return; | ||
_this.map.setStyle(style.url); | ||
_this.map.setStyle(style.styleUrl); | ||
}); | ||
@@ -75,15 +77,10 @@ | ||
[].forEach.call(_this2.container.querySelectorAll('button'), function (div) { | ||
return div.classList.remove('-active'); | ||
}); // remove GET params: ?optimize=true | ||
div.classList.remove('-active'); | ||
}); | ||
var styleUrls = _this2.styles.map(function (style) { | ||
if (typeof style.url === 'string') { | ||
var styleUrlSplit = style.url.split('?'); | ||
return styleUrlSplit.length > 0 ? styleUrlSplit[0] : style.url; | ||
} | ||
return style.url; | ||
var styleNames = _this2.styles.map(function (style) { | ||
return style.styleName; | ||
}); | ||
var currentStyleIndex = styleUrls.indexOf(_this2.map.getStyle().sprite.replace('sprites', 'styles')); | ||
var currentStyleIndex = styleNames.indexOf(_this2.map.getStyle().name); | ||
@@ -90,0 +87,0 @@ if (currentStyleIndex !== -1) { |
{ | ||
"name": "mapbox-gl-controls", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -31,5 +31,5 @@ "homepage": "https://bravecow.github.io/mapbox-gl-controls/", | ||
"peerDependencies": { | ||
"mapbox-gl": "^0.54.0" | ||
"mapbox-gl": "^0.54.0 <2.0.0" | ||
}, | ||
"repository": "bravecow/mapbox-gl-controls" | ||
} |
const stylesDefault = [ | ||
{ | ||
name: 'Streets', | ||
url: 'mapbox://styles/mapbox/streets-v9', | ||
label: 'Streets', | ||
styleName: 'Mapbox Streets', | ||
styleUrl: 'mapbox://styles/mapbox/streets-v9', | ||
}, { | ||
name: 'Satellite', | ||
url: 'mapbox://styles/mapbox/satellite-v9', | ||
label: 'Satellite', | ||
styleName: 'Satellite', | ||
styleUrl: 'mapbox://styles/mapbox/satellite-v9', | ||
}, | ||
@@ -24,6 +26,6 @@ ]; | ||
const node = document.createElement('button'); | ||
node.textContent = style.name; | ||
node.textContent = style.label; | ||
node.addEventListener('click', () => { | ||
if (node.classList.contains('-active')) return; | ||
this.map.setStyle(style.url); | ||
this.map.setStyle(style.styleUrl); | ||
}); | ||
@@ -39,12 +41,7 @@ this.nodes.push(node); | ||
this.map.on('styledata', () => { | ||
[].forEach.call(this.container.querySelectorAll('button'), div => div.classList.remove('-active')); | ||
// remove GET params: ?optimize=true | ||
const styleUrls = this.styles.map(style => { | ||
if (typeof style.url === 'string') { | ||
const styleUrlSplit = style.url.split('?'); | ||
return styleUrlSplit.length > 0 ? styleUrlSplit[0] : style.url; | ||
} | ||
return style.url; | ||
[].forEach.call(this.container.querySelectorAll('button'), (div) => { | ||
div.classList.remove('-active'); | ||
}); | ||
const currentStyleIndex = styleUrls.indexOf(this.map.getStyle().sprite.replace('sprites', 'styles')); | ||
const styleNames = this.styles.map(style => style.styleName); | ||
const currentStyleIndex = styleNames.indexOf(this.map.getStyle().name); | ||
if (currentStyleIndex !== -1) { | ||
@@ -51,0 +48,0 @@ const currentNode = this.nodes[currentStyleIndex]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48843
1329