I don't know what you are trying to do. I'm using variable substitution here to filter data of a layer based on a parameter sent by the user. For example, if i have a layer of airports, the user can choose to view only the airports A and B. So, my mapfile looks like:
<br><br>map<br> ...<br> layer<br> name "airports"<br> connectiontype POSTGIS<br> connection "xxxxxx"<br> data "geom from foo"<br> ...<br> metadata
<br> tile_source "nocache"<br> end<br> filter "name IN (%name%)"<br> ...<br> end<br>end<br><br>So, when the user click on a checkbox (airport A) and choose to refresh the map I call a function that looks like:
<br><br>function refreshMap() {<br> var map = myKaMap.getCurrentMap();<br> var airports = map.getLayer('airports'); <br><br> airports.replacementVariables = {name: airportName}; //airportName contains the name of airport checked by the user
<br><br> airports.redraw();<br>}<br><br>Is that you are trying to do?<br><br><div><span class="gmail_quote">On 11/24/06, <b class="gmail_sendername">Damiano Morosi</b> <<a href="mailto:damiano.morosi@atac.roma.it">damiano.morosi@atac.roma.it
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Your idea is very interesting. I tried to do as you said, putting all<br>
the things in my mapfile, i.e., "tile-source" "nocache" in metadata and<br>putting CONNECTION "%conn%" to make a test.<br>After this, in my js:<br><br>layers = myKaMap.getCurrentMap().getAllLayers();
<br>for(var i=0; i < layers.length; i++) {<br> layers[i].replacementVariables = {conn: 'test.ovf'};<br>}<br><br>It seems logic, but it doesn't work as I try to load the map. This piece<br>of code is called inside the myMapInitialized function: is it right?
<br><br>Thanks,<br><br>Damiano<br><br>Pje ha scritto:<br>> You can do that using mapfile variables and setting you layer metadata<br>> to tile_source "nocache". So, when you click on a link, you send the<br>
> parameter to your mapfile and refresh your layer.<br>><br>> To specify values for variable replacement on the client side, add a<br>> replacementVariables object to your JavaScript _layer object (e.g.<br>>
myLayer.replacementVariables = {key1: 'value1', key2: 'value2'}).<br>> Variable replacement currently works for layer->data, layer->connection,<br>> layer->filter, and for class->expression.<br>><br>> You can see how it works here:
<br>> <a href="http://mapserver.gis.umn.edu/docs/reference/mapfile/variable_sub">http://mapserver.gis.umn.edu/docs/reference/mapfile/variable_sub</a><br>> <<a href="http://mapserver.gis.umn.edu/docs/reference/mapfile/variable_sub">
http://mapserver.gis.umn.edu/docs/reference/mapfile/variable_sub</a>><br>><br>> On 11/23/06, *Damiano Morosi* <<a href="mailto:damiano.morosi@atac.roma.it">damiano.morosi@atac.roma.it</a><br>> <mailto:<a href="mailto:damiano.morosi@atac.roma.it">
damiano.morosi@atac.roma.it</a>>> wrote:<br>><br>> Hi,<br>><br>> I would like to change the layer in my kaMap by clicking on a link or<br>> selecting a voice in a combobox.<br>> Is there some javascript API to do such thing without too much reverse
<br>> engineering of ka-map?<br>> Thanks,<br>><br>> Damiano<br>> _______________________________________________<br>> ka-Map-users mailing list<br>> <a href="mailto:ka-Map-users@lists.maptools.org">
ka-Map-users@lists.maptools.org</a> <mailto:<a href="mailto:ka-Map-users@lists.maptools.org">ka-Map-users@lists.maptools.org</a>><br>> <a href="http://lists.maptools.org/mailman/listinfo/ka-map-users">http://lists.maptools.org/mailman/listinfo/ka-map-users
</a><br>><br>><br>><br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> ka-Map-users mailing list<br>> <a href="mailto:ka-Map-users@lists.maptools.org">
ka-Map-users@lists.maptools.org</a><br>> <a href="http://lists.maptools.org/mailman/listinfo/ka-map-users">http://lists.maptools.org/mailman/listinfo/ka-map-users</a><br></blockquote></div><br>