[OpenLayers-Users] WMS and Google Maps - Overlayer Alignement

CLAY.LINC CLAY.LINC at flsenate.gov
Tue Aug 26 11:08:51 EDT 2008


Hello List,

Regarding this issue, I am experiencing the following behavior.

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>

-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of Salvaro
Sent: Tuesday, August 26, 2008 9:45 AM
To: users at openlayers.org
Subject: Re: [OpenLayers-Users] WMS and Google Maps - Overlayer
Alignement


I found a part of the generated JS, but it looks like useless:
"mapOptions_0 = (mapOptions = $MapOptions(new MapOptions()) ,
mapOptions.element['maxResolution'] = 156543.03125 , maxExtent =
$Bounds(new
Bounds(), -20037508, -20037508, 20037508, 2.003750834E7) ,
mapOptions.element['controls'] = $JObjectArray_0(new JObjectArray(),
initValues(_3Lcom_google_gwt_core_client_JavaScriptObject_2_classlit,
1184,
-1, [])).element , mapOptions.element['restrictedExtent'] =
maxExtent.element , mapOptions.element['numZoomLevels'] = 19 ,
mapOptions.element['projection'] = 'EPSG:900913' ,
$setAttribute_0(mapOptions, 'displayProjection', WSG84.element) ,
mapOptions.element['units'] = 'km' , mapOptions); "

But I found something "new", when I put the zoom in the maximun is
possible
to change the position of Map in some metres (kilometres after I changed
the
units), so, I guess the problem probably should be in the coordinates
passed
when the map is with Spherical Mercator true (probably is passing
anything
like 0.00023 in the place of 23.000), I find for something in the source
of
the lib but if I change the value of coordinates direct in Navigation.js
it
will not work in WMS. Is possible do something to pass the correct
coordinates to move the map? Is anything wrong in the code?

Thanks!
-- 
View this message in context:
http://n2.nabble.com/WMS-and-Google-Maps---Overlayer-Alignement-tp781460
p784107.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users



More information about the Users mailing list