[OpenLayers-Users] COG and basemap

Jakob Miksch jakob at meggsimum.de
Fri May 27 01:18:05 PDT 2022


Dear list,

I am trying to display COGs in OpenLayers. This works well for single 
images. However, I would like to add more more layers like a basemap. 
But then the view is blocked to the extent of the COG. See my example below.

Is there a way to overlay a COG on a basemap and still be able to zoom 
and pan wherever I want and not being restricted by the extent of the COG?

best regards,
Jakob

importGeoTIFFfrom'ol/source/GeoTIFF.js';
importMapfrom'ol/Map.js';
importProjectionfrom'ol/proj/Projection.js';
importWebGLTileLayerfrom'ol/layer/WebGLTile.js';
importViewfrom'ol/View.js';
import{getCenter} from'ol/extent.js';
importTileLayerfrom'ol/layer/Tile';
importOSMfrom'ol/source/OSM';
constprojection= newProjection({
code:'EPSG:32721',
units:'m',
});
// metadata from 
https://s3.us-west-2.amazonaws.com/sentinel-cogs/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/S2B_21HUB_20210915_0_L2A.json
constsourceExtent= [300000, 6090260, 409760, 6200020];
constcogSource= newGeoTIFF({
sources:[
{
url:'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/TCI.tif',
},
],
});
constcogLayer= newWebGLTileLayer({
source:cogSource,
});
newMap({
target:'map',
layers:[
newTileLayer({
source:newOSM()
}),
cogLayer
],
view:newView({
projection:projection,
center:getCenter(sourceExtent),
extent:sourceExtent,
zoom:1,
}),
});

-- 
Jakob Miksch
Geoinformatiker

meggsimum - Büro für Geoinformatik
Christian Mayer
Schillerstr. 2a    | 67112 Mutterstadt
info at meggsimum.de  |www.meggsimum.de
T 06231 - 6298988  |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20220527/e63f3976/attachment.htm>


More information about the Users mailing list