Hi Guys,<br><br>I am so tired of trying to over lay WFS. I am totally clueless. Have gone through probably all the sites and gis.Stack but all have the same code but it is not working for me?<br><br>I am not sure why is that the case. The firebug is giving me this error<br>
<br><font color="#ff0000">XMLHttpRequest cannot load <a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>. Origin <a href="http://localhost">http://localhost</a> is not allowed by Access-Control-Allow-Origin.</font><br>
<br>Here is my code,<br><br><body><br> <h1>iPlant Map</h1><br> <div id="map-id"></div><br> <script><br> var map = new OpenLayers.Map("map-id");<br>
var bio = new OpenLayers.Layer.WMS(<br> "bio11",<br> "<a href="http://localhost:8080/geoserver/iPlant/wms">http://localhost:8080/geoserver/iPlant/wms</a>",<br> {layers: 'iPlant:bio11'}<br>
);<br> var imagery = new OpenLayers.Layer.WMS(<br> "Global Imagery",<br> "<a href="http://maps.opengeo.org/geowebcache/service/wms">http://maps.opengeo.org/geowebcache/service/wms</a>",<br>
{layers: "bluemarble"}<br> );<br> <br> /*var QuebecSpecies = new OpenLayers.Layer.WMS(<br> "AllQuebecSpecies",<br> "<a href="http://localhost:8080/geoserver/iPlant/wms">http://localhost:8080/geoserver/iPlant/wms</a>",<br>
{layers: 'iPlant:AllQuebecSpecies'},<br> {'opacity': 0.4, 'isBaseLayer': false, 'visibility': true}<br> );*/<br> <br> var QuebecSpecies = new OpenLayers.Layer.Vector(<br>
"AllQuebecSpecies",<br> {<br> strategies: [new OpenLayers.Strategy.Fixed()],<br> projection: new OpenLayers.Projection("EPSG:4326"),<br> visibility: true,<br>
protocol: new OpenLayers.Protocol.WFS({<br> version: "1.1.0",<br> url: "<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>",<br>
featurePrefix: 'iPlant', //geoserver worspace name<br> featureType: "iPlant:AllQuebecSpecies", //geoserver Layer Name<br> featureNS: "<a href="http://geoserver.org/iPlant">http://geoserver.org/iPlant</a>", // Edit Workspace Namespace URI<br>
geometryName: "the_geom" // field in Feature Type details with type "Geometry"<br> })<br> });<br> <br> QuebecSpecies.refresh();<br> map.addLayers([imagery, bio, QuebecSpecies]); //map.addLayers([imagery, bio, vectors]);<br>
map.addControl(new OpenLayers.Control.LayerSwitcher());<br> map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));<br> map.events.register("mousemove", map, function(e) { <br>
var latlon = map.getLonLatFromViewPortPx(e.xy) ;<br> var lat = Math.round(latlon.lat);<br> var lon = Math.round(latlon.lon); <br> OpenLayers.Util.getElement("location").innerHTML = "The Latitude is " + lat +<br>
" and the Longitude is " + lon;<br> <br> <br> map.zoomToMaxExtent();<br> </script><br> <div id="location">Position</div><br></body><br>
<br>Please tell me where am I going wrong?<br><br>-- <br>Thanks & Regards<br>Smaran Harihar