Been playing with OpenLayers, GeoServer and the TIGER roads shapefile but cannot get it to line up correctly over New York. I have looked online and followed the instructions regarding setting the projections and setting Google Maps to sphericalmercator = true, however it still doesn't line up correctly.

Any ideas?

        var map;
        var untiled;
        var tiled;
        var pureCoverage = false;
        // pink tile avoidance
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
        // make OL compute scale according to WMS spec
        OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;

        function init(){
            format = 'image/png';

            var bounds = new OpenLayers.Bounds(
                -20037508, -20037508,
                20037508, 20037508.34

            var options = {
                projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
                maxExtent: bounds,
                //maxResolution: 0.00075764453125,
                units: 'm'

           map = new OpenLayers.Map('map', options);

           var GoogleMap = new OpenLayers.Layer.Google(
                "Google Satellite", {
                type: G_SATELLITE_MAP,
                maxZoomLevel: 30,
                "sphericalMercator": true

            // setup tiled layer
            wmsLayer = new OpenLayers.Layer.WMS(
                "tiger_roads - Tiled", "http://localhost:8080/geoserver/wms",
                    layers: 'tiger:tiger_roads',
                    styles: '',
                    format: format,
                    tiled: 'true',
                    isBaseLayer: false

            map.addControl(new OpenLayers.Control.MouseDefaults()); 
            map.addControl(new OpenLayers.Control.Navigation());
            map.addControl(new OpenLayers.Control.ZoomBox({alwaysZoom:true}));
            // Coordinate display at bottom of map
            map.addControl(new OpenLayers.Control.MousePosition()); 
            map.addLayers([GoogleMap, wmsLayer]);

           var point = new OpenLayers.LonLat(-73.96543, 40.78885); 
           // Need to convert zoom point to mercator too
           point.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); 
           map.setCenter(point, 12); 

  • just tried the tasmania wms and it seems to overlay correctly although is doesnt match up with the island very well. How accurate are the demo shapefiles offered by geoserver Apr 13, 2011 at 10:17

2 Answers 2


You should include proj4js library to your project. Did you? If not, see the userguide and that wiki page for instructions.


In Google Maps, there are slightly difference in between satellite and streetmap. Could you try with streetmap whether it match with layer. I tried GeoServer tiger roads with openstreet maps and it looks fine.

Note that for Google maps integration with GeoServer, Openlayers alone is enough at client side.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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