[OpenLayers-Users] WMS servers/Brititish National Grid and Projection issues

Dave Potts dave.potts at pinan.co.uk
Tue Jul 15 13:48:30 EDT 2008


Eric Lemoine wrote:
> Hi Dave. Two notes (most probably un-relevant to your problem, sorry):
> the srs WMS param isn't necessary, nor is the bounds arg to
> zoomToMaxExtent. Cheers. Eric
>
>   
Hi

I discovered that geoserver will actual write you a rather nice 
openlayer script, pity I did'nt discover it before, but such is life.

Geoserver attempt is below.

Dave.
------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>OpenLayers map preview</title>
        <style type="text/css">
            #map {
                width: 800px;
                height: 463px;
                border: 1px solid black;
            }
            #wrapper {
                width: 800px;
            }
            #location {
                float: right;
            }
        </style>
        <script 
src="http://localhost:8080/geoserver/openlayers/OpenLayers.js" 
type="text/javascript">
        </script>
        <script defer="defer" type="text/javascript">
        var map;
        var untiled;
        var tiled;
        function setHTML(response) {
            document.getElementById('nodelist').innerHTML = 
response.responseText;
        };

        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
        OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;

        function init(){
            var bounds = new OpenLayers.Bounds(
                528560.734375, 113253.70976631354,
                645496.578125, 185387.61054618648
            );
            var options = {
                controls: [],
                maxExtent: bounds,
                maxResolution: 456.7806396484375,
                projection: "EPSG:27700",
                units: 'm'
            };
            map = new OpenLayers.Map('map', options);


            // setup tiled layer
            tiled = new OpenLayers.Layer.WMS(
                "kentc:kent_boundry - Tiled", 
"http://localhost:8080/geoserver/wms",
                {
                    width: '800',
                    srs: 'EPSG:27700',
                    layers: 'kentc:kent_boundry',
                    height: '463',
                    styles: '',
                    format: 'image/png',
                    tiled: 'true',
                    tilesOrigin : "528560.734375,113253.70976631354"
                },
                {buffer: 0}
            );

            // setup single tiled layer
            untiled = new OpenLayers.Layer.WMS(
                "kentc:kent_boundry - Untiled", 
"http://localhost:8080/geoserver/wms",
                {
                    width: '800',
                    srs: 'EPSG:27700',
                    layers: 'kentc:kent_boundry',
                    height: '463',
                    styles: '',
                    format: 'image/png'
                },
                {singleTile: true, ratio: 1}
            );

            map.addLayers([untiled, tiled]);

            // setup controls and initial zooms
            map.addControl(new OpenLayers.Control.PanZoomBar());
            map.addControl(new OpenLayers.Control.Navigation());
            map.addControl(new OpenLayers.Control.Scale($('scale')));
            map.addControl(new 
OpenLayers.Control.MousePosition({element: $('location')}));
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            //map.addControl(new OpenLayers.Control.OverviewMap());
            map.zoomToExtent(bounds);

            // support GetFeatureInfo
            map.events.register('click', map, function (e) {
                document.getElementById('nodelist').innerHTML = 
"Loading... please wait...";
                var url =  map.layers[0].getFullRequestString(
                    {
                        REQUEST: "GetFeatureInfo",
                        EXCEPTIONS: "application/vnd.ogc.se_xml",
                        BBOX: map.getExtent().toBBOX(),
                        X: e.xy.x,
                        Y: e.xy.y,
                        INFO_FORMAT: 'text/html',
                        QUERY_LAYERS: map.layers[0].params.LAYERS,
                        FEATURE_COUNT: 50,
                        WIDTH: map.size.w,
                        HEIGHT: map.size.h
                    },
                    "http://localhost:8080/geoserver/wms"
                );
                OpenLayers.loadURL(url, '', this, setHTML, setHTML);
                OpenLayers.Event.stop(e);
            });
        }
        </script>
    </head>
    <body onload="init()">
        <div id="map"></div>
        <div id="wrapper">
            <div id="location"></div>
            <div id="scale"></div>
        </div>
        <div id="nodelist">Click on the map to get feature info</div>
    </body>
</html>
                                                                                                                                                                  


-------------- next part --------------
A non-text attachment was scrubbed...
Name: dave.potts.vcf
Type: text/x-vcard
Size: 91 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080715/ca9d2270/dave.potts.vcf


More information about the Users mailing list