[OpenLayers-Users] Unable to still get WFS info

Andreas Hocevar ahocevar at opengeo.org
Tue Jun 5 06:27:01 PDT 2012


Hi,

wrong control! You have loaded your features with WFS already, so use
OpenLayers.Control.SelectFeature instead of
OpenLayers.Control.WMSGetFeatureInfo.

The warnings about event.layerX etc. don't do any harm.

Andreas.

On Sun, Jun 3, 2012 at 1:22 AM, Smaran Harihar <smaran.harihar at gmail.com> wrote:
> Hi guys,
>
> Despite having re-installed the complete open-geo suite, I am still not able
> to obtain the PopUp. I have added the cgi-script according to the FAQ of
> OpenLayers but without any success.
>
> What am I doing wrong? It seems that the XmlHttpRequest continues to persist
> (I think, because now that I am directly accessing it from the server, I am
> getting only warnings, like this,
> event.layerX and event.layerY are broken and deprecated in WebKit. They will
> be removed from the engine in the near future.)
>
> This is my entire code. You can access it as well by going to the following
> site,
>
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>iPlant Map</title>
> <link rel="stylesheet" href="openlayers/theme/default/style.css"
> type="text/css">
> <style>
> #map-id {
> width: 1024px;
> height: 512px;
> }
>
> </style>
> <script src="openlayers/lib/OpenLayers.js"></script>
> <script type="text/javascript"
> src="http://maps.googleapis.com/maps/api/js?sensor=false&v=3.6"></script>
> </head>
> <body>
> <h1>iPlant Map</h1>
> <div id="map-id"></div>
> <script>
> OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
> //OpenLayers.ProxyHost = "proxy.jsp?";
> var map = new OpenLayers.Map("map-id");
> var bio = new OpenLayers.Layer.WMS("bio11",
> "http://niles.iplantcollaborative.org:8080/geoserver/wms", {
> layers : 'bio11'
> });
>
> /*var QuebecSpecies = new OpenLayers.Layer.WMS("AllQuebecSpecies",
> "http://localhost:8080/geoserver/iPlant/wms", {
> layers : 'iPlant:AllQuebecSpecies',
> transparent : true
> }, {
> 'isBaseLayer' : false
> });*/
> var QuebecSpecies = new OpenLayers.Layer.WMS("All Quebec Species",
> "http://niles.iplantcollaborative.org:8080/geoserver/wms", {
> layers : 'AllQuebecSpecies',
> transparent : true
> }, {
> 'isBaseLayer' : false
> });
>
> var pima = new OpenLayers.Layer.WMS("Pima Pines",
> "http://niles.iplantcollaborative.org:8080/geoserver/wms", {
> layers : 'PimaPine',
> transparent : true
> }, {
> 'isBaseLayer' : false
> });
>
> var carib = new OpenLayers.Layer.WMS("Carribbean Pine",
> "http://niles.iplantcollaborative.org:8080/geoserver/wms", {
> layers : 'CaribPine',
> transparent : true
> }, {
> 'isBaseLayer' : false
> });
> var vector_layer = new OpenLayers.Layer.Vector('Editable Vectors');
> map.addLayers([bio, QuebecSpecies, pima, carib, vector_layer]);
> /*var QuebecSpecies = new OpenLayers.Layer.Vector("AllQuebecSpecies", {
> strategies : [new OpenLayers.Strategy.Fixed()],
> projection : new OpenLayers.Projection("EPSG:4326"),
> visibility : true,
> protocol : new OpenLayers.Protocol.WFS({
> version : "1.1.0",
> url : "http://localhost:8080/geoserver/iPlant/wfs",
> featurePrefix : 'iPlant', //geoserver worspace name
> featureType : "AllQuebecSpecies", //geoserver Layer Name
> featureNS : "http://geoserver-iPlant", // Edit Workspace Namespace URI
> geometryName : "the_geom" // field in Feature Type details with type
> "Geometry"
> })
> });*/
>
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> map.addControl(new OpenLayers.Control.MousePosition({
> element : $('location')
> }));
> map.addControl(new OpenLayers.Control.EditingToolbar(vector_layer));
> map.events.register("mousemove", map, function(e) {
> //var position = this.events.getMousePosition(e);
> //var position = OpenLayers.Control.MousePosition(e);
> var latlon = map.getLonLatFromViewPortPx(e.xy);
> var lat = Math.round(latlon.lat);
> var lon = Math.round(latlon.lon);
> OpenLayers.Util.getElement("location").innerHTML = "The Latitude is " + lat
> + " and the Longitude is " + lon;
> });
> info = new OpenLayers.Control.WMSGetFeatureInfo({
> url : 'http://niles.iplantcollaborative.org:8080/geoserver/iPlant/wms',
> title : 'Identify features by clicking',
> queryVisible : true,
> eventListeners : {
> getfeatureinfo : function(event) {
> map.addPopup(new OpenLayers.Popup.FramedCloud("chicken",
> map.getLonLatFromPixel(event.xy), null, event.text, null, true));
> }
> }
> });
> map.addControl(info);
> info.activate();
>
> //map.setCenter(center, 9);
> map.zoomToMaxExtent();
> </script>
>                 <div id="location">
> Position
> </div>
> </body>
> </html>
>
> --
> Thanks & Regards
> Smaran Harihar
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list