<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt">Hi ,<br>I tried to follow th exemple given by Brent Pedersen <a href="http://giifweb.cnr.berkeley.edu/fire/wind/gfi/gfi.html">http://giifweb.cnr.berkeley.edu/fire/wind/gfi/gfi.html</a><br>to get a feature info from a map got from geoserver but it dosen't work the problem is with OpenLayers.loadURL ( I use Openlayers 2.3)<br><br>and here is my code :<br><br><span></span><br> <head><br> <style type="text/css"><br> #map {<br> width: 600px;<br> height: 600px;<br> border: 1px inset black;<br>
}<br> </style><br> <script><br> if(window.console == undefined){ console = {}; console.debug = function(){}}<br> </script><br> <script src="../lib/OpenLayers.js"></script><br> <script type="text/javascript"><br> var map, layers;<br><br><br> OpenLayers.Layer.WMS.prototype.getFeatureInfoURL = function(e/*,info_format*/){<br> var x = e.xy.x<br> var y = e.xy.y<br> /*<br> var el = Event.findElement(e,'div');<br> var p =
OpenLayers.Util.pagePosition(el);<br> x -= p[0];<br> y -= p[1];<br> */<br><br> // var url = this.getURL(this.map.getExtent())<br> // .replace(/getMap/i,'GetFeatureInfo');<br><br> var ms = this.map.getCurrentSize();<br> var format = arguments.length > 1 ? arguments[1] : 'text/plain'<br><span> var url = '<a target="_blank"
href="http://localhost:8080/geoserver/wms?bbox=-130,24,-66,50&styles=population&format=jpeg&info_format=text/plain&request=GetFeatureInfo&layers=topp:states&query_layers=topp:states&width=550&height=250&x=170&y=160">http://localhost:8080/geoserver/wms?bbox=-130,24,-66,50&styles=population&format=jpeg&info_format=text/plain&request=GetFeatureInfo&layers=topp:states&query_layers=topp:states&width=550&height=250&x=170&y=160</a>';</span><br> //url = url.replace(/&width=[^&\?$]+/i,'&WIDTH=' + ms.w)<br> // .replace(/&height=[^&\?$]+/i,'&HEIGHT=' + ms.h)<br> alert(url);<br> return
url <br> };<br><br><br><br><br> function init(){<br><br> map = new OpenLayers.Map($('map'),{projection:'EPSG:4326',<br> controls: [new OpenLayers.Control.MouseDefaults()],<br> maxExtent: new OpenLayers.Bounds(-130,24,-66,50)<br><br> });<br> <br> muni = new OpenLayers.Layer.WMS( "Cities and Counties",<br><span> "<a target="_blank"
href="http://localhost:8080/geoserver/wms">http://localhost:8080/geoserver/wms</a>?"</span><br> , {layers: 'topp:states', format: 'image/png' }<br> , { <br> tileSize: new OpenLayers.Size(512,512)<br> ,isBaseLayer:true<br>
,reproject:false<br> }<br> );<br><br> map.addLayer(muni);<br><br> map.addControl(new OpenLayers.Control.PanZoomBar());<br> map.addControl(new OpenLayers.Control.LayerSwitcher());<br><br> <br> map.zoomToMaxExtent()<br><br> map.events.register('click',map,mapquery);<br> <br><br><br>function mapquery(evt){<br> var url =
muni.getFeatureInfoURL(evt);<br> alert(url);<br> OpenLayers.loadURL(url,{},this,function(req){ // the problem is here<br> alert(req.responseText) <br> <br> });<br>}<br><br><br> }<br><br> </script><br> </head><br><br> <body onload="init()"><br> <div id="map"></div><br> </body><br></html><br><br><br></div><br>
<hr size="1">
Découvrez <a href="http://blog.mail.yahoo.fr">le blog Yahoo! Mail</a> : dernières nouveautés, astuces, conseils.. et vos réactions !</body></html>