2012-03-28 14 views
1

実際に私はポップアップの例でGetFeatureInfoにこのコードを使用しています。今はポップアップのフィールドを制限したいと思います。フィールドを制限する方法、またはGetFeatureInfoリクエストで特定のフィールドを取得する方法は?

<html> 
    <head> 
    <title>GetFeatureInfo Popup</title> 
    <script src="ol/OpenLayers.js"></script> 
    <link rel="stylesheet" href="ol/theme/default/style.css" type="text/css" /> 
    <link rel="stylesheet" href="ol/examples/style.css" type="text/css" /> 
    <script> 
    OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url="; 
    /*Same as identifier*/ 
    var map, info; 

    function load() { 
     map = new OpenLayers.Map({ 
      div: "map", 
      maxExtent: new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573) 
     }); 

     var political = new OpenLayers.Layer.WMS("State Boundaries", 
      "http://localhost:8080/geoserver/wms", 
      {'layers': 'topp:tasmania_state_boundaries', transparent: true, format: 'image/gif'}, 
      {isBaseLayer: true} 
     ); 

     var roads = new OpenLayers.Layer.WMS("Roads", 
      "http://localhost:8080/geoserver/wms", 
      {'layers': 'topp:tasmania_roads', transparent: true, format: 'image/gif'}, 
      {isBaseLayer: false} 
     ); 

     var cities = new OpenLayers.Layer.WMS("Cities", 
      "http://localhost:8080/geoserver/wms", 
      {'layers': 'topp:tasmania_cities', transparent: true, format: 'image/gif'}, 
      {isBaseLayer: false} 
     ); 

     var water = new OpenLayers.Layer.WMS("Bodies of Water", 
      "http://localhost:8080/geoserver/wms", 
      {'layers': 'topp:tasmania_water_bodies', transparent: true, format: 'image/gif'}, 
      {isBaseLayer: false} 
     ); 



     map.addLayers([political, roads, cities, water]); 

     info = new OpenLayers.Control.WMSGetFeatureInfo({ 
      url: 'http://localhost:8080/geoserver/wms', 
      title: 'Identify features by clicking', 
      queryVisible: true, 
      eventListeners: { 
       getfeatureinfo: function(event) { 
        map.addPopup(new OpenLayers.Popup.FramedCloud(
         "chicken",  
         //document.getElementById('get').innerHTML = xmlResponse.attribute.state; 
         map.getLonLatFromPixel(event.xy), 
         null, 
         event.text, 
         null, 
         true 
        )); 
        xmlResponse = new OpenLayers.Format.XML().read(event.text); 
        document.getElementById('h').innerHTML = xmlResponse.attribute.STATE; 
       } 
      } 
     }); 
     map.addControl(info); 
     info.activate(); 

     map.addControl(new OpenLayers.Control.LayerSwitcher()); 
     map.zoomToMaxExtent(); 
    } 

    </script> 
    </head> 
    <body onload="load()"> 
     <h1 id="title">Feature Info in Popup</h1> 

     <div id="tags"></div> 

     <p id="shortdesc"> 
     Demonstrates the WMSGetFeatureInfo control for fetching information 
     about a position from WMS (via GetFeatureInfo request). Results 
     are displayed in a popup. 
     </p> 

     <div id="map" class="smallmap"></div> 
     <form> 
     <input type="lable" id="h"> 
     </form> 

    <div id="docs"></div> 
    </body> 
</html> 

ここでは、特定のフィールドのみを必要としたり、ポップアップ機能のフィールドを制限したりします。私はそれを初めて知っています。

答えて

関連する問題