[OpenLayers-Users] Problem with the position of the WMS when I switch the type of map

Diego Roberto diegorrborges at yahoo.com.br
Mon Dec 9 05:09:05 PST 2013


I'm working with OpenLayers and GeoServer , I'm using a WMS layer to display some items , and as a layer map , the following code :



MAP = {
map: undefined
};

var map = new OpenLayers.Map({
div: "map",
maxExtent: boundsMap,
minZoomLevel: 6,
maxResolution: 0.0146771208047863,
projection: 'EPSG:4326'
});

MAP.map = map;

gmap = new OpenLayers.Layer.Google("Google Streets",{baseLayer: false});

format = 'image/png';
layerGeoPolitic = new OpenLayers.Layer.WMS(
"madeingoias:city_layer - Tiled", GEOSERVER_HOST+"/geoserver/madeingoias/wms",
{
LAYERS: 'madeingoias:city_layer',
STYLES: 'region_planned',
format: format,
tiled: true,
transparent: true,
noMagic : true,
tilesOrigin : MAP.map.maxExtent.left + ',' + MAP.map.maxExtent.bottom
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true,
tileOrigin: new OpenLayers.LonLat(-180, -90),
yx : {'EPSG:4326' : true}
});

MAP.map.addLayers([gmap , layerGeoPolitic]);

Everything works fine , however the big problem occurs when I change the layer to the map and go back to the WMS .
To change to the map layer I use the following code :



MAP.map.setBaseLayer(gmap);
MAP.map.setCenter(new OpenLayers.LonLat(-49.002457,-16.003576).transform(new OpenLayers.Projection("EPSG:4326"), MAP.map.getProjectionObject()), 0);
E para voltar para a camada WMS eu utilizo:
layerGeoPolitic.setVisibility(true);
MAP.map.setBaseLayer(layerGeoPolitic);
MAP.map.zoomToExtent(boundsMap);

The no error in FireFox console, plus map does not appear , and in chrome as it is in the attached image .


Using FireFox is loaded after all I use :


MAP.map.setBaseLayer(gmap);
MAP.map.setBaseLayer(layerGeoPolitic);
MAP.map.zoomToExtent(boundsMap);

I've tried using a setTimeout to give a delay in code , most still not working .

Does anyone have any suggestions ?

Thank you for your attention .
Diego.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20131209/264ac271/attachment-0001.html>


More information about the Users mailing list