0

I developed an script to display 2 layers ob base map.

but it is not zooming properlly.

I am using following code

can you please suggest me

<script type="text/javascript">
    var map, layer, select, hover, control;

    function init(){

        map = new OpenLayers.Map('map', {
            controls: [
                new OpenLayers.Control.PanZoom(),
                new OpenLayers.Control.Permalink(),
                new OpenLayers.Control.Navigation()
            ]
        });
             layer = new OpenLayers.Layer.WMS(
            "States WMS/WFS",
            "http://localhost:8080/geoserver/topp/wms",
            {layers: 'topp:india_road',transparent: true}

        );
        select = new OpenLayers.Layer.Vector("Selection", {styleMap: 
            new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
        });
        hover = new OpenLayers.Layer.Vector("Hover");
        map.addLayers([layer, hover, select]);
         var wmsLayer = new OpenLayers.Layer.Google('Google Layer',{} );
        map.addLayer(wmsLayer);



        map.setCenter(new OpenLayers.Bounds(143.83482400000003,-43.648056,148.47914100000003,-39.573891).getCenterLonLat(), 5);
    }
</script>

1 Answers1

0

What do you mean by not zooming properly?

Are you finding that they are not matching up with the google maps when zooming in as far as you can go, or the zoom work until you try to pan and then the layers don't stay lined up with google maps? If this is the case then you are probably zooming in further than is supported by the Google map service. There is no easy way to fix this and I recommend you alter allowed scales and zoom with the following settings

  • minScale - float -- the minimum scale value at which the layer should display
  • maxScale - float -- the maximum scale value at which the layer should display
  • numZoomLevels - int -- Total number of zoom levels Also please see this link on more information about google zoom scales.

If you are finding that none of your layers match the google background. I.E. they look like they are zoomed in out or offset then it is likely that your data is in a different projection to the google maps layer. Google maps uses EPSG:900913 as their SRS. The eisiest way to do this is to let geoserver do the re projection for you. Go to your layer setting in geoserver make sure you have the native projection set correctly and set the declared SRS to EPSG:900913.

If that doesn't help then I think we need more information on exactly what the problem is.

Darkcylde
  • 849
  • 5
  • 17