Open ghost opened 11 months ago
We would be happy to accept a pull request from you.
I solved my problem by preloading the GeoPackage, caching it in geoPackages
and then reading the style before creating the layer.
function loadGeoPackage(url: string, then_func: (gpkg: GeoPackage)=>void): void {
let gpkg: GeoPackage;
if (!(gpkg = geoPackages[url])) {
setSqljsWasmLocateFile(((filename: string) => 'https://unpkg.com/@ngageoint/geopackage@4.2.3/dist/' + filename));
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
GeoPackageAPI.open(new Uint8Array(this.response)).then(function(gp) {
geoPackages[url] = gp;
then_func(gp);
});
};
xhr.send();
}
else
then_func(gpkg);
}
How about a 'load' event like in other async leaflet layers like TileLayer or ImageOverlay? I need to know when the GeoPackage has loaded completely so I can read the SQLite DB to read styles from a table.