jibeinc/juice

View on GitHub
examples/currentLocation.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
<head>
  <title>Current Location Example</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
  <script src='../dist/ui.js'></script>
</head>
<body>

  <div class='my-location'></div>

  <style>
    .my-location {
      width: 100px;
      height: 200px;
    }
  </style>

  <script>
    var c = new UI.CurrentLocation('.my-location', {
      geolocationAPI: window.navigator.geolocation
    });

    c.subscribe(function (msg) {
      if (msg.isLocation) {
        console.log('Users current location is', msg);
      } else {
        console.log(msg);
      }
    });

    c.render();
  </script>

</body>
</html>