[OpenLayers-Users] WMS overlay with Google and OSM
Dan Lear
dble at MBA.ac.uk
Fri Aug 12 09:37:10 EDT 2011
Hi,
I have the following code (mostly lifted from the OL examples):
<script type="text/javascript">
var lon = 5;
var lat = 40;
var zoom = 5;
var map, select;
function init(){
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
map = new OpenLayers.Map('map', options);
var mapnik = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");
var gmap = new OpenLayers.Layer.Google("Google", {sphericalMercator:true});
var dm_wms = new OpenLayers.Layer.WMS(
"Crab Data",
"http://warehouse1.indicia.org.uk:8080/geoserver/wms?bbox=-142385,6693234,25943,6710384&styles=dist_point_blue&Format=image/png&request=GetMap&version=1.1.1&layers=risc:mitten_crab_all&width=800&height=300&srs=EPSG:4326&cql_filter=record_status=%27C%27"
,
{isBaseLayer: false, visibility: false}
);
map.addLayers([mapnik, gmap, dm_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToExtent(
new OpenLayers.Bounds(
68.774414, 11.381836, 123.662109, 34.628906
).transform(map.displayProjection, map.projection)
);
}
</script>
Which I want overlay the WMS from a Geoserver instance (dm_wms), but it isn't displaying, I suspect it's a projection issue, but don't understand enough to fix it! Also need the map to set focus on the UK, is there somewhere I can find the bounds required or is it just a case of trial and error?
Thanks for any help received,
Dan
More information about the Users
mailing list