Hello Attila,
I posted the item below to the OpenLayers forum regarding a similar problem.
As noted in the posting, if the overlay is not visible by default the initial
placement of the layer is off. However, any map move that fetches the data
again fixes the problem. I have received no answers to the posting nor have I
figured it out myself yet. This posting includes the map file and the
OpenLayers example.
In addition to what is in the posting below, you need to include the Google
projection (900913) definition in the PROJ4 data file. Information on that can
be found at this posting:
http://lists.osgeo.org/pipermail/mapserver-users/2008-August/057291.html
If you are using PostGIS, you will need to do both items 1 and 2. If you are
not using PostGIS, then I believe you only need item 1. Also, thanks to Paul
Ramsey, if you add the Google projection definition to the top of the PROJ4
epsg file (as well as the definitions of the other projections/coordinate
systems you are using) MapServer will make your map faster. (Thanks Paul, this
make a perceptible difference!).
I hope this helps,
Best regards,
-Linc
--- OpenLayers Posting ---
Using an overlay layer projected by MS (OpenLayer.MapServer object) to Google
(and Virtual Earth, EPSG 900913), if the overlay layer is initially visible
(visibility: true) then the overlay layer is correctly placed. If the initial
visibility is false, then upon the first fetch of the layer, it is NOT
correctly placed. However, any subsequent map navigation that causes a fetch
of the data correctly places the overlay layer. This behavior is consistent
using the layer switcher control and manually turning the layer on and off (not
including the layer switcher control).
The relevant portions of code are below. Sorry it is a bit long, but it is
needed for completeness.
Hopefully this is a newbie error on my part.
Any ideas?
Thanks,
-Linc
MS Map File Fragment...
PROJECTION
"init=epsg:900913" #Google
END #end projection
LAYER
NAME "senate"
connectiontype postgis
connection "user=xxxx password=xxxx dbname=xxxx host=xxxx port=xxxx"
data "geom from s17s0036_shapes"
PROJECTION
"init=epsg:4269"
END #end projection
TYPE polygon
STATUS OFF
CLASS
STYLE
OUTLINECOLOR 0 255 0
WIDTH 3
END #end style
END #end class
END #end layer
LAYER
NAME "senate_go"
connectiontype postgis
connection "user=xxx password=xxx dbname=xxx host=xxx port=xxx"
data "geom from s17s0036_go"
PROJECTION
"init=epsg:900913"
END #end projection
TYPE polygon
STATUS OFF
#MINSCALE 7000000
CLASS
STYLE
OUTLINECOLOR 255 0 0
WIDTH 3
END #end style
END #end class
END #end layer
900913 projection defined to PROJ4 and PostGIS per Subha Ramakrishnan's
MapServer posting of last week.
I used the OpenLayers Google Overlay example. I'm a newbie so it's not real
pretty.... In this code, I was trying to see if the layer switcher control was
the issue so I did not include it and manually toggled layer visibility.
<script type="text/javascript">
var map;
var senate;
var senate_go;
function init() {
map = new OpenLayers.Map('map',
{});
var gmap_r = new OpenLayers.Layer.Google("Google
Streets",
{projection: "EPSG:900913"}
);
senate_go = new OpenLayers.Layer.MapServer(
"State Senate Google",
"http://xxx/cgi-bin/mywms.exe", {map:
'wms_senate_go.map', layers: 'senate_go',
transparent: true, sphericalMercator: true
},
{ visibility: true, singleTile: true,
opacity: 0.5 } );
senate = new OpenLayers.Layer.MapServer( "State
Senate",
"http://xxx/cgi-bin/mywms.exe", {map:
'wms_senate_go.map', layers: 'senate',
transparent: true, sphericalMercator: true
},
{ visibility: true, singleTile: true,
opacity: 0.5 } );
map.addLayers([gmap_r]);
map.zoomToExtent(new OpenLayers.Bounds(-87.6,
24.3, -79.8, 31.1));
document.getElementById('cb_senate').checked =
false;
document.getElementById('cb_senate_go').checked =
false;
}
function toggleLayer(layer) {
if (layer == 'senate') {
if
(document.getElementById('cb_senate').checked) {map.addLayer(senate)}
else {map.removeLayer(senate)}
}
else
if
(document.getElementById('cb_senate_go').checked) {map.addLayer(senate_go)}
else {map.removeLayer(senate_go)}
}
</script>
</head>
<body onload="init()">
<h1 id="title">OpenLayers Google Example</h1>
<div id="tags"></div>
<p>
<input id="cb_senate" type="checkbox" value="senate"
onclick="toggleLayer(this.value)" /> Senate (EPSG:4269) <br>
<input id="cb_senate_go" type="checkbox" value="senate_go"
onclick="toggleLayer(this.value)" /> Senate (EPSG:900913) <br>
</p>
<div id="map"></div>
</body>
</html>
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Berényi Attila
Sent: Friday, August 29, 2008 9:21 AM
To: _mapserver
Subject: [mapserver-users] reprojection
Dear All,
I have a lot of data in epsg:23700 (HD-72 EOV), and I try to display it as an
overlay over Google Map (epsg:900913) in Openlayers trough WMS. Theoretically
it is possible to do this but I have no success at all...Which projection
should I define in tha main MAP part? And in the LAYER part?
Have anybody done something like this before? If yes, please help me.
Thanks in advance,
Attila Berényi
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users