Skip to content

Commit

Permalink
symbol is styled differently now. include a few twemoji icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
arichnad committed Dec 9, 2023
1 parent 22524d9 commit 2ad4152
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/cyclemaps.js

Large diffs are not rendered by default.

Binary file added sprite/2197.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sprite/2197.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprite/2198.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sprite/2198.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprite/27a1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sprite/27a1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 34 additions & 6 deletions src/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class LayerButton extends Button {
const description = features[0].properties.description;

if(geometry.type == 'Point') {
new Popup()
new Popup({maxWidth: 'none'})
.setLngLat(geometry.coordinates as [number,number])
.setHTML(description)
.addTo(map);
Expand All @@ -174,16 +174,16 @@ class LayerButton extends Button {
getOptions(type: string) {
if(type == 'symbol') {
return {'layout': {
'icon-image': ["concat", ["coalesce", ["get", "marker-symbol"], "marker"], "_11"],
'icon-size': 1.5,
'icon-image': ["coalesce", ["get", "icon-image"], "marker_11"],
'icon-size': ["coalesce", ["get", "icon-size"], 1],
'text-field': '{title}',
'icon-allow-overlap': true,
'text-allow-overlap': true,
'text-anchor': 'top',
'text-font': ['Open Sans Regular'],
'text-max-width': 9,
'icon-offset': [0, -3],
'text-offset': [0, .2],
'text-offset': [0, .75],
'text-padding': 2,
'text-size': 12,
},
Expand Down Expand Up @@ -388,7 +388,6 @@ export class ButtonControl implements IControl {
//this.container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');
this.container = document.createElement('div');
this.container.className = 'maplibregl-ctrl';
this.checkAddGeoJsonLayer();
this.checkAddButtons();
this.setupButtons();
return this.container;
Expand All @@ -404,7 +403,7 @@ export class ButtonControl implements IControl {
if(geoJsonData === null) {
return;
}
this.map!.on('style.load', (event: Event) => this.addLayerHelper('geoJsonData', type, geoJsonData!));
this.addLayerHelper('geoJsonData', type, geoJsonData!);
}

checkAddButtons() {
Expand All @@ -419,6 +418,8 @@ export class ButtonControl implements IControl {
});
this.map!.on('load', (event: Event) => {
this.addLayerButtons(data.buttons);
this.setupIcons();
this.checkAddGeoJsonLayer();
});
});
}
Expand Down Expand Up @@ -525,4 +526,31 @@ export class ButtonControl implements IControl {
button.buttonElement.classList.contains('active'))
.forEach(button => button.deselect())
}

setupIcons() {
this.map!.loadImage('sprite/2197.png', (error, image) => {
if (error) throw error;
if(image == null) {
console.error('trouble loading image');
return;
}
this.map!.addImage('upright', image);
});
this.map!.loadImage('sprite/2198.png', (error, image) => {
if (error) throw error;
if(image == null) {
console.error('trouble loading image');
return;
}
this.map!.addImage('downright', image);
});
this.map!.loadImage('sprite/27a1.png', (error, image) => {
if (error) throw error;
if(image == null) {
console.error('trouble loading image');
return;
}
this.map!.addImage('right', image);
});
}
}

0 comments on commit 2ad4152

Please sign in to comment.