Skip to content

Commit

Permalink
update pmtiles.js
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Apr 30, 2021
1 parent 1f3454a commit 34009ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ cli:
debug:
go run -mod vendor cmd/example/main.go

pmtiles-js:
curl -s -L -o static/javascript/protomaps.min.js https://unpkg.com/protomaps@latest/dist/protomaps.min.js

protomaps-js:
curl -s -L -o static/javascript/protomaps.min.js https://unpkg.com/protomaps@latest/dist/protomaps.min.js
7 changes: 5 additions & 2 deletions cmd/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
var tile_url = document.body.getAttribute("data-protomaps-tile-url");

const map = L.map('map');

const p = new pmtiles.PMTiles(tile_url);

console.log("P", p);

p.metadata().then(m => {

console.log("HELLO");
let bounds_str = m.bounds.split(',')
let bounds = [[+bounds_str[1],+bounds_str[0]],[+bounds_str[3],+bounds_str[2]]]
layer = new protomaps.LeafletLayer({url:p, bounds:bounds})
layer.addTo(map)
map.fitBounds(bounds)
map.fitBounds(bounds)
});

new L.Hash(map);
</script>
</body>
Expand Down
3 changes: 2 additions & 1 deletion static/javascript/pmtiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
}

metadata = func => {
console.log("WHAT", func);
this.root.then(root => {
func(root.metadata)
})
Expand Down Expand Up @@ -188,4 +189,4 @@
}
}
return {PMTiles:PMTiles}
}))
}))

0 comments on commit 34009ed

Please sign in to comment.