I thought this was an easy one, but I'm a bit stuck...

I want to clone the "OSM Mapnik (Default)" layer (so I can get the Zoom Level Range function).

I though the template base URL was http://tile.openstreetmap.org/${x}/{$y}/{$z}.png but this isn't working.

I'm getting the error: "Error during map rendering: TypeError: template is null". I get the title but no map.

Does anyone know what the correct template base URL is or where I could find it?

Thanks in advance.

Comments

tmcw’s picture

I believe this fix should have fixed this: #939400: XYZ Layer causes js error and will not load. Try updating to -dev and check?

cajmcmahon’s picture

Version: 6.x-2.0-alpha10 » 6.x-2.x-dev
FileSize
3.94 KB

Thanks to all. The dev version works and a cloned map will now render.

However, when I eliminate "Zoom Level Ranges" 0 and 1 the tiles won't load (please see attached screenshot).

I'm trying to prevent users from zooming all the way out creating a tiny map.

I'll keep trying...

Thanks again.

tmcw’s picture

Status: Active » Closed (works as designed)

This is an upstream bug; the OpenLayers.js implementation of XYZ layers doesn't support zoom level limitations on the top end (yes; it's annoying and stupid, and bad design. I'm not in love with the design of the javascript library).

You'll need to put an error report on OpenLayers.org for this if you want it to get fixed.

coredumperror’s picture

Title: Clone OSM Mapnik layer - base URL setting? » Cloning OSM Mapnik layer - Zoom Level Range is broken
Version: 6.x-2.x-dev » 7.x-2.x-dev
Component: Layers » OL Layers
Category: support » bug
Status: Closed (works as designed) » Active

I recently tried to do the same thing as cajmcmahon, cloning the OSM Mapnik layer so I could apply zoom level limitations. However, when I use that cloned layer, if any set of zoom levels (even 0 and 1) has been chosen in the Zoom Level Range multiselect, the "z" value for every single tile at every zoom level apparently gets set to -1. This causes every tile request made to tile.openstreetmap.org to result in a 404 Not Found error (according to the Net tab on Firebug. e.g http://tile.openstreetmap.org/-1/11263/26150.png). If I unselect every value in the Zoom Level Range control, the layer starts working fine.

Is this still a problem in the OpenLayers library end, or is it a bug in the drupal module? This was last addressed in late 2010, and I imagine that both have changed dramatically since then, so I'm hoping that this issue can now be resolved.

I'll do my best to root around in the code and figure out where the problem is originating, but I wanted to bring it up here so that the folks who actually know what they're doing might be able to shed some light on the issue.

coredumperror’s picture

I did some rooting around in the OpenLayers issue tracker and found this:
http://trac.osgeo.org/openlayers/ticket/2189

The 3-month-old patch from this issue hasn't gone into a live OpenLayers library release yet, but as you can see in the link from the second to last post (http://openlayers.org/dev/examples/bing-tiles-restrictedzoom.html), it is definitely now possible to do a zoom-limited layer. It doesn't appear to support the kind of granlarity that the edit control in this module's Layer editor allows, though. But simply being able to limit the zoom level to e.g. 15-18 is entirely possible now.

I'll see about writing up a patch to the module that will utilize the patched library functionality.

zzolo’s picture

Title: Cloning OSM Mapnik layer - Zoom Level Range is broken » Add interface options for zoom level ranges in XYZ layers
Category: bug » feature

Thanks for digging into that @coredumperror . Marking as a feature request, then.

coredumperror’s picture

Title: Add interface options for zoom level ranges in XYZ layers » Fix interface for zoom level ranges in XYZ layers
Assigned: Unassigned » coredumperror
Category: feature » bug

Well, I don't really think this is a feature request. Right now the OpenLayers module has interface functionality for limiting the zoom level for a layer, and it doesn't work. In fact, using it at all completely breaks the layer.

This is going to be an important feature of the site I'm writing, so I'll go ahead and assign this to myself. I should have a patch within a week or so.

cableman0408’s picture

FileSize
1.17 KB

I'm trying to display a local map from a MapBox TileStram server, but the z part of the server request is always -1. I think it's related to the issue described here.

I have create a patch that makes the map display, but not sure that it fixes the whole problem, but maybe it can help getting the problem resolved correctly.

Pol’s picture

Status: Active » Fixed

Hello,

Can you try with the latest dev release and report back ?
Re open the ticket if needed.

Thanks !

coredumperror’s picture

Status: Fixed » Active

Yes, this still happens in the newest dev release. I tried setting the OSM Mapnik layer to only allow zoom levels of 15-18, and every map tile broke in the same way (the 'z' part of the tile image's URL was -1).

Pol’s picture

And now ?

coredumperror’s picture

I installed the Feb 02 dev build, and it also didn't work... but it did cause different errors than last time.

1) The edit forms for XYZ style Layers have the "Zoom Level Range" form element twice. As seen here.

2) Rather than showing broken images in the place of tiles, setting the Zoom Level Range now causes the entire map to not render at all. Checking the Network tab on the Chrome Inspector shows that it's not even attempting to download tiles.

2a) Upon further testing, I've discovered that setting the Zoom Level Range in the top form element (as seen in my screenshot) causes this "no render" error. But setting it in the bottom form element causes the original "broken tiles" effect (even when the top element is also set). I see it trying to download tiles with incorrect URLs like http://tile.openstreetmap.org/0/0/13074.png. At least it's not trying to download tiles with "-1" in the URL anymore.

Pol’s picture

Thanks for trying coredump,

I'm trying to understand how 'serverResolutions' and 'resolutions' keys are working.

I will work on the layer form again soon and I will add some more documentation.
Any insight is welcome to help me !

I'll come back on this thread as soon as I made any progress.

friedjoff’s picture

Both fields for zoom level ranges in XYZ layers appear with the same title and description. This patch changes the title and description for the serverResolutions field.

Pol’s picture

Thanks @friedjoff, committed !

Pol’s picture

Issue summary: View changes
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.