Many improvements: navbar, favico, new icons
This commit is contained in:
parent
3dc8edb4a8
commit
f1786541cd
20 changed files with 161 additions and 83 deletions
47
imports/startup/client/Gkeys.js
Normal file
47
imports/startup/client/Gkeys.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import React from 'react';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import i18n from 'i18next';
|
||||
|
||||
const gmapkey = new ReactiveVar();
|
||||
|
||||
Meteor.startup(function() {
|
||||
Meteor.call('getMapKey', function (error, key) {
|
||||
if (typeof key !== 'undefined') {
|
||||
// console.log(key);
|
||||
gmapkey.set(key);
|
||||
} else {
|
||||
callback(error, null)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
class GkeysC {
|
||||
constructor() {
|
||||
this.state = { init: false };
|
||||
}
|
||||
|
||||
load(callback) {
|
||||
if (this.state.init) {
|
||||
// already loaded
|
||||
callback(null, gmapkey.get());
|
||||
} else {
|
||||
this.state.init = true;
|
||||
Meteor.autorun(function() {
|
||||
var key = gmapkey.get();
|
||||
if (typeof key !== 'undefined') {
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.onload = function () {
|
||||
// console.log(key);
|
||||
callback(null, key);
|
||||
}.bind(this);
|
||||
// https://stackoverflow.com/questions/28130114/google-maps-places-autocomplete-language-output
|
||||
script.src = `https://maps.googleapis.com/maps/api/js?key=${key}&libraries=places&language=${i18n.language}`
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let Gkeys = new GkeysC();
|
||||
Loading…
Add table
Add a link
Reference in a new issue