[OpenLayers-Users] displacement of google satellite data compared to google streetmap

Andreas Hocevar andreas.hocevar at gmail.com
Fri Apr 24 16:35:13 EDT 2009


Jo Cook wrote:
> Hi Andreas,
>
> I've tried your new patch for bug 1797 but it doesn't do anything for me. I
> don't know if it's because I'm not seeing this problem when I resize the
> map, but when I simply switch layers. I'm not using a vector layer over the
> top, just a WMS (non baselayer), so I haven't seen the issues with popup
> alignment.
>   

So it seems your issue is a different one. Maybe you have some weird css
on the page where you place the map? Try to use the code you posted
below in an empty html page without css and just a map div.

Other than that, does the workaround to specify the map div's width and
height in pixels work for you?

Regards,
Andreas.

> Andreas Hocevar-2 wrote:
>   
>> Hi,
>>
>> this is a known issue, unfortunately without a good solution at the
>> moment:
>> http://trac.openlayers.org/ticket/1797
>> http://trac.openlayers.org/ticket/2055
>>
>> A workaround is to specify the map div's width and height in pixels.
>>
>> Regards,
>> Andreas.
>>
>> Joanne Cook wrote:
>>     
>>> Hi List,
>>>
>>> I have a map that I thought was all correctly set up to use spherical
>>> mercator, and all my data (which is all projected in 900913) is correctly
>>> displaying on either open streetmap or google streets data. However, when
>>> I add a google satellite or hybrid layer, the initial load of the map
>>> shows the satellite layer displaced several hundred miles to the west. If
>>> I switch to the google streets layer without any zooming or panning, the
>>> displacement disappears. If I then switch back to the google satellite
>>> layer, again with no zooming or panning, it appears in the correct place.
>>> Throughout all of this, my data layer has no displacement. Furthermore,
>>> since all of this is set within mapfish, with extjs used for side panels,
>>> if I minimise the side panel while the displacement is occurring it also
>>> removes the displacement. I'm using the svn versions of openlayers and
>>> mapfish.
>>>
>>> This is the code relating to setting up the map and layers:
>>>
>>> function createMap() {
>>> 	var options = {
>>> 		projection: new OpenLayers.Projection("EPSG:900913"),
>>>         displayProjection: new OpenLayers.Projection("EPSG:27700"),
>>>         units: "m",
>>>         maxResolution: 156543.0339,
>>>         maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
>>>                                                  20037508.34,
>>> 20037508.34)
>>> 	};
>>> return new OpenLayers.Map('olmap',options);
>>> } //end createmap
>>>
>>> function addlayers(map){
>>> 	
>>> 	
>>> 	// define wms
>>> 	layer = new OpenLayers.Layer.WMS("OA Sites WMS",
>>> "http://geoserver.thehumanjourney.net:80/geoserver/wms?",
>>>                            {layers: 'oadigi:oasites', transparent: true,
>>> format: 'image/png', buffer:0},
>>>                             {isBaseLayer: false});
>>> 	
>>> 	
>>> 	
>>> 	// create Google Mercator layers
>>>             var gmap = new OpenLayers.Layer.Google(
>>>                 "Google Streets",
>>>                 {'sphericalMercator': true}
>>>             );
>>>             var gsat = new OpenLayers.Layer.Google(
>>>                 "Google Satellite",
>>>                 {type: G_SATELLITE_MAP, 'sphericalMercator': true,
>>> numZoomLevels: 22}
>>>             );
>>>             var ghyb = new OpenLayers.Layer.Google(
>>>                 "Google Hybrid",
>>>                 {type: G_HYBRID_MAP, 'sphericalMercator': true}
>>>             );
>>>
>>>     	
>>> 	// define pseudo-layer for highlighting selected features
>>> 	select = new OpenLayers.Layer.Vector("Selection", 
>>> 		{protocol: new mapfish.Protocol.TriggerEventDecorator(protocol),
>>> 		strategies: [new mapfish.Strategy.ProtocolListener({append: true})],
>>> 		styleMap: new
>>> OpenLayers.Style(OpenLayers.Feature.Vector.style["select"]), 
>>> 		displayInLayerSwitcher: false});
>>> 		
>>>     
>>> 	// add layers
>>> 	map.addLayers([layer, select, gmap, gsat, ghyb]);
>>>
>>> } //end addlayers
>>>
>>> function setMapCenter() {
>>> //define a new projection object so map can be centred using latlong
>>> 	var proj = new OpenLayers.Projection("EPSG:4326");
>>> 	var point = new OpenLayers.LonLat(-2.9, 53.6);
>>> 	this.setCenter(point.transform(proj, this.getProjectionObject()), 6);
>>> } //end setMapCenter
>>>
>>> I hope that's enough information for someone as it's hard for me to get
>>> this map accessible to the outside world yet.
>>>
>>> Many thanks
>>>
>>> Jo
>>>
>>>   
>>>       
>> -- 
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>>     
>
>   




More information about the Users mailing list