kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
589 stars 173 forks source link

Resolutions smaller than 0 #123

Closed l4ci closed 8 years ago

l4ci commented 8 years ago

Hey there,

Im using custom resolutions from an ArcGIS Server (https://geoportal.stadt-kassel.de/arcgis/rest/services/Raster/RSK_WEB_G/MapServer)

var proj4rs25832def = '+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs';
var customcrs = new L.Proj.CRS('EPSG:25832', proj4rs25832def, {
    resolutions: [
        13.229193125052918,
        5.291677250021167,
        2.6458386250105836,
        1.3229193125052918,
        0.6614596562526459,
    ]
});
var map = new L.Map('map', {
        crs: customcrs,
        center: [51.3133835, 9.49648767981191],
        zoomControl: true,
        zoom: 1,
        maxZoom: customcrs.options.resolutions.length,
        minZoom: 1,
        continuousWorld: true
});

L.esri.dynamicMapLayer({
        url: 'https://geoportal.stadt-kassel.de/arcgis/rest/services/Raster/RSK_WEB_G/MapServer',
    }).addTo(map);

Unfortunately the last zoom resolution 0.6614596562526459 doesn't really work. It zooms to it, but afterwards zooms even further, which it should not do at all, because its the last step. But it seems to ignore that, and zooms one more time - which shows a bigger version (so it zooms out again). When removing the last zoom level it all works as intended, but I need this last zoom level, as its the most detailed one.

Anyone has an idea how to fix this, or can point me in the right direction? Im kinda lost..

sivesind commented 8 years ago

Maybe a long shot, but have you double-checked the tilesize of the service and set it correctly on the L.esri.dynamicMapLayer? http://kartena.github.io/Proj4Leaflet/api/

I had a similar problem with 512 px tiles, and the default is 256.

l4ci commented 8 years ago

I just checked it:

Height: 256 Width: 256 Dpi: 96

So that should fit, right?

sivesind commented 8 years ago

Unfortunately, yes :-) Tried to remove the minzoom/maxzoom settings?

l4ci commented 8 years ago

Already tried that, doesn't fix it (it lets me zoom out more, but zooming in -> same error).

Currently Im setting customcrs.options.resolutions.length-1;- which prevents zooming out one more step. This shows my lowest zoom setting 0.6.., but the step before 1.3... (which was showed afterwards before) is missing.

This is so confusing.

sivesind commented 8 years ago

Remove resolutions settings?

l4ci commented 8 years ago

This will make the map zoomable with the default leaflet zoom steps - which display some tiles in a very bad quality.

Am Mittwoch, 7. September 2016 schrieb Lars Eirik Sivesind :

Remove resolutions settings?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kartena/Proj4Leaflet/issues/123#issuecomment-245391178, or mute the thread https://github.com/notifications/unsubscribe-auth/AAc4DJJRYXo7WLmj1IVeJF3KfkEuEAL2ks5qnxE_gaJpZM4J3C1o .

Volker Otto volkerotto.net

semone commented 8 years ago

How does L.esri.dynamicMapLayer work? Will it know which resolutions and zoom-levels you have defined for the map? Or how does it know what to render and in what coordinate system?

Do you have somewhere were we can see the map?

sivesind commented 8 years ago

Your resolutions deviates from a similar set I use: 21.16670900008467, 10.583354500042335, 5.291677250021167, 2.6458386250105836, 1.3229193125052918, 0.6614596562526459, 0.33072982812632296, 0.16536491406316148 Notice your 13.229... resembles my 1.3229... , with a different ordering. Maybe check your resolutions again?

(your mapserver is not available from Norway)

perliedman commented 8 years ago

@l4ci In your example code you have:

maxZoom: customcrs.options.resolutions.length

That should be:

maxZoom: customcrs.options.resolutions.length - 1

Even though you have minZoom set to 1, Proj4Leaflet will look at resolutions[zoomLevel] (https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L122) - so your current configuration will step outside the resolution array's bounds.

This should be a correct setup:

var proj4rs25832def = '+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs';
var customcrs = new L.Proj.CRS('EPSG:25832', proj4rs25832def, {
    resolutions: [
        undefined,
        13.229193125052918,
        5.291677250021167,
        2.6458386250105836,
        1.3229193125052918,
        0.6614596562526459,
    ]
});

var map = new L.Map('map', {
        crs: customcrs,
        center: [51.3133835, 9.49648767981191],
        zoomControl: true,
        zoom: 1,
        maxZoom: customcrs.options.resolutions.length - 1,
        minZoom: 1,
        continuousWorld: true
});
l4ci commented 8 years ago

Thanks for all your responses guys :)

@sivesind I already checked the resolutions multiple times - but thanks for the hint anyway!

@semone well its just a layer added to the map, which has the crs defined. So thats how it should know the resolution.

@perliedman oh wow, thank you. I was already using maxZoom: customcrs.options.resolutions.length - 1 as this got rid of the last zoom level, but I thought it removed another zoom level. Adding an undefined or another higher zoom level is the only thing I didn't try yet. Will give it a go and report back!

semone commented 8 years ago

Okey so it is just an imagelayer?

l4ci commented 8 years ago

Thanks guys, adding an undefined and using maxZoom: customcrs.options.resolutions.length - 1 fixed my problem!