[OpenLayers-Users] GetFeatureInfo- HTML Template with JS

Greg Allensworth gregor at greeninfo.org
Mon Aug 27 08:22:59 PDT 2012


On 8/26/2012 2:51 PM, Phil Scadden wrote:
> I'd consider getting the response in GML and formatting with js in your
> application. You can build in a lot more flexibility.

+1 on that.

If you don't want to go all the way with GML, at least a trivial XML format:

<feature class="[category]" name="[name]" address="[street] [city]" />

And you would parse it in your GetFeatureInfo's 
eventListeners.getfeatureinfo If you're using jQuery then parsuing the 
HTML/XML is dead simple:

clicker = new OpenLayers.Control.WMSGetFeatureInfo({
    eventListeners: {
       getfeatureinfo: function (reply) {
          var xml = $(reply);
          reply.find('feature').each(function () {
             console.log(  $(this).attr('name)  );
          });
     }
  }
});
MAP.addControl(clicker);

-- 
Greg Allensworth, Web GIS Developer
BS  A+  Network+  Security+  Linux+  Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510  San Francisco CA 94104
PH: 415-979-0343 x302  FX: 415-979-0371    email: gregor at greeninfo.org
Web: www.GreenInfo.org     www.MapsPortal.org

Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org


More information about the Users mailing list