GWT-OpenLayers and OpenLayers.Format.WMSCapabilities -
i working google web toolkit wrapper openlayers. i'm attempting add wms layer map, need parse capabilities document in order available layer names. see wmscapabilities class available in openlayers http://dev.openlayers.org/releases/openlayers-2.12/doc/apidocs/files/openlayers/format/wmscapabilities-js.html, can't seem find implementation in gwt. feature not yet available, or hiding, undocumented somewhere? in advance!
i still don't know if gwt implementation available, it's rather easy wrap native javascript code in java. here solution:
import com.google.gwt.core.client.jsarraystring; native jsarraystring getlayernames(string capdoc) /*-{ var toreturn = []; var parser = new $wnd.openlayers.format.wmscapabilities(); var doc = parser.read(capdoc); (var in doc.capability["layers"]) { toreturn.push(doc.capability["layers"][i].name); } return toreturn; }-*/;
you can access them using:
jsarraystring layers = getlayernames(getmycapabilitiesdocumentasstring()); (int = 0; < layers.length(); i++) { window.alert("a layer name " + layers.get(i)); }
the variable doc
javascript array containing entire contents of capabilities document, it's possible access more layer names; pull out need. also, it's better create single parser rather create new 1 each time method called, that's different exercise ;)
Comments
Post a Comment