Subs form (wip)
This commit is contained in:
parent
3d86418d22
commit
df96b6e51e
14 changed files with 530 additions and 75 deletions
18
imports/startup/client/geolocation.js
Normal file
18
imports/startup/client/geolocation.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
const geolocation = new ReactiveVar();
|
||||
|
||||
Meteor.startup(function() {
|
||||
Meteor.call("geo", function (error, response) {
|
||||
if (error) {
|
||||
console.warn(error);
|
||||
} else {
|
||||
var pos = [
|
||||
response.location.latitude,
|
||||
response.location.longitude
|
||||
];
|
||||
geolocation.set(pos);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export default geolocation;
|
||||
34
imports/startup/client/gkeys.js
Normal file
34
imports/startup/client/gkeys.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
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)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var getGKeys = function (callback) {
|
||||
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);
|
||||
};
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default getGKeys;
|
||||
|
|
@ -75,7 +75,7 @@ i18n.use(backend)
|
|||
whitelist: false,
|
||||
// whitelist: ['es', 'en'], // allowed languages
|
||||
load: 'all', // es-ES -> es, en-US -> en
|
||||
debug: true,
|
||||
debug: false,
|
||||
ns: 'common',
|
||||
defaultNS: 'common',
|
||||
saveMissing: true, // if true seems it's fails to getResourceBundle
|
||||
|
|
|
|||
|
|
@ -40,4 +40,11 @@ Meteor.methods({
|
|||
})
|
||||
return promise.await();
|
||||
},
|
||||
getMapKey: function () {
|
||||
// http://meteorpedia.com/read/Environment_Variables
|
||||
// https://developers.google.com/maps/documentation/javascript/get-api-key
|
||||
// https://console.developers.google.com/
|
||||
// export GMAPS_KEY=SomeGMapsKey
|
||||
return process.env.GMAPS_KEY || Meteor.settings.gmaps.key;;
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue