[OpenLayers-Users] Call Mapfile layer with Openlayers
whenstatus ON or OFF
Arnd Wippermann
arnd.wippermann at web.de
Wed Sep 9 18:06:40 EDT 2009
Hi Paul,
by default OpenLayers use EPSG:4326 for the map, if not otherwise declared.
The extent for the whole world are -180,-90,180,90 with a resolution of
1.40. From your extent it seems, you want an other projection. So you have
to declare the projection in the map options.
Arnd
_____
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Paul Curran
Gesendet: Mittwoch, 9. September 2009 22:20
An: Alexandre Dube
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Call Mapfile layer with Openlayers
whenstatus ON or OFF
Thanks for your responses
I have now removed the map parameter as suggested. I am just trying to
display one layer correctly and i will then add my second layer when my
single layer looks right.
My layer is now displaying tiled across the screen several times and quite
zoomed out, i cannot zoom in or out
My code now looks as follows:
var bounds = new OpenLayers.Bounds(0, 0, 660046, 1229782);
var map, layer1, layer2;
var options = { maxExtent: bounds, maxResolution: 600, numZoomLevels:
10};
function init(){
map = new OpenLayers.Map('map', options);
layer1 = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://localhost/cgi-bin/mapserv.exe?mode=map
<http://localhost/cgi-bin/mapserv.exe?mode=map&map=c:/ms4w/apps/openlayers-2
.5/data/uk2.map> &map=c:/ms4w/apps/openlayers-2.5/data/uk2.map", { layers:
"250" },
{ gutter: 15, minZoomLevel: 1, maxZoomLevel: 4 });
map.addLayer(layer1);
map.zoomToExtent(bounds);
map.setCenter(bounds);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MousePosition());
}
Any more much much appreciatted
Cheers
2009/9/9 Alexandre Dube <adube at mapgears.com>
Hi Paul,
You can copy the image url by right clicking on it and open it in a new
window. You'll see the request url constructed by OpenLayers and maybe an
error message from MapServer.
I noticed that you use the "map" parameter. WMS has no such parameter so it
should be part of your main url, like below. Also, if you look in the
OpenLayers/Layer/WMS.js code, you'll see that this object takes 4
parameters, the 3e being the server-side "parameters" and the 4th being the
OpenLayers object "options". min/maxZoomLevel are not parameters but OL
options.
layer1 = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://127.0.0.1/cgi-bin/mapserv.exe?map=/ms4w/apps/openlayers-2.5/data/uk2
.map
<http://127.0.0.1/cgi-bin/mapserv.exe?map=/ms4w/apps/openlayers-2.5/data/uk2
.map&> &",
{ layers: "uk"},
{ gutter: 15, minZoomLevel: 1, maxZoomLevel: 4 }
);
If you still get pink tiles, copy the link in a new window to see the error.
Regards,
Alexandre
Paul Curran wrote:
Hi
I can view my UK Layer via Mapserver with the following url:
'ms4w/cgi-bin/mapserv.exe?mode=map&map=c:mapdirectory*&layer=uk'.* The
*&layer=uk *is calling my layer.
However I cant find any documentation on how to call the layer when viewing
my map within OpenLayers.
I am currently trying to call the layer like this:
var map, layer1, layer2;
var options = { maxExtent: bounds, maxResolution: 600, numZoomLevels: 10};
layer1 = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://127.0.0.1/cgi-bin/mapserv.exe?", { layers: "uk", map:
'/ms4w/apps/openlayers-2.5/data/uk2.map',
minZoomLevel: 1, maxZoomLevel: 4 },
{ gutter: 15 });
layer2 = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://127.0.0.1/cgi-bin/mapserv.exe?", { layers: "250", map:
'/ms4w/apps/openlayers-2.5/data/uk2.map',
minZoomLevel: 5, maxZoomLevel: 10},
{ gutter: 15 });
map.addLayer(uk, 250);
map.zoomToExtent(bounds);
map.setCenter(bounds);
map.zoomToMaxExtent();
However I am just seeing pink tiles within OpenLayers.
Note: If my layers are set to default within my Mapfile all my layers are
displayed.
Thanks for any help in advance
Paul
------------------------------------------------------------------------
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
--
Alexandre Dubé
Mapgears
www.mapgears.com <http://www.mapgears.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090910/6dfb02f1/attachment.html
More information about the Users
mailing list