Tutorial Store Locator - Structure

by woosmap

HTML

<script src="https://sdk.woosmap.com/locator/loader.js"></script>

<div id="main">
  <div id="my-map-container">
    <div id="my-map">MAP</div>
  </div>
  <div id="sidebar-container">
    <div id="sidebar" style="padding:40px">SIDEBAR</div>
  </div>
</div>

CSS

#main {
  display: flex;
  position: absolute;
  flex-direction: column;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#my-map-container {
  display: flex;
  flex-grow: 0;
  height: 55vh;
  position: relative;
}

#my-map {
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #CCC;
}

#sidebar-container {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  flex-grow: 1;
  flex-basis: 0;
  position: relative;
  z-index: 1;
  overflow: hidden;
  background-color: white;
  box-shadow: 0 -2px 4px 0 rgba(0, 0, 0, 0.12);
}

#sidebar {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

@media (min-width: 650px) {
  #main {
    flex-direction: row;
    height: 100%;
  }

  #my-map-container {
    flex-basis: 70vw;
    order: 2;
    position: relative;
    height: 100%;
  }

  #sidebar-container {
    flex-basis: 30vw;
    min-width: 300px !important;
    max-width: 500px !important;
    order: 1;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    -webkit-box-flex: 0;
    flex-grow: 0;
    height: 100%;
  }
}

JavaScript

const woosmapLoadOptions = {
  version: '1.4',
  publicKey: 'woos-8b95bb95-8e0d-3e34-9d30-87e77e2e0d93', //replace with your public key
  callback: woosmap_main,
  loadJQuery: true
};
const woosmapOptions = {
};
const googleLoadOptions = {
  key: "AIzaSyCOtRab6Lh2pNn7gYxvAqN5leETC24OXYQ"
};
const googleMapsOptions = {
  center: {
    lat: 51.53,
    lng: -0.185
  },
  zoom: 11
};

function woosmap_main() {
  const loader = new woosmap.MapsLoader(googleLoadOptions);
  loader.load(function() {
    map = new google.maps.Map(woosmap.$('#my-map')[0], googleMapsOptions);
    mapView = new woosmap.TiledView(map, woosmapOptions);
  });
}

if (window.attachEvent) {
  window.attachEvent('onload', function() {
    WoosmapLoader.load(woosmapLoadOptions);
  });
} else {
  window.addEventListener('load', WoosmapLoader.load(woosmapLoadOptions), false);
}