[OpenLayers-Users] WMS-layer: BBOX and SRS not being detected

InterRob rob.marjot at gmail.com
Tue Apr 26 05:52:07 EDT 2011


Ah!
Indeed, I already thought the solution would be trivial! Thanks, this solved
my problem.

As I am new to OpenLayers, I started off here:
http://docs.openlayers.org/

Too bad I couldn't find any hints on OL's defaulting when it comes to
projection, units, extents etc. In fact, I expect many newbies wanting to
deviate from the default EPSG:4326...

May I suggest to insert the below lines of code on this page:
http://docs.openlayers.org/library/introduction.html
    //set always mapOptions, if you use a projection other than EPSG:4326
    mapOptions = {

        projection: new OpenLayers.Projection("EPSG:28992"),
        units: "m",
        numZoomLevels: 18,
        maxResolution: 5,
        maxExtent: new OpenLayers.Bounds(131110,447700,131830,448310)
    };
    map = new OpenLayers.Map('map', mapOptions);

Ciao,
Rob

2011/4/22 Arnd Wippermann <arnd.wippermann at web.de>

>  hi,
>
> if you declare your map without options, then OL takes the default (see
> Map.js):
>
>     projection: "EPSG:4326",
>     units: 'degrees',
>     maxResolution: 1.40625,
>     maxExtent: new OpenLayers.Bounds(-180,-90,180,90),
> But it seems, when you declare a projection in your baselayer, then this
> projection overwrites the map projection and is used for the SRS parameter
> of the WMS request. But the maxExtent are still the default ones.
>
> You should use map options to overwrite the default.
>
>     //set always mapOptions, if you use a projection other than EPSG:4326
>     mapOptions = {
>
>         projection: new OpenLayers.Projection("EPSG:28992"),
>         units: "m",
>         numZoomLevels: 18,
>         maxResolution: 5,
>         maxExtent: new OpenLayers.Bounds(131110,447700,131830,448310)
>     };
>     map = new OpenLayers.Map('map', mapOptions);
> Arnd
>
>  ------------------------------
>  *Von:* openlayers-users-bounces at lists.osgeo.org [mailto:
> openlayers-users-bounces at lists.osgeo.org] *Im Auftrag von *InterRob
> *Gesendet:* Donnerstag, 21. April 2011 23:37
> *An:* openlayers-users at lists.osgeo.org
> *Betreff:* [OpenLayers-Users] WMS-layer: BBOX and SRS not being detected
>
> Dear list,
>
> Today I set up a MapServer WMS service. The service seems to work just
> fine, as I tested it with QGIS. Even the SRS is recognized automatically:
> EPSG:28992 (Dutch CS).
> At the bottom of this message, I copy/pasted the GetCapabilites-response.
>
> The bit of JavaScript used to load the OpenLayers control + map + layer, is
> classical:
>
> ============
>
>  var map, layer;
>   function init(){
>     map = new OpenLayers.Map( 'map' );
>     layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", "
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&", { layers
> : 'pgn_verwachting' }, { units : 'm', projection : new
> OpenLayers.Projection("EPSG:28992"), singleTile : true, buffer : 0, ratio :
> 1 } );
>
> ============
>
> In my browser, OpenLayers does load nicely (zoom and pan tools become
> available in the upper right corner of an empty map-div) and then does the
> following GET to fetch that single tile:
>
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&LAYERS=pgn_verwachting&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fjpeg&SRS=EPSG%3A28992&BBOX=-281.25,-210.9375,281.25,210.9375&WIDTH=800&HEIGHT=600
>
> I don't see how I can get the BBOX parameter right... What am I missing?
> When I edit the above URL, it works just fine, obviously...
>
> And shouldn't the SRS be detected automatically as well?
>
> Hints are much appreciated!
>
> Kind regards,
>
>
> Rob
>
>
>
> =============== GetCapabilities response ======================
> <?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?>
>  <!DOCTYPE WMT_MS_Capabilities SYSTEM "
> http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd"
>  [
>  <!ELEMENT VendorSpecificCapabilities EMPTY>
>  ]>  <!-- end of DOCTYPE declaration -->
>
> <WMT_MS_Capabilities version="1.1.1">
>
> <!-- MapServer version 5.6.6 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
> OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV
> SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
> SUPPORTS=WFS_CLIENT SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS
> INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->
>
> <Service>
>   <Name>OGC:WMS</Name>
>   <Title>Beleidskaart_Binnenstad</Title>
>   <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/>
>   <ContactInformation>
>   </ContactInformation>
> </Service>
>
> <Capability>
>   <Request>
>     <GetCapabilities>
>       <Format>application/vnd.ogc.wms_xml</Format>
>       <DCPType>
>         <HTTP>
>           <Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/></Get>
>           <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp
> ;"/></Post>
>         </HTTP>
>       </DCPType>
>     </GetCapabilities>
>     <GetMap>
>       <Format>image/gif</Format>
>       <Format>image/png</Format>
>       <Format>image/png; mode=24bit</Format>
>       <Format>image/jpeg</Format>
>       <Format>image/vnd.wap.wbmp</Format>
>       <Format>image/tiff</Format>
>       <Format>image/svg+xml</Format>
>       <DCPType>
>         <HTTP>
>           <Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/></Get>
>           <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp
> ;"/></Post>
>         </HTTP>
>       </DCPType>
>     </GetMap>
>     <GetFeatureInfo>
>       <Format>text/plain</Format>
>       <Format>application/vnd.ogc.gml</Format>
>       <DCPType>
>         <HTTP>
>           <Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/></Get>
>           <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp
> ;"/></Post>
>         </HTTP>
>       </DCPType>
>     </GetFeatureInfo>
>     <DescribeLayer>
>       <Format>text/xml</Format>
>       <DCPType>
>         <HTTP>
>           <Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/></Get>
>           <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp
> ;"/></Post>
>         </HTTP>
>       </DCPType>
>     </DescribeLayer>
>     <GetLegendGraphic>
>       <Format>image/gif</Format>
>       <Format>image/png</Format>
>       <Format>image/png; mode=24bit</Format>
>       <Format>image/jpeg</Format>
>       <Format>image/vnd.wap.wbmp</Format>
>       <DCPType>
>         <HTTP>
>           <Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/></Get>
>           <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp
> ;"/></Post>
>         </HTTP>
>       </DCPType>
>     </GetLegendGraphic>
>     <GetStyles>
>       <Format>text/xml</Format>
>       <DCPType>
>         <HTTP>
>           <Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;"/></Get>
>           <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp
> ;"/></Post>
>         </HTTP>
>       </DCPType>
>     </GetStyles>
>   </Request>
>   <Exception>
>     <Format>application/vnd.ogc.se_xml</Format>
>     <Format>application/vnd.ogc.se_inimage</Format>
>     <Format>application/vnd.ogc.se_blank</Format>
>   </Exception>
>   <VendorSpecificCapabilities />
>   <UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1"
> RemoteWFS="0"/>
>   <Layer>
>     <Name>Beleidskaart_Binnenstad</Name>
>     <Title>Beleidskaart_Binnenstad</Title>
>     <Abstract>Beleidskaart_Binnenstad</Abstract>
>     <SRS>EPSG:28992</SRS>
>     <LatLonBoundingBox minx="5.03953" miny="52.0181" maxx="5.05006"
> maxy="52.0236" />
>     <BoundingBox SRS="EPSG:28992"
>                 minx="131110" miny="447700" maxx="131830" maxy="448310" />
>     <Layer queryable="0" opaque="0" cascaded="0">
>         <Name>pgn_verwachting</Name>
>         <Title>pgn_verwachting</Title>
>         <LatLonBoundingBox minx="5.04025" miny="52.0182" maxx="5.04993"
> maxy="52.0236" />
>         <BoundingBox SRS="EPSG:28992"
>                     minx="131160" miny="447707" maxx="131821" maxy="448305"
> />
>         <Style>
>           <Name>default</Name>
>           <Title>default</Title>
>           <LegendURL width="147" height="41">
>              <Format>image/png</Format>
>              <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:type="simple" xlink:href="
> http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&amp;version=1.1.1&amp;service=WMS&amp;request=GetLegendGraphic&amp;layer=pgn_verwachting&amp;format=image/png&amp;STYLE=default<http://localhost/mapserv?map=/var/www/geo/binnenstad_wms.map&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=pgn_verwachting&format=image/png&STYLE=default>
> "/>
>           </LegendURL>
>         </Style>
>     </Layer>
>   </Layer>
> </Capability>
> </WMT_MS_Capabilities>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110426/f0e04281/attachment-0001.html


More information about the Users mailing list