Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #286 from QwantResearch/easter-egg
Browse files Browse the repository at this point in the history
Add "fraicheur" layer via url param
  • Loading branch information
GuillaumeGomez authored Jun 26, 2019
2 parents 2d921ee + d766031 commit 32c731c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ server:

app:
versionFlag: Beta
easterEggs: true

# Services
services:
Expand Down
Binary file added public/images/sorbet_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/adapters/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import DirectionPoi from './poi/specials/direction_poi';
import UrlShards from '../proxies/url_shards';
import Error from '../adapters/error';
import { createIcon } from '../adapters/icon_manager';
import SceneEasterEgg from './scene_easter_egg';

const performanceEnabled = nconf.get().performance.enabled;
const baseUrl = nconf.get().system.baseUrl;
const easterEggsEnabled = nconf.get().app.easterEggs;

const store = new LocalStore();

Expand Down Expand Up @@ -152,6 +154,11 @@ Scene.prototype.initMapBox = function() {
}
});

/* Easter egg for beta */
if (easterEggsEnabled) {
SceneEasterEgg.enableEggs(this.mb);
}

window.execOnMapLoaded = (f) => f();
fire('map_loaded');
});
Expand Down
71 changes: 71 additions & 0 deletions src/adapters/scene_easter_egg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import Error from '../adapters/error';

export default class MapEasterEgg {
static enableEggs(map) {
this.addIcecreamLayer(map);
}

static addIcecreamLayer(map) {
if (!URLSearchParams) {
return;
}
let urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('fraicheur') === null) {
return;
}
map.removeLayer('poi-level-1');
map.setFilter('poi-level-2', ['boolean', false]);
map.setFilter('poi-level-3', ['boolean', false]);

map.loadImage(`${window.baseUrl}statics/images/sorbet_64.png`, (error, image) => {
if (error) {
Error.sendOnce('scene', 'easter_egg', 'Failed to load image', error);
return;
}
map.addImage('icecream_easter_egg', image);

map.addLayer({
'id': 'poi-level-1',
'type': 'symbol',
'source': 'poi',
'source-layer': 'poi',
'minzoom': 14,
'filter': [
'all',
[
'==',
'$type',
'Point',
],
[
'in',
'subclass',
'ice_cream',
],
],
'layout': {
'text-size': 15,
'icon-image': 'icecream_easter_egg',
'text-font': [
'Noto Sans Regular',
],
'text-padding': 2,
'text-offset': [
0,
2.5,
],
'text-anchor': 'top',
'text-field': '{name}',
'text-optional': true,
'text-max-width': 12,
},
'paint': {
'text-halo-blur': 0.5,
'text-color': '#4ba2ea',
'text-halo-width': 1,
'text-halo-color': '#ffffff',
},
});
});
}
}

0 comments on commit 32c731c

Please sign in to comment.