unable to get simultaneous display of shapefile layers

11 views
Skip to first unread message

chardi...@gmail.com

unread,
Jun 4, 2019, 1:39:00 PM6/4/19
to Tethys Platform
I am new to tethys and much of the associated software.  The Tethys Tutorials have been very helpful.  In an attempt to develop a viewing app to see mutiple shapefile layers of the east Texas area simultaneously, I first worked through the "Spatial Dataservices and Geoserver Tutorial".  Then I scaffolded a new app I named "Mitigation Network" (migitage_app), copied script files from the Tutorial, modified them as best I could judge, and was able to get two shapefiles (both of the east Texas area) to display on the same background global map that is used in the Tutorial.  But I cannot seem to get both shapefiles to display simultaneously.  In the controllers.py file, in the select_options under def map(request), I modified multiple = False to multiple = True, i.e., I have

select_options = SelectInput(
    display_text = 'Choose Layer',
    name = 'layer'
    multiple = True,
    options = options
   )

The rest of controllers.py is the same as in the tutorial, except for modifying the name of the app.

This change allows me to select multiple layers on the GeoServer Layers page of the app, simultaneously, including the two from east Texas.  But when I click Update only one appears.  And if I select one layer at a time, and Update, the earlier layer will disappear and be replaced by the most recent one.

I explored the network of files, and also tracked the SelectInput function to what appears to me to be its origin, but any changes I make don't work. 

Does anyone have any advice on the kind of documentation that I should read to get help?  And of course no objection if anyone can tell me what file(s) I need to modify and how.

Brown, Dustin T ERDC-RDE-CHL-MS CIV

unread,
Jun 4, 2019, 1:55:52 PM6/4/19
to chardi...@gmail.com, Tethys Platform

Hi there,

 

If I understand what tutorial you’re looking at, you’ll have to change request.POST[‘layer’] to something like request.POST.getlist(‘layer’) or request.POST.getlist(‘layer[]’).  This will return a list of the values instead of just one value.  You’d also have to iterate through that list and make a MVLayer object for each being added. 

 

i.e. something like:

 

if request.POST and 'layer' in request.POST:

        selected_layers = request.POST.getlist('layer')

        for layer in selected_layers:

            legend_title = layer.title()

 

            geoserver_layer = MVLayer(

            source='ImageWMS',

            options={

                'url': 'http://localhost:8181/geoserver/wms',

                'params': {'LAYERS': layer},

                'serverType': 'geoserver'

            },

            legend_title=legend_title,

            legend_extent=[-114, 36.5, -109, 42.5],

            legend_classes=[

                MVLegendClass('polygon', 'County', fill='#999999'),

        ])

 

            map_layers.append(geoserver_layer)

 

 

Thanks,

Dustin Brown

--
You received this message because you are subscribed to the Google Groups "Tethys Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tethysplatfor...@googlegroups.com.
To view this discussion on the web visit Blockedhttps://groups.google.com/d/msgid/tethysplatform/2d62cbca-3a72-4cbf-88de-36a124f9479f%40googlegroups.comBlocked.
For more options, visit Blockedhttps://groups.google.com/d/optoutBlocked.

chardi...@gmail.com

unread,
Jun 4, 2019, 10:51:40 PM6/4/19
to Tethys Platform
Dustin Brown, that worked beautifully.  Thank you so much!
Reply all
Reply to author
Forward
0 new messages