Use same data as in mapbox-style example

This commit is contained in:
Andreas Hocevar
2020-03-22 20:11:07 +01:00
parent ade9ac8857
commit 28f390828d
5 changed files with 170 additions and 138 deletions
+6 -32
View File
@@ -2,20 +2,6 @@
// http://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6.json
function createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text) {
let worker;
try {
worker = self.document ? null : self;
worker.addEventListener('message', message => {
if (message.data.type === 'imageLoaded') {
iconCache[message.data.iconName].setImage(new Icon({
img: message.data.image,
imgSize: [15, 15]
}));
}
});
} catch (e) {}
var fill = new Fill({color: ''});
var stroke = new Stroke({color: '', width: 1});
var polygon = new Style({fill: fill});
@@ -28,19 +14,11 @@ function createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text) {
function getIcon(iconName) {
var icon = iconCache[iconName];
if (!icon) {
if (!worker) {
icon = new Style({image: new Icon({
src: 'https://unpkg.com/@mapbox/maki@4.0.0/icons/' + iconName + '-15.svg',
imgSize: [15, 15],
crossOrigin: 'anonymous'
})});
} else {
icon = new Style({});
worker.postMessage({
type: 'loadImage',
iconName: iconName
});
}
icon = new Style({image: new Icon({
src: 'https://unpkg.com/@mapbox/maki@4.0.0/icons/' + iconName + '-15.svg',
imgSize: [15, 15],
crossOrigin: 'anonymous'
})});
iconCache[iconName] = icon;
}
return icon;
@@ -331,8 +309,4 @@ function createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text) {
styles.length = length;
return styles;
};
}
try {
module.exports = createMapboxStreetsV6Style;
} catch (e) {}
}