Subversion Repositories eFlore/Applications.cel

Rev

Rev 3638 | Blame | Last modification | View Log | RSS feed

<!doctype html>
<html lang="">

<head>
  <base href=".">
  <meta charset="utf-8">
  <title>TB Geolocation</title>
  <link rel="stylesheet" href="./styles.css">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>

<body>
  <script src="./tb-geoloc-lib-app.js"></script>

  <form>
    <div id="tb-map"></div>
    <div style="display:inline-flex;flex-direction:row;margin:5px;padding:5px;justify-content:space-between;width:80%;border:2px solid grey;">
      <input id="locality" type="text" placeholder="locality">
      <input id="postcode" type="text" placeholder="postcode">
      <input id="latitude" type="text" placeholder="latitude">
      <input id="longitude" type="text" placeholder="longitude">
      <input id="altitude" type="text" placeholder="altitude">
    </div>
  </form>
  
  <script>
    var map = document.createElement('tb-geolocation-element');

    map.setAttribute('zoom_init', 8);
    map.setAttribute('lat_init', 43.6);
    map.setAttribute('lng_init', 3.8);
    map.setAttribute('marker', true);
    map.setAttribute('polyline', true);
    map.setAttribute('polygon', false);
    map.setAttribute('show_lat_lng_elevation_inputs', true);
    map.setAttribute('osm_class_filter', '');
    map.setAttribute('geometry_filter', ['linestring']);
    map.setAttribute('elevation_provider', 'mapquest');
    map.setAttribute('map_quest_api_key', 'mG6oU5clZHRHrOSnAV0QboFI7ahnGg34');
    map.setAttribute('height', '400px');
    
    document.getElementById('tb-map').append(map);

    map.addEventListener("location", function(location) {
      console.log(location.detail);
      document.getElementById('locality').value = location.detail.locality;
      document.getElementById('postcode').value = location.detail.osmPostcode;
      document.getElementById('latitude').value = location.detail.geometry.coordinates[1];
      document.getElementById('longitude').value = location.detail.geometry.coordinates[0];
      document.getElementById('altitude').value = location.detail.elevation;
    });
  </script>

</body>

</html>