Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a mapping application (the Arne G. Brekke Bygdebok Collection) which uses OpenLayers to load map tiles from a GeoWebCache server operated by the Statens Kartverk (Norwegian Mapping Authority).

It's worked nicely for two years, but this morning the tiles all load as pink, with errors like "400: Requested horizontal resolution: 0.0439453125 , best match: 0.03333333333333333 exceeds 10% threshold. Perhaps the client is configured with an incorrect set of scales (resolutions), or the DPI setting is off compared to the one in GWC?" if you view the image directly.

Here is a test case I worked out demonstrating the problem:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Arne G. Brekke Bygdebok Collection</title>
    <style type="text/css" media="screen">
        #map {
          border: 1px solid #BBBBBB;
          height: 425px;
          width: 675px;
        }
    </style>
</head>
<body>

<h2>Arne G. Brekke Bygdebok Collection</h2>

<div id="map"></div>

<script src="http://openlayers.org/api/OpenLayers.js" type="text/javascript"> </script>
<script type="text/javascript">
var map, base;

function init(){

    map = new OpenLayers.Map("map", {controls: [], projection: new OpenLayers.Projection('EPSG:4326')});

    base = new OpenLayers.Layer.WMS(
        "topo2 SK",
        "http://opencache.statkart.no/gatekeeper/gk/gk.open?",
        {layers: "topo2",format: 'image/jpeg'},
        {attribution:'Map: &copy;<a href="http://www.statkart.no/">Statens kartverk</a>'}
    );

    map.addLayer(base);

    map.setCenter(new OpenLayers.LonLat(17.0068359375, 62.9296875), 5);
}

window.onload = init;
</script>

</body>
</html>

That's the simplest test case I can work out for it. Based on that, OpenLayers generates URLs like this one (broken onto multiple lines for clarity):

http://opencache.statkart.no/gatekeeper/gk/gk.open
    ?LAYERS=topo2
    &FORMAT=image%2Fjpeg
    &SERVICE=WMS
    &VERSION=1.1.1
    &REQUEST=GetMap
    &STYLES=
    &SRS=EPSG%3A4326
    &BBOX=11.25,56.25,22.5,67.5
    &WIDTH=256
    &HEIGHT=256

How can I get it to work again? Bear in mind that I have zero control over the map server -- I can only adjust the JavaScript on my end.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I guess that statkart.no GWC does not support EPSG:4326 projection

Try this:

<script type="text/javascript">
var map, base;

function init(){

    map = new OpenLayers.Map("map", {projection: new OpenLayers.Projection('EPSG:900913')});

    base = new OpenLayers.Layer.WMS(
        "topo2 SK",
        "http://opencache.statkart.no/gatekeeper/gk/gk.open?",
        {layers: "topo2"},
        {attribution:'Map: &copy;<a href="http://www.statkart.no/">Statens kartverk</a>'}
    );
    map.addLayer(base);
    map.zoomToMaxExtent();
}

window.onload = init;
</script>
share|improve this answer
    
I'm pretty sure it does support EPSG:4326 - the problem seems to be something involving the resolutions available. However, I was unable to make EPSG:4326 work reliably, and switching to EPSG:900913 (the spherical mercator projection) at least got the maps working reliably. It also required a fair amount of rewriting since spherical mercator doesn't use lat/lon coordinates for points. See: docs.openlayers.org/library/spherical_mercator.html (Spherical Mercator OpenLayers docs). Accepting the answer since it solved my problem. –  Will Martin Oct 5 '12 at 15:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.