[OpenLayers-Users] Using OpenLayers with a non WMS-Service

Thomas Buschhardt thomas at buschhardt.de
Thu Aug 13 05:50:22 EDT 2009


Hallo,
I want connect OpenLayers with a non WMS-map programm. I wrote a  
little php-Script as a bridge to this map-programm and Im able to  
request.
I can zoom-in and pan in this map but Im unable to zoom-out. I think I  
dont understand the logic of the boundig-box of OpenLayers.

I add a Image-Layer to OpenLayers and register an zoom/move-Event to  
this map to request the new coordinates.

If the script get the event - it throws the function showmap (its al  
little bit Ajax) and I send this new coordinates to the map-server and  
get a array with picture-url and bbox-coordinates back. My problem is  
the understanding of
layerExt and why I cant zoom-out.

Thank You for help me out.
Thomas


Here is the code:

function init(){
map = new OpenLayers.Map('map',{controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.MousePosition()
] });
//GIS-Karte Layer init - without picture
	var layerExt=new OpenLayers.Bounds(10.0,10.0,1000.0,1000.0);
	var layerSize=new OpenLayers.Size(500,500);
	layer=new OpenLayers.Layer.Image("GISDienstLayer","no- 
pic.jpg",layerExt,layerSize);
	map.addLayer(layer);

map.events.register("moveend", this, function() {
	if (!noaction){
		boundobj=this.map.getExtent();
		bbox=boundobj.toArray();
		lux=bbox[0];
		luy=bbox[1];
		rox=bbox[2];
		roy=bbox[3];
		noaction=true;
		showmap();
	}
	}
);
}


function showmap(){
	var anfrage=getXMLObject();
	anfrage.open("POST","gismap.php",true);
	anfrage.onreadystatechange=function(){
		if (anfrage.readyState==4){
			if (anfrage.status==200){
				var antwort=anfrage.responseText;
				pgAntwort=antwort.split("\t");
		//destroy old layer
		map.removeLayer(layer);

		//Extent BBox of the actual Picture
		picurl=pgAntwort[0];
		lux = parseFloat(pgAntwort[2]);
		luy = parseFloat(pgAntwort[3]);
		rox = parseFloat(pgAntwort[4]);
		roy = parseFloat(pgAntwort[5]);

		//maybe here is the problem

		var layerExt=new  
OpenLayers.Bounds(pgAntwort[2],pgAntwort[3],pgAntwort[4],pgAntwort[5]);
		var layerSize=new OpenLayers.Size(500,500);
		layer=new  
OpenLayers.Layer.Image("GISDienstLayer",picurl,layerExt,layerSize);
		map.addLayer(layer);
		//whats that?
		map.maxExtent=	new OpenLayers.Bounds(4000000,5000000,5000000,6000000);
		map.zoomToMaxExtent();
		noaction=false;
			}
		}
	}
	anfrage.setRequestHeader ("Content-Type", "application/x-www-form- 
urlencoded");
	anfrage.send("cmd=getmap&lux="+escape(lux)+"&luy="+escape(luy) 
+"&rox="+escape(rox)+"&roy="+escape(roy));
}



More information about the Users mailing list