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.

ADDED: Another curious effect is that no matter to what scale I zoom on the baselayer google/bing map, the WMS overlay is always the same-sized shot of MN. That is, as the baselayer map is scaled up or down, the WMS overlay map never scales -- it always shows the same bounds.

I am trying to convert an Openlayers page from running overlay maps with OpenLayers.Layer.MapServer to one running WMS with OpenLayers.Layer.WMS. The information I am providing through these interfaces is overlaying on a Google/Bing/Openlayers baselayer. The Mapserver implementaion works fine, but the WMS implementation seems to generate an overlay from my data that is ~ 2x too large for the overlay with the baselayer maps.

** Please excuse the use of links here and for pastebin... I wanted to embed images and make links directly to pastebin, but being a new user, I was given restrictions of no images and only two links.

Here is a picture of the working overlay: enter image description here

Here is a picture with the problematic WMS overlay: Problem

The mapfiles for mapserver are mostly identical, as I used the working Mapserver mapfile to create the mapfile for WMS, but with some necessary mods to the WMS mapfile to make it WMS enabled.

Here is the working Mapserver map file: http://pastebin.com/VQBW5YSx

And here is the WMS mapfile: http://pastebin.com/swMagqma

Any help is appreciated.

Thanks, Matt

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I can use the following code to show your layers on top of Google Maps:

 var map;

    function init() {
            //Create the map object
            map = new OpenLayers.Map('map_element',{
                maxExtent: new OpenLayers.Bounds(
                -128 * 156543.0339,
                -128 * 156543.0339,
                128 * 156543.0339,
                128 * 156543.0339),
                maxResolution: 156543.0339,                
                units: 'm',
                projection: new OpenLayers.Projection('EPSG:900913'),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
            });

            //Google streets is the normal map type, so we don't need to pass in a type
            var google_streets = new OpenLayers.Layer.Google(
                "Google Streets",
                {numZoomLevels: 20}
            );



            var wms_layer=new OpenLayers.Layer.WMS("Min",
                'http://209.20.85.148/mapserv?map=/var/www/votevis/MN/2012-election/stsen/stsen-2012-wms.map',
            {layers:'sendist_border',transparent: true},
                {isBaseLayer: false,
                opacity: .7}
            );



            //Add the google map layers
            map.addLayers([google_streets, wms_layer ]);



            //Add a mouse position control
            map.addControl(new OpenLayers.Control.MousePosition());

            // Add a layer switcher control
            map.addControl(new OpenLayers.Control.LayerSwitcher({}));

            // Zoom the map to the max extent 
            if(!map.getCenter()){
                map.zoomToMaxExtent();
            }
        }
share|improve this answer
    
I approve (though I cannot upvote this because I lack enough reputation points). My problem was that I had sloppily cut and paste the WMS online resource from mapserver. I had left on the parameter "mode=map" on the URL in the OpenLayers.Layer.WMS second argument, and when I removed it (and added explicit layers that I was requesting, the problem went away, and this now works. Thank you so much! –  mpettis Oct 22 '12 at 3:59
    
I'm glad to help you out. –  Devdatta Tengshe Oct 22 '12 at 4:40

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.