wms server v0.9

Topics: SharpMap Project, SharpMap v0.9 / v1.x, Web Controls
Aug 7, 2008 at 7:46 PM
attempting to use data from a postgis data source to create a wms layer to use in openlayers - started from v0.9 vb wms.ashx demo.
I get either multiple images drawn as tiles (8 tiles 255X255 in the example code) or a static single tile image depending on the OL layer creation code used.
I am unable to pan or zoom the result - just reloads the initial rendering. Does someone know of any examples that would assist me in getting a WMS layer working correctly?

EXAMPLE CODE:

<!

 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<

 

html xmlns="http://www.w3.org/1999/xhtml" >

 

 

<head>

 

 

<title>openlayers/sharpmap Example</title>

 

 

<link rel="stylesheet" href="../../../component/openlayers/theme/default/style.css" type="text/css" />

 

 

<link rel="stylesheet" href="../../../component/openlayers/theme/default/framedCloud.css" type="text/css" />

 

 

<style type="text/css">

 

 

#map {

 

 

width: 700px;

 

 

height: 510px;

 

 

border: 1px solid black;

 

}

 

</style>

 

 

<script type="text/javascript" src="../../../component/openlayers/OpenLayers.js"></script>

 

 

</head>

 

 

<body onload="init()">

 

 

<table style="width: 895px; height: 510px;">

 

 

<tr valign="top">

 

 

<td>

 

 

<div id="vmap" style="position: relative; width: 700px; height: 510px; overflow: hidden; border-style:ridge; border-width:thin;"></div>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

<script type="text/javascript">

 

 

var map = null;

 

 

var fileqry = null;

 

 

var width = 700;

 

 

var height = 510;

 

 

var zoom = 9;

 

 

var minlon = null;

 

 

var minlat = null;

 

 

var maxlon = null;

 

 

var maxlat = null;

 

 

var traclat = null;

 

 

var traclon = null;

 

 

var traczoom = null;

 

OpenLayers.IMAGE_RELOAD_ATTEMPTS=4;

OpenLayers.Util.onImageLoadErrorColor =

"transparent";

 

 

function lonLatToMercator(ll) {

 

 

var lon = ll.lon * 20037508.34 / 180;

 

 

var lat = Math.log (Math.tan ((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);

 

lat = lat * 20037508.34 / 180;

 

return new OpenLayers.LonLat(lon, lat);

 

}

 

function init(){

 

minlon = -16697000;

minlat = 8610000;

maxlon = -16667000;

maxlat = 8640000;

traclat = 8630000;

traclon = -16682000;

traczoom = 360;

map =

new OpenLayers.Map( 'vmap',

 

{maxExtent:

new OpenLayers.Bounds(-16697000,8610000,-16667000,8640000),

 

maxResolution:

"auto",

 

projection:

new OpenLayers.Projection("EPSG:3395") } );

 

map.addControl(

new OpenLayers.Control.LayerSwitcher({'ascending':false}));

 

fileqry =

"../../../component/sharpmap_wms.ashx?REQUEST=GetMap&Layers=Poly,PolyLabel,Lines,LineLabel&STYLES=&CRS=EPSG:3395&SRS=EPSG:3395&BBOX="+minlon+","+minlat+","+maxlon+","+maxlat+"&WIDTH="+width+"&HEIGHT="+height+"&FORMAT=image/png&BGCOLOR=0XC0D9D9&VERSION=1.3.0"

 

 

var layerSharpmap = new OpenLayers.Layer.WMS( "OpenLayers WMS",

 

fileqry, {transparent:

false, format: 'image/png'}, { 'isBaseLayer':true, buffer:1 } );

 

 

 

// *** as singleTile

 

 

//var layerSharpmap = new OpenLayers.Layer.WMS( "OpenLayers WMS",

 

 

// fileqry, {transparent: false, format: 'image/png'}, { 'isBaseLayer':true, singleTile:true, ratio:1, buffer:1 } );

 

 

var stlayer = new OpenLayers.Layer.WMS( "SUAS",

 

fileqry,

{layers:

'Poly,PolyLabel,Lines,LineLabel',

 

request:

'getmap' , transparent: "false", format: "image/png"},

 

{

'isBaseLayer':true}, { singleTile:true, ratio:1, buffer:1 }

 

);

map.addLayer(layerSharpmap);

map.setCenter(

new OpenLayers.LonLat(-149.9,61.175).transform(new OpenLayers.Projection("EPSG:3395"), new OpenLayers.Projection("EPSG:3395")), 11);

 

}

 

</script>

 

 

</body>

 

</

 

html>