Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3638 delphine 1
<!doctype html>
2
<html lang="">
3
 
4
<head>
5
  <base href=".">
6
  <meta charset="utf-8">
7
  <title>TB Geolocation</title>
8
  <link rel="stylesheet" href="./styles.css">
9
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
10
</head>
11
 
12
<body>
13
  <script src="./tb-geoloc-lib-app.js"></script>
3811 idir 14
 
15
  <form>
16
    <div id="tb-map"></div>
17
    <div style="display:inline-flex;flex-direction:row;margin:5px;padding:5px;justify-content:space-between;width:80%;border:2px solid grey;">
18
      <input id="locality" type="text" placeholder="locality">
19
      <input id="postcode" type="text" placeholder="postcode">
20
      <input id="latitude" type="text" placeholder="latitude">
21
      <input id="longitude" type="text" placeholder="longitude">
22
      <input id="altitude" type="text" placeholder="altitude">
23
    </div>
3638 delphine 24
  </form>
25
 
26
  <script>
3811 idir 27
    var map = document.createElement('tb-geolocation-element');
28
 
29
    map.setAttribute('zoom_init', 8);
30
    map.setAttribute('lat_init', 43.6);
31
    map.setAttribute('lng_init', 3.8);
32
    map.setAttribute('marker', true);
33
    map.setAttribute('polyline', true);
34
    map.setAttribute('polygon', false);
35
    map.setAttribute('show_lat_lng_elevation_inputs', true);
36
    map.setAttribute('osm_class_filter', '');
37
    map.setAttribute('geometry_filter', ['linestring']);
38
    map.setAttribute('elevation_provider', 'mapquest');
39
    map.setAttribute('map_quest_api_key', 'mG6oU5clZHRHrOSnAV0QboFI7ahnGg34');
40
    map.setAttribute('height', '400px');
41
 
42
    document.getElementById('tb-map').append(map);
43
 
44
    map.addEventListener("location", function(location) {
3638 delphine 45
      console.log(location.detail);
46
      document.getElementById('locality').value = location.detail.locality;
47
      document.getElementById('postcode').value = location.detail.osmPostcode;
48
      document.getElementById('latitude').value = location.detail.geometry.coordinates[1];
49
      document.getElementById('longitude').value = location.detail.geometry.coordinates[0];
50
      document.getElementById('altitude').value = location.detail.elevation;
51
    });
52
  </script>
53
 
54
</body>
55
 
56
</html>