agentscript
Version:
AgentScript Model in Model/View architecture
43 lines (31 loc) • 1.25 kB
HTML
<html>
<head>
<title>RectMap</title>
</head>
<body>
<script type="module">
import * as gis from '../src/gis.js'
import * as mltools from './mltools.js'
const bbox = gis.santaFeBBox
// ===== Start of map & layers
// terrain sources: osm topo topo1 smooth usgs
// elevation sources: mapzen maptiler redfishUSA redfishWorld mapbox
const terrain = gis.template('usgs')
const map = await mltools.newMap(bbox, 10)
mltools.addRasterLayer(map, 'terrain', terrain)
// Draw a rect of this bbox on map. Used for point-of-view GIS functions.
mltools.addGeojsonLayer(map, 'rectangle', bbox, 'rgba(255, 0, 0, 0.2)', 'red', 3)
mltools.addLayerCursor(map, 'rectangle')
// Change rectangle to a new point-of-view. See console for bbox coords
// fcn args: fcn(bbox) where bbox is dragged rectangle in geo coords
const fcn = async bbox => {
mltools.updateGeojson(map, 'rectangle', bbox)
map.panTo(gis.bboxCenter(bbox))
console.log('rect bbox', bbox)
}
mltools.addDragRect(map, fcn)
// ===== End of map & layers
</script>
<div id="map"></div>
</body>
</html>