[OpenLayers-Users] Display WMS over OSM with OL
Juán David
juda87 at yahoo.com
Wed Oct 17 12:19:23 PDT 2012
Good morning,
I´m writing this mail because i need some help with OL, and i couldn´t find any solution on the web.
I work in a map overlaping a wms point layer over OSM and this only displays the overlay when map is in max_extent but when i use zoom in twice the overlay dissapears, this overlay have get_feature option active and it loads the info when a click over any wms point but i cant see any point indeed.
I guess it isn' t a projection problem because the wms attributes are loaded when click in any point even if i can´t see any of them. The wms have EPSG: 4326 and 900913 support. Besides i tried to use a wms base layer (with EPSG:4326) and it works without any problem.
Thanks for the help and sorry for my english.
Juan David Rondón Díaz
Bogotá, Colombia
Here is the code:
<!DOCTYPE html>
<html lang='es'>
<head>
<meta charset='utf-8' />
<title>Cuenca Río Bogotá</title>
<script type='text/javascript' src='OpenLayers.js'></script>
<script type='text/javascript'>
var map, info;
function init() {
var options = {
projection: new OpenLayers.Projection("EPSG:4326"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
};
map = new OpenLayers.Map('map_element', options);
var base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");
var base2 = new OpenLayers.Layer.WMS(
'Base layer',
'http://vmap0.tiles.osgeo.org/wms/vmap0',
{layers: 'basic'},
{isBaseLayer: true}
);
var rio = new OpenLayers.Layer.WMS(
'Rio Bogota',
'http://host.com/cgi-bin/mapserv.exe?map=C:/OSGeo4W/apache/maps/r_bogota2.map',
{layers: 'Cuenca Rio Bogota',
visibility: true, transparent: true}
);
map.addLayers([base2,base,rio]);
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://host.com/cgi-bin/mapserv.exe?map=C:/OSGeo4W/apache/maps/r_bogota2.map',
title: 'Click para consultar',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"chicken",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
}
}
});
map.addControl(info);
info.activate();
map.addControl(new OpenLayers.Control.LayerSwitcher({}));
if(!map.getCenter()){
map.zoomToMaxExtent();
}
}
</script>
</head>
<body onload='init();'>
<div id='map_element' style='width: 800px; height: 600px;'>
</div>
</body>
</html>
More information about the Users
mailing list