Skip to content

Instantly share code, notes, and snippets.

/main.js Secret

Created November 7, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/710a1998c4c7afe177b99d86f0024ce0 to your computer and use it in GitHub Desktop.
Save anonymous/710a1998c4c7afe177b99d86f0024ce0 to your computer and use it in GitHub Desktop.
Sage main javascript file with google maps from https://www.npmjs.com/package/google-maps
// import external dependencies
import 'jquery';
import 'bootstrap/dist/js/bootstrap';
import GoogleMapsLoader from 'google-maps';
// import local dependencies
import Router from './util/router';
import common from './routes/Common';
import home from './routes/Home';
import aboutUs from './routes/About';
// Use this variable to set up the common and page specific functions. If you
// rename this variable, you will also need to rename the namespace below.
const doLoadGmap = (el, options) => {
const newMap = new window.google.maps.Map(el, options);
return newMap;
};
const mapEl = document.getElementById('map');
const mapOpts = {
center: { lat: -34.397, lng: 150.644 },
scrollwheel: false,
zoom: 8,
};
GoogleMapsLoader.KEY = 'AIzaSyAdQZEV2sGV_6ILHJ0xBToBnmVKGtLo19U';
GoogleMapsLoader.load(doLoadGmap(mapEl, mapOpts));
const routes = {
// All pages
common,
// Home page
home,
// About us page, note the change from about-us to aboutUs.
aboutUs,
};
// Load Events
document.addEventListener('DOMContentLoaded', () => new Router(routes).loadEvents());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment