UNPKG

1.25 kBHTMLView Raw
1<html>
2
3<head>
4 <title>RectMap</title>
5</head>
6
7<body>
8 <script type="module">
9 import * as gis from '../src/gis.js'
10 import * as mltools from './mltools.js'
11
12 const bbox = gis.santaFeBBox
13
14 // ===== Start of map & layers
15
16 // terrain sources: osm topo topo1 smooth usgs
17 // elevation sources: mapzen maptiler redfishUSA redfishWorld mapbox
18 const terrain = gis.template('usgs')
19
20 const map = await mltools.newMap(bbox, 10)
21
22 mltools.addRasterLayer(map, 'terrain', terrain)
23
24 // Draw a rect of this bbox on map. Used for point-of-view GIS functions.
25 mltools.addGeojsonLayer(map, 'rectangle', bbox, 'rgba(255, 0, 0, 0.2)', 'red', 3)
26
27 mltools.addLayerCursor(map, 'rectangle')
28
29 // Change rectangle to a new point-of-view. See console for bbox coords
30 // fcn args: fcn(bbox) where bbox is dragged rectangle in geo coords
31 const fcn = async bbox => {
32 mltools.updateGeojson(map, 'rectangle', bbox)
33 map.panTo(gis.bboxCenter(bbox))
34 console.log('rect bbox', bbox)
35 }
36 mltools.addDragRect(map, fcn)
37
38 // ===== End of map & layers
39 </script>
40 <div id="map"></div>
41</body>
42
43</html>
\No newline at end of file