Project

General

Profile

API/WMJSService

Example 1: Do GetCapabilities on a WMS Service URL WMJSService.getCapabilities

    $( document ).ready(function() {
      var serviceURL = 'http://geoservices.knmi.nl/cgi-bin/RADNL_OPER_R___25PCPRR_L3.cgi?';

      var service = WMJSgetServiceFromStore(serviceURL);

      var failed = function(msg){
        alert(msg);
      };

      var success = function(capabilitiesDoc){
        console.log("GetCapabilities obtained");
        console.log(capabilitiesDoc);
      };

      service.getCapabilities(success,failed);
    });

Example 2: Get all layernames in a service: WMJSService.getLayerNames

    $( document ).ready(function() {
      var serviceURL = 'http://geoservices.knmi.nl/cgi-bin/RADNL_OPER_R___25PCPRR_L3.cgi?';

      var service = WMJSgetServiceFromStore(serviceURL);

      var failed = function(msg){
        alert(msg);
      };

      var success = function(layerNames){
        console.log("layerNames obtained");
        console.log(layerNames);
      };

      service.getLayerNames(success,failed);
    });

Example 3: Parse the first layer in a service and show all its metadata

    $( document ).ready(function() {
      var serviceURL = 'http://geoservices.knmi.nl/cgi-bin/RADNL_OPER_R___25PCPRR_L3.cgi?';

      var service = WMJSgetServiceFromStore(serviceURL);

      var failed = function(msg){
        alert(msg);
      };

      var showLayerInfo = function(layer){

        var html="<table border=1>";
        html+="<tr><td>service</td><td>"+layer.service+"</td></tr>";
        html+="<tr><td>name</td><td>"+layer.name+"</td></tr>";
        html+="<tr><td>title</td><td>"+layer.title+"</td></tr>";
        html+="<tr><td>abstract</td><td>"+layer.abstract+"</td></tr>";

        //Styles
        html+="<tr><td>styles</td><td><ul>";
        for(var j=0;j<layer.styles.length;j++){
          html+="<li>"+layer.styles[j].name+"</li>";
        }
        html+="</ul></td></tr>";

        //Projections
        html+="<tr><td>projections</td><td><ol>";
        for(var j=0;j<layer.projectionProperties.length;j++){
          html+="<li>"+layer.projectionProperties[j].srs;
          html+="<ul><li>bbox: "+layer.projectionProperties[j].bbox.toString()+"</li></ul>";
          html+="</li>";
        }
        html+="</ol></td></tr>";

        //Dimensions
        html+="<tr><td>dimensions</td><td><ol>";
        for(var j=0;j<layer.dimensions.length;j++){
          html+="<li>"+layer.dimensions[j].name;
          html+="<ul><li>values: "+layer.dimensions[j].values+"</li></ul>";
          html+="<ul><li>units: "+layer.dimensions[j].units+"</li></ul>";
          html+="</li>";
        }
        html+="</ol></td></tr>";

        html+="</table>";

        $('#layerproperties').html(html);
      };

      var success = function(layerNames){
        console.log("layerNames obtained");
        console.log(layerNames);

        var layer = new WMJSLayer({service:serviceURL,name:layerNames[0],onReady:showLayerInfo});
      };

      service.getLayerNames(success,failed);
    });

Example 4: Get the first couple of available dates for a layer


    $( document ).ready(function() {
      var serviceURL = 'http://geoservices.knmi.nl/cgi-bin/RADNL_OPER_R___25PCPRR_L3.cgi?';

      var service = WMJSgetServiceFromStore(serviceURL);

      var failed = function(msg){
        alert(msg);
      };

      var showLayerInfo = function(layer){

        var dim = layer.dimensions[0]; // Use the first dimension 
        console.log(dim);
        var html="Available dates for "+dim.name+" with units "+dim.units+" and values "+dim.values+"<br/>First 100 dates of total "+dim.size()+" dates:<br/>";
        for(var j=0;j<100&&j<dim.size();j++){
          html+=dim.getValueForIndex(j)+"</br>";
        };

        $('#layerproperties').html(html);
      };

      var success = function(layerNames){
        console.log("layerNames obtained");
        console.log(layerNames);

        var layer = new WMJSLayer({service:serviceURL,name:layerNames[0],onReady:showLayerInfo});
      };

      service.getLayerNames(success,failed);
    });

Configuration

  • Use the global method WMJSgetServiceFromStore(serviceUrl) to create or get a service object for an URL.

Properties

  • service
  • title
  • getcapabilitiesDoc

Methods

  • getCapabilities(successCallback, failedCallback,forceReload) - Does getcapabilities for this service. Uses callback functions to indicate whether success or failure has happened.
  • getNodes(successCallback, failedCallback,forceReload) - Returns all layernames in a hierarchical way, the returned objects are nested by using the children property. A node has the following properties: name, text, leaf and children. The returned object can directly be used in an ExtJS4 tree component.
  • getLayerNames(successCallback, failedCallback) - Returns an array with all layernames.