Reputation: 21
We have created a web application using Openlayers- showing primarily ArcGIS REST data using the ImageArcGISRest source.
We would like to be able to show some Vector tile data at the same time - but are having some problems with the tiling scheme and or extent. The vector tiles, which have been created in ArcGIS Pro, are EPSG:25832 - the same projection as the ImageArcGISRest source.
When viewing the vector tiles and ImageArcGISRest in the same Openlayers map - the vector tiles are offset by 10.000 meters horizontally.
Does anybody know why this is happening?
I have created a simple fiddle to show the code and the problem: https://jsfiddle.net/larssoe/0vyw2Lg5/150/
proj4.defs('EPSG:25832', "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs");
ol.proj.proj4.register(proj4);
var myProjection = ol.proj.get('EPSG:25832');
myProjection.setExtent([130000, 5661139.2, 1378291.2, 6500000]);
var resturl = 'https://bragdev3.gis.dk/arcgis/rest/services/Plandistrikter2/MapServer';
const mousePositionControl = new ol.control.MousePosition({
coordinateFormat: ol.coordinate.createStringXY(4),
projection: 'EPSG:25832',
className: 'custom-mouse-position',
target: document.getElementById('mouse-position'),
});
var map = new ol.Map({
controls: ol.control.defaults().extend([mousePositionControl]),
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 10,
projection: myProjection
//projection: 'EPSG:25832',
}),
layers: [
new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
//tilegrid: myTileGrid,
projection: 'EPSG:25832',
minZoom: 0,
maxZoom: 15,
maxResolution: 1638.4,
wrapX: false,
url: 'https://bragdev3.gis.dk/arcgis/rest/services/Hosted/Plandistrikter2/VectorTileServer/tile/{z}/{y}/{x}.pbf'
}),
tileSize: 512,
//tilegrid: myTileGrid2
}),
new ol.layer.Tile({
title:'ArcGISRest',
source: new ol.source.TileArcGISRest({
url: resturl,
params: {
FORMAT: "png32",
LAYERS: "show:0",
DPI: 96
},
projection: ol.proj.get("EPSG:25832"),
//tilegrid: myTileGrid
})
})
],
});
map.on('moveend', move);
function move(event) {
var info = document.getElementById('info');
const extent = map.getView().calculateExtent(map.getSize());
const resolution = map.getView().getResolution();
const zoom = map.getView().getZoom();
info.innerText = 'zoom: ' + zoom + ' resolution: ' + resolution + ' extent:' + extent;
info.style.opacity = 1;}
var info = document.getElementById('info');
function showInfo(event) {
var features = map.getFeaturesAtPixel(event.pixel);
if (features.length == 0) {
info.innerText = '';
info.style.opacity = 0;
return;
}
var properties = features[0].getProperties();
info.innerText = JSON.stringify(properties, null, 2);
info.style.opacity = 1;
}
var center = [706000,6216062];
map.getView().setCenter(center);
map.getView().setZoom(6);
Any help would be appreciated. Thanks!
Upvotes: 1
Views: 411
Reputation: 21
To others with vector tiles offset problems: The initial offset problems (both horizontal and vertical) where solved by setting the property maxResolution. In my case to 1638.4
Upvotes: 1