[ka-Map-users] Changing map layer dinamically
Damiano Morosi
damiano.morosi at atac.roma.it
Fri Nov 24 07:18:16 EST 2006
Yes, I'm trying to do a quite similar thing changing the DATA instead of
FILTER. I'll give a try now, maybe I'm missing the redraw(). Stay tuned!
Pje ha scritto:
> 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:
>
> map
> ...
> layer
> name "airports"
> connectiontype POSTGIS
> connection "xxxxxx"
> data "geom from foo"
> ...
> metadata
> tile_source "nocache"
> end
> filter "name IN (%name%)"
> ...
> end
> end
>
> So, when the user click on a checkbox (airport A) and choose to refresh
> the map I call a function that looks like:
>
> function refreshMap() {
> var map = myKaMap.getCurrentMap();
> var airports = map.getLayer('airports');
>
> airports.replacementVariables = {name: airportName}; //airportName
> contains the name of airport checked by the user
>
> airports.redraw();
> }
>
> Is that you are trying to do?
>
> On 11/24/06, *Damiano Morosi* <damiano.morosi at atac.roma.it
> <mailto:damiano.morosi at atac.roma.it>> wrote:
>
> Your idea is very interesting. I tried to do as you said, putting all
> the things in my mapfile, i.e., "tile-source" "nocache" in metadata and
> putting CONNECTION "%conn%" to make a test.
> After this, in my js:
>
> layers = myKaMap.getCurrentMap().getAllLayers();
> for(var i=0; i < layers.length; i++) {
> layers[i].replacementVariables = {conn: 'test.ovf'};
> }
>
> It seems logic, but it doesn't work as I try to load the map. This piece
> of code is called inside the myMapInitialized function: is it right?
>
> Thanks,
>
> Damiano
>
> Pje ha scritto:
> > You can do that using mapfile variables and setting you layer metadata
> > to tile_source "nocache". So, when you click on a link, you send the
> > parameter to your mapfile and refresh your layer.
> >
> > To specify values for variable replacement on the client side, add a
> > replacementVariables object to your JavaScript _layer object (e.g.
> > myLayer.replacementVariables = {key1: 'value1', key2: 'value2'}).
> > Variable replacement currently works for layer->data,
> layer->connection,
> > layer->filter, and for class->expression.
> >
> > You can see how it works here:
> > http://mapserver.gis.umn.edu/docs/reference/mapfile/variable_sub
> > < http://mapserver.gis.umn.edu/docs/reference/mapfile/variable_sub>
> >
> > On 11/23/06, *Damiano Morosi* <damiano.morosi at atac.roma.it
> <mailto:damiano.morosi at atac.roma.it>
> > <mailto: damiano.morosi at atac.roma.it
> <mailto:damiano.morosi at atac.roma.it>>> wrote:
> >
> > Hi,
> >
> > I would like to change the layer in my kaMap by clicking on a
> link or
> > selecting a voice in a combobox.
> > Is there some javascript API to do such thing without too much
> reverse
> > engineering of ka-map?
> > Thanks,
> >
> > Damiano
> > _______________________________________________
> > ka-Map-users mailing list
> > ka-Map-users at lists.maptools.org
> <mailto:ka-Map-users at lists.maptools.org>
> <mailto:ka-Map-users at lists.maptools.org
> <mailto:ka-Map-users at lists.maptools.org>>
> > http://lists.maptools.org/mailman/listinfo/ka-map-users
> <http://lists.maptools.org/mailman/listinfo/ka-map-users>
> >
> >
> >
> >
> ------------------------------------------------------------------------
> >
> > _______________________________________________
> > ka-Map-users mailing list
> > ka-Map-users at lists.maptools.org
> <mailto:ka-Map-users at lists.maptools.org>
> > http://lists.maptools.org/mailman/listinfo/ka-map-users
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
More information about the ka-Map-users
mailing list