Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it works with custom extent? #2

Closed
t1geomatika opened this issue May 23, 2016 · 2 comments
Closed

Does it works with custom extent? #2

t1geomatika opened this issue May 23, 2016 · 2 comments

Comments

@t1geomatika
Copy link

HI,

I'm trying to use this plugin to display tiles from Tilecache with ol3 but I the URL generated are not Okay.

The projection of my map is EPSG3943 (http://epsg.io/3943-1753.js)

The resolutions associated to this projection are :
[35.2777777778, 17.6388888889, 8.81944444444, 3.52777777778, 1.76388888889, 0.881944444444, 0.705555555556, 0.352777777778, 0.176388888889, 0.0881944444444]

The extent associated is : 
        extent.xmax=1343422.962875;
        extent.xmin=1335234.08035;
        extent.ymax=2267712.102675;
        extent.ymin=2259212.04695;

and when I try to display my map at [1339328.5216125,2263462.0748125] and zoom level 0, i got
http://myTilecacheServer/myTileset/12/000/002/185/000/002/279.png
instead of
http://myTilecacheServer/myTileset/00/000/000/000/000/000/000.png

I don't see in the code of this plugin any relation with the map extent but in the tilecache.js of OL2 there are in the getUrl :

        var bbox = this.maxExtent;
        ...
        var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
        var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h));

Does this plugin works only with WorldWide tileset? Or did id do a mistake in my code ?

My code :

       layer=new ol.layer.Tile({
                  source: new ol.source.XYZ({
                      tileUrlFunction: 
                      ol.TileCacheUrlFunction.createTileUrlFunction('http://myTilecacheServer/myTileset/{0z}/{x1}/{x2}/{x3}/{-y1}/{-y2}/{-y3}.png'),
                      projection: 'EPSG:3943'
                  })
              });
        maptest = new ol.Map({
          target: 'map',
          view: new ol.View({
              projection: 'EPSG:3943',
              center: [1339328.5216125,2263462.0748125],
              zoom: 0,
              maxExtent:maxExtent,
              resolutions:resolutions
          }),
          layers: [layer]
      });

Thanks

@ghettovoice
Copy link
Owner

Hi!
As I know, to use custom resolutions you need define custom tileGrid with your custom resolutions and extent.
Without that ol3 will create and use a default TileGrid whose resolutions and origin will be determined based on the projection's validity extent. Some information about that link
You need something like that:

<!DOCTYPE html>
<html>
    <head>
        <title>test</title>
        <link rel="stylesheet" href="http://openlayers.org/en/latest/css/ol.css" />
        <style>
            html, body, #map {
                width: 100%;
                height: 100%;
                margin: 0;
            }
        </style>
    </head>
    <body>
        <div id="map"></div>

        <script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js"></script>
        <script src="http://epsg.io/3943-1753.js"></script>
        <script src="http://openlayers.org/en/latest/build/ol.js"></script>
        <script src="C:/Users/ghetto/Documents/GitHub/ol3-tilecache/dist/ol3-tilecache.js"></script>

        <script>
            var projection = new ol.proj.Projection({
                code: 'EPSG:3943',
                extent: [624227.05, 2076993.88, 2217136.99, 3178000.51]
            });

            var resolutions = [35.2777777778, 17.6388888889, 8.81944444444, 3.52777777778, 1.76388888889, 0.881944444444, 0.705555555556, 0.352777777778, 0.176388888889, 0.0881944444444];
            var layer=new ol.layer.Tile({
                  source: new ol.source.XYZ({
                      tileUrlFunction: 
                      ol.TileCacheUrlFunction.createTileUrlFunction('http://myTilecacheServer/myTileset/{0z}/{x1}/{x2}/{x3}/{-y1}/{-y2}/{-y3}.png'),
                      projection: 'EPSG:3943',
                      tileGrid: new ol.tilegrid.TileGrid({
                          origin: [624227.05, 2076993.88],
                          extent: [624227.05, 2076993.88, 2217136.99, 3178000.51],
                          resolutions: resolutions
                      })
                  })
              });
            var maptest = new ol.Map({
                target: 'map',
                view: new ol.View({
                    projection: 'EPSG:3943',
                    center: [1339328.5216125,2263462.0748125],
                    zoom: 0,
                    resolutions: resolutions
                }),
                layers: [layer]
            });
        </script>
    </body>
</html>

@ghettovoice
Copy link
Owner

So I close this issue. If you have questions, please, reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants