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">
      <section id="selected-store-container">
      </section>
    </div>
  </div>
</div>

CSS

body {
  font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}

#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;
}

#selected-store-container {
  display: flex;
  overflow: auto;
  justify-content: space-between;
  flex-direction: column;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: auto;
  background: white;
}


.selected-store-card {
  vertical-align: middle;
  line-height: 2em;
}

.selected-store-card .hero {
  padding: .8rem 1.4rem;
}

.selected-store-card .store-title {
  font-size: 1.5rem;
}


.selected-store-card .content {
  padding: 0 1.4rem .8rem;
  color: #1D1D1D;
}


.store-address {
  line-height: 1.6rem;
}

.selected-store-card .store-address,
.store-contact a,
.store-website a {
  padding: .2em 0;
  margin-left: 20px;
  color: #1D1D1D;
}

.store-website a::before,
.store-contact a::before,
.selected-store-card .store-address::before {
  content: "";
  background-size: 16px 16px;
  background-repeat: no-repeat;
  padding-right: 20px;
  vertical-align: middle;
  margin-left: -20px;
}

.store-contact a::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath...

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 = {
  style: {
    'default': {
      'icon': {
        url: 'https://demo.woosmap.com/storelocator/images/markers/starbucks-marker.svg',
        scaledSize: {
          height: 47,
          width: 40
        },
      },
      'numberedIcon': {
        url: 'https://demo.woosmap.com/storelocator/images/markers/starbucks-marker.svg',
        scaledSize: {
          height: 47,
          width: 40
        },
      },
      'selectedIcon': {
        url: 'https://demo.woosmap.com/storelocator/images/markers/starbucks-marker-selected.svg',
        scaledSize: {
          height: 71,
          width: 61
        }
      }
    }
  },
  tileStyle: {
    color: '#008248',
    size: 15,
    minSize: 4
  },
  breakPoint: 12
};
const googleLoadOptions = {
  key: "AIzaSyCOtRab6Lh2pNn7gYxvAqN5leETC24OXYQ"
};
const googleMapsOptions = {
  center: {
    lat: 51.53,
    lng: -0.185
  },
  zoom: 10
};
let selectedStoreObj;
const selectedStoreTemplate = "<div class='woosmap-tableview-cell'>" +
  "<div class='store-photo-header'></div>" +
  "<div class='selected-store-card'><div class='hero'>" +
  "<div class='store-title'>{{name}}</div>" +
  "{{#types}}<div class='store-types'>{{types}}</div>{{/types}}</div>" +
  "<div class='content'><div class='store-address'>{{address.lines}}</div>" +
  "{{#contact.phone}}<div class='store-contact'><a href='tel:{{contact.phone}}'>{{contact.phone}}</a></div>{{/contact.phone}}" +
  "{{#contact.website}}<div class='store-website'><a href='{{contact.website}}' target='_blank'>Go to website</a></div>{{/contact.website}}" +
  "</div></div>" +
  "</div>";

function getSelectedRenderedTemplate(store) {
  const templateRenderer = new woosmap.TemplateRenderer(selectedStoreTemplate);
  return templateRenderer.render(store.properties);
}

function...