Subversion Repositories eFlore/Applications.cel

Rev

Rev 3812 | Blame | Compare with Previous | 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>
  <tb-geolocation-element
    id="tb-geolocation"
    layer='opentopomap'
    zoom_init="4"
    lat_init="46.5"
    lng_init="2.9"
    marker="true"
    polyline="false"
    polygon="false"
    show_lat_lng_elevation_inputs="false"
    osm_class_filter=""
    elevation_provider="mapquest"
    map_quest_api_key="mG6oU5clZHRHrOSnAV0QboFI7ahnGg34"
    >
  </tb-geolocation-element>
  
  <form 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">
  </form>
  
  <script>
    var tbGeolocation = document.getElementById('tb-geolocation');
    tbGeolocation.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>