Closed rafaalbert closed 3 years ago
Where were you trying to do this?
I have created my geopackage in qgis using a .tiff image. And tried this:
`var placer = L.geoPackageFeatureLayer([], { geoPackageUrl: 'code/002.gpkg', layerName: 'raster',
}).addTo(map);`
You appear to be trying to load a raster layer with the feature layer method. Try something like this
const tileLayer = L.geoPackageTileLayer({
geoPackageUrl: 'code/002.gpkg',
layerName: 'raster',
}).addTo(map);
oh, yes. But now I have bunch of lines with the same error: file is not a database. Maybe I'm missing somethng when I create the geopackage in QGIS cos I used a points layer from tutorial and it works fine, but after I had this error with my raster I've created a point layer and it doesn't work
Have you tried loading your GeoPackage here: https://ngageoint.github.io/geopackage-js/ If it does not work there, I can look at it if you put it somewhere I can get to.
I have tried right now and it was loaded fine
Your layer is named 002
const tileLayer = L.geoPackageTileLayer({
geoPackageUrl: 'code/002.gpkg',
layerName: '002',
}).addTo(map);
Yeii, it woks XD . thanks for the support. I have a final question, how can I zoom to the tile?
Assuming that QGIS set the tile matrix set bounding box correctly, you can do this (replace my GeoPackage and layer names with yours):
const tileLayer = L.geoPackageTileLayer({
geoPackageUrl: 'https://ngageoint.github.io/GeoPackage/examples/rivers.gpkg',
layerName: 'rivers_tiles',
}).addTo(map);
tileLayer.on('load', function() {
tileLayer.off('load');
const tileDao = tileLayer.geoPackage.getTileDao('rivers_tiles');
const projectedBoundingBox = tileDao.tileMatrixSet.boundingBox.projectBoundingBox(tileDao.projection, 'EPSG:4326');
map.fitBounds([
[projectedBoundingBox.minLongitude, projectedBoundingBox.minLatitude],
[projectedBoundingBox.maxLongitude, projectedBoundingBox.maxLatitude],
]);
Great. I'm very grateful with your help. Now it works perfectly. Thank you
I've tred to load a raster geopackage but I had this error: doneCallback is not a function. How can I solve it?