[OpenLayers-Users] Set extent for mapserver's layer with gmap

Chen kuja eiclkun at gmail.com
Fri May 9 16:09:47 EDT 2008


hi,
    I've tried to set the extend for my map all the night, but failed.
    I set google map, world map and my own map as base maps, than i can
select one from the control box. But the problem is , my map is too
small——it's my university's map, and other two maybe too large. With the
default setting of extent from a tutorial, I have to zoom at least 20 times
to find my dormitory, else all my campus is a pixel. I've tried
"SphericalMercator.forwardMercator", it failed too. Maybe I understand it in
the wrong way. Here is the stuff:

            var map;
        function init() {
            map = new OpenLayers.Map('map');
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            var ext1 =
OpenLayers.Layer.SphericalMercator.forwardMercator(114.330527, 30.46327);
            var ext2 =
OpenLayers.Layer.SphericalMercator.forwardMercator(114.366537,
30.48481);

            var options = {
    projection: new OpenLayers.Projection("EPSG:900913"),
    units: "m",
    maxResolution: 156543.0339,
   // maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
       maxExtent: new OpenLayers.Bounds(ext1.lon, ext1.lat, ext2.lon,
ext2.lat)

};
            var map1 = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
                    "http://kuja.oicp.net/cgi-bin/mapserv.exe?", {
                    <!-- <script type="http://127.1/cgi-bin/mapserv.exe?", {
##for local-->
 map: '/ms4w/hzau/maps/map.map'} );

           var map2 = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
                    "http://kuja.oicp.net/cgi-bin/mapserv.exe?", {
                    <!-- <script type="http://127.1/cgi-bin/mapserv.exe?", {
##for local-->
 map: '/ms4w/hzau/maps/123.map'} );

               var gsat = new OpenLayers.Layer.Google(
                "Google Satellite",
                {type: G_SATELLITE_MAP}
            );


            map.addLayers([map1, map2, gsat]);

            map.setCenter(new OpenLayers.LonLat(114.349125, 30.475885), 2);
        }


Did I set sth wrong? Otherwise I have to calculate the extent with calc.exe,
silly way but may effects.
Besides, i added
'wms_srs'             'EPSG:4326 EPSG:900913'
to all my mapfiles , and <900913...> to proj.  , but still it seem to be a
little drift-- 0.3 cm on my screen,  i missed sth ?

Any helpful information will be appreciated. Tks in advance.

ps. this is my site, but it won't be available all the time, i share a adsl
2m with my roommates
http://kuja.oicp.net

the testpage, mapserver's layer with gmap (which bothered me the whole
night)
http://kuja.oicp.net/lite4.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080510/c1da11ab/attachment.html


More information about the Users mailing list