Cameron Shorter wrote:
> 
> Hello Dario,
> I'm not sure why your code is not working in 1.5, but I have my
> suspicions.
> Most/all of the examples in 1.5 use OWSContext instead of WMC.
> WMC provides a list of WMS layers. OWSContext lists WFS, GML, Cached 
> WMS, Google Map layers as well. Unfortunately it has a slightly 
> different syntax, which means it is not backwardly compatible with WMC. 
> Our MapPaneOL widget should render both WMC and OWSContext files, but it 
> might not. (Note that the MapPane widget has been depreated - that might 
> also be your problem).
> 
> On another note,
> I'm interested to know what your end goal is. Adding filter 
> functionality to Mapbuilder is a highly requested feature. I'm 
> interested to know how you plan to achieve this (your design) and 
> whether you are able to return the code back into Mapbuilder.
> 
> Andreas may have more to say - he has been looking into Filters as well.
> 
> Of note, manipulating a WMC using a filter, or building a filter should 
> probably be in a widget or tool rather than in the Context.js. Our 
> design aim is to keep the model classes small so that other applications 
> which don't use Filter don't need to include the extra code.
> 
> Dario Zarro wrote:
>> hi,
>> I have developed a new function, initFilter, in Context.js. It's a simple
>> function to set wmc:Literal value, in wmc:Filter, with parameter passed
>> by
>> URL.  
>>
>> For example:
>>
>> --- WMC : tasmania.xml ----
>>
>> <Layer>
>> ....
>> <SLD>
>>     ...
>>        <Filter>
>>               ...
>>              <PropertyIsEqualTo>
>>                      <PropertyName>
>>                              TYPE
>>                        </PropertyName>
>>              <Literal id="type"></Literal>  // the id attribute determine url
>> parameter
>> name
>>              </PropertyIsEqualTo>
>>                  <PropertyIsEqualTo>
>>                      <PropertyName>
>>                              LENGTH
>>                        </PropertyName>
>>              <Literal id="length"></Literal>  // the id attribute determine 
>> url
>> parameter name
>>              </PropertyIsEqualTo>
>>              ...
>>        </Filter>
>>    ...
>> </SLD>
>> ...
>> </Layer>
>>
>> --------- end WMC ------
>> -------- Context.js ------
>> ...
>> //my function
>>  this.initFilter=function(objRef) {
>>     // Set wmc:Filter of context from URL CGI params
>>     
>>     if(window.cgiArgs["filter"]){
>>     var filter=window.cgiArgs["filter"].split(',');   
>>     
>>     var basicXpath='//wmc:[EMAIL PROTECTED]"value"]';
>>     var re="value";
>>     
>>     for(var i=0;i<filter.length;i++){
>>      var keyValue = filter[i].split(':');
>>      
>>      var currentXpath=basicXpath.replace(re,keyValue[0]);
>>      
>>      objRef.setXpathValue(objRef,currentXpath,keyValue[1],true);
>>     }
>>     
>>    }
>>      
>>   }
>>   this.addListener( "loadModel", this.initFilter, this );
>> ...
>> -------- end Context.js-----
>> In this example, I can change value at '<Literal id="type"></Literal>'
>> passing "../index.html?filter=type:newTypeValue,length:newLengthValue" in
>> URL.
>>
>> THE PROBLEM:
>> This function executes correctly in Mapbuilder 1.0.1 but it don't work in
>> Mapbuilder 1.5 .
>> Why?
>>
>>
>>   
> 
> 
> -- 
> 

Hello Cameron,
how I wrote in my last post, I want to load maps with filters that I pass
with CGI parameters. I have developed initFilter function (you can see my
last post) in Context.js to get from URL the filter parameter and set the
wmc:Filter before the map is painted. It work correctly in Mapbuilder 1.0.1
. I prefer to develop
 a new "MyContext" object  (with initFilter function),that inherites from
Context object, rather than to develop a new widget because the widget is
useful only after the map is painted. If an application don't use filter it
can use Context object, if it use filter it can use MyContext object. I have
an your widget, speciesList, that  provide an form to filter the map( I have
appended the code on bottom of this post). It's a good one but don't solves
my problem. 

Sorry if my english is bad, but i'm an italian student.

------ speciesList.xsl ------------
<?xml version="1.0" encoding="UTF-8" ?> 
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:gml="http://www.opengis.net/gml"; version="1.0">
- <!-- 
Description: Convert a GML Feature or FeatureCollection into a HTML form.
Author:      Cameron Shorter cameron ATshorter.net
Licence:     LGPL as per: http://www.gnu.org/copyleft/lesser.html
$Id: FeatureList.xsl 1717 2005-10-09 10:55:55Z camerons $
$Name$


  --> 
  <xsl:output method="xml" encoding="utf-8" /> 
- <!--  Common params for all widgets 
  --> 
- <!-- xsl:param name="targetModelId"/
  --> 
  <xsl:param name="modelId" /> 
  <xsl:param name="widgetId" /> 
- <!--  Main html 
  --> 
- <xsl:template match="/">
- <!-- xsl:variable name="propertyName" select="//wmc:PrpertyName"/
  --> 
- <form>
  Species: 
- <select id="{$widgetId}_species"
onchange="config.objects.{$widgetId}.setAttr(config.objects.{$widgetId},'//wmc:PropertyName',document.getElementById('{$widgetId}_species').value);">
  <option value="" /> 
  <option value="SUSSCR">SUSSCR</option> 
  <option value="CAPHIR">CAPHIR</option> 
  <option value="CERSPP">CERSPP</option> 
  </select>
  <br /> 
- <!-- 
      Value:
      <input
        type="text"
        id="{$widgetId}_value"
        value="4/2/3"
       
onchange="config.objects.{$widgetId}.setAttr(config.objects.{$widgetId},'//wmc:Literal',document.getElementById('{$widgetId}_value').value);"
       />
       

  --> 
  </form>
  <xsl:apply-templates /> 
  </xsl:template>
- <!--  Print out an option list with one option selected 
  --> 
- <!-- 
  <xsl:template name="optionList">
    <xsl:param name="selected"/>
    <xsl:if>
      <xsl:when test="compare($selected,$option)">
      </xsl:when>
      <xsl:otherwise>
        <option value="$option"></option>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  

  --> 
- <!--  Remove documentation, text, comments 
  --> 
  <xsl:template match="comment()|text()|processing-instruction()" /> 
  </xsl:stylesheet>
----------- end speciesList.xsl -------
----------- speciesList.js ------------
/*
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
$Id: FeatureList.js 1738 2005-10-16 19:15:14Z camerons $
*/

// Ensure this object's dependancies are loaded.
mapbuilder.loadScript(baseDir+"/widget/WidgetBase.js");

/**
 * Functions to select a weed species.
 * @constructor
 * @base WidgetBase
 * @author Cameron Shorter
 * @param objRef  The widget's XML object node from the configuration
document.
 * @param model       The model object that this widget belongs to.
 */
function SpeciesList(objRef, model) {
  WidgetBaseXSL.apply(this,new Array(objRef, model));

  /**
   * Set the value of an attribute from the SpeciesList.
   * @param objRef Reference to this object.
   * @param xpath Xpath reference to the attribute in the GML.
   * @param value New attribute value.
   */
  this.setAttr=function(objRef,xpath,value){
    objRef.model.setXpathValue(objRef.model,xpath,value);
  }
}
--------- end speciesList.js ----------------
-- 
View this message in context: 
http://www.nabble.com/new-Context-object-with-initFilter%28%29-function-to-initialize-filter-in-WMC-tp14716460p14737007.html
Sent from the MapBuilder Devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
mapbuilder-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-devel

Reply via email to