Add support to view other attributions

feature/threejs-update
Matthew Harrison-Jones 2016-09-15 17:04:17 +01:00
rodzic 4f98bee863
commit 2aa7406b5c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 2BFA474C82C30A2C
4 zmienionych plików z 53 dodań i 5 usunięć

Wyświetl plik

@ -88,6 +88,7 @@
"lodash.throttle": "^4.0.0",
"lru-cache": "^4.0.0",
"reqwest": "^2.0.5",
"shortid": "^2.2.6",
"three": "^0.74.0",
"topojson": "^1.6.24",
"xhr2": "^0.1.3"

Wyświetl plik

@ -49,14 +49,22 @@ class World extends EventEmitter {
}
_initAttribution() {
var message = '<a href="http://vizicities.com" target="_blank">Powered by ViziCities</a>';
var message = '<a href="http://vizicities.com" target="_blank">ViziCities</a> | <a id="show-attr" href="#">Attribution</a>';
var element = document.createElement('div');
element.classList.add('vizicities-attribution');
var additionalElem = document.createElement('div');
additionalElem.id = 'attribution-container';
element.innerHTML = message;
element.appendChild(additionalElem);
this._container.appendChild(element);
document.getElementById('show-attr').addEventListener('click', function(e) {
e.currentTarget.parentNode.classList.toggle('is-visible');
});
}
_initEngine() {
@ -133,6 +141,21 @@ class World extends EventEmitter {
this.emit('postUpdate', delta);
}
_addAttribution(id, message) {
var container = document.getElementById('attribution-container');
var span = document.createElement('p');
span.dataset.layer = id;
span.innerHTML = message;
container.appendChild(span);
}
_removeAttribution(id) {
var elem = document.querySelectorAll('#attribution-container [data-layer="' + id + '"]')[0];
elem.remove();
}
// Set world view
setView(latlon) {
// Store initial geographic coordinate for the [0,0,0] world position
@ -230,6 +253,9 @@ class World extends EventEmitter {
return new Promise((resolve, reject) => {
layer._addToWorld(this).then(() => {
if (layer._options.attribution) {
this._addAttribution(layer._options.id, layer._options.attribution);
}
this.emit('layerAdded', layer);
resolve(this);
}).catch(reject);

Wyświetl plik

@ -1,5 +1,6 @@
import EventEmitter from 'eventemitter3';
import extend from 'lodash.assign';
import shortid from 'shortid';
import THREE from 'three';
import Scene from '../engine/Scene';
import {CSS3DObject} from '../vendor/CSS3DRenderer';
@ -23,6 +24,7 @@ class Layer extends EventEmitter {
super();
var defaults = {
id: shortid.generate(),
output: true,
outputToScene: true
};

Wyświetl plik

@ -1,4 +1,5 @@
.vizicities-attribution {
position: relative;
background: rgba(255, 255, 255, 0.9);
border-radius: 3px 0 0;
bottom: 0;
@ -16,7 +17,25 @@
text-decoration: none;
}
.vizicities-attribution a:hover {
color: #2bb2ed;
text-decoration: underline;
}
.vizicities-attribution a:hover {
color: #2bb2ed;
text-decoration: underline;
}
#attribution-container {
position: absolute;
right: 0;
bottom: 0;
z-index: -1;
width: 250px;
padding: 4px 7px;
padding-right: 120px;
background: rgba(255, 255, 255, 0.9);
border-radius: 3px 0 0;
opacity: 0;
transition: opacity 100ms linear;
}
.is-visible #attribution-container {
opacity: 1;
}