TMS/XYZ Tiles Not Displaying with EPSG:4326 in OpenLayers 3 from GeoServer

Open
#16,304 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
frontend, web-dev

Research direction

Start with the OpenLayers 3 XYZ source shown in the issue and the linked GeoWebCache layers and blobstores documentation. Compare the EPSG:4326 TMS URL, requested z/x/y values, and the stated layer extent; done means identifying a reproducible configuration or request correction that displays the tiles in EPSG:4326.

Written by the indexing model from the issue text.

Description

bug
• GeoWebCache Bounding Box to Tile Conversion Not Working Properly (EPSG:4326)
• I am working on loading TMS and XYZ tiles from GeoServer into an OpenLayers 3 map using the EPSG:4326 projection. My implementation works with EPSG:900913 (Web Mercator), but when I switch to EPSG:4326 (WGS 84), the tiles do not display.
• The tiles for zoom levels 0-15 were generated using the gdal2tiles command, following a directory structure format of zoomLevel/xTile/yTile.png. These tiles work fine when loaded directly into OpenLayers 3. However, I encounter issues when trying to display the GeoServer TMS layer tiles.
  
  Problem Details:
• Requesting tiles using EPSG:900913 works as expected in GeoServer.
• Requesting tiles using EPSG:4326 does not display the tiles(i.e /5/21/17.png,7/91/73.png,...), and it seems like the tile requests are targeting incorrect zoom levels or tile indices.
• Layer extent is : 67.9999999892922062,6.7500084218887384 97.4152926721475438,35.5000646459131772 
• I would prefer to display the map using EPSG:4326 since my data is in that projection. However, the TMS tiles from GeoServer fail to load in this projection. It seems there may be issues with coordinate transformations or the way OpenLayers 3 requests the tiles.
  Sample code :
var epsg_projection = '4326';  
var layerCity = 'cite:layername';
var epsg_projection2 = 'EPSG:' + epsg_projection;
var testlayer = new ol.layer.Tile({
source: new ol.source.XYZ({
    	url: 'http://localhost:8080/geoserver/gwc/service/tms/1.0.0/' + layerCity + '@EPSG%3A' + 	epsg_projection +'@png/{z}/{x}/{-y}.png',
   	 minZoom: 0,
   	 maxZoom: 15
  })
});

  My Questions:
• Is there a way to instruct GeoServer to generate tiles with the XYZ structure (zoom/x/y) for EPSG:4326?
• How can I configure OpenLayers 3 to request the TMS tiles correctly from GeoServer for EPSG:4326?
• Is there a better approach to handle TMS with EPSG:4326 in GeoWebCache?

Any guidance or insights on resolving this issue would be highly appreciated!

Reference link:
https://docs.geoserver.org/main/en/user/geowebcache/webadmin/blobstores.html
https://docs.geoserver.org/main/en/user/geowebcache/webadmin/layers.html
https://github.com/geoserver/geoserver
Screenshot from 2024-10-19 12-56-10
Screenshot from 2024-10-19 13-01-27

Dominant language
JavaScript
Stars
12.6k
Forks
3.2k
Avg merge
2d 17h
Merged PRs (30d)
21

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openlayers/openlayers

All issues in openlayers/openlayers

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.