'Display a filterable set of Projects on a Map
- assumes mode_3w
- currently assumes that theme_percentages=True
@ToDo: Browse by Year'

@staticmethod
def project_map(r, **attr):

    if ((r.representation == 'html') and (r.name == 'project')):
        T = current.T
        db = current.db
        s3db = current.s3db
        response = current.response
        ptable = s3db.project_project
        ttable = s3db.project_theme
        tptable = s3db.project_theme_project
        ltable = s3db.gis_location
        themes_dropdown = SELECT(_multiple=True, _id='project_theme_id', _style='height:80px')
        append = themes_dropdown.append
        table = current.s3db.project_theme
        themes = current.db((table.deleted == False)).select(table.id, table.name, orderby=table.name)
        for theme in themes:
            append(OPTION(theme.name, _value=theme.id, _selected='selected'))
        form = FORM(themes_dropdown)
        url = URL(f='location', extension='geojson')
        layer = {'name': T('Projects'), 'id': 'projects', 'tablename': 'project_location', 'url': url, 'active': True}
        map = current.gis.show_map(collapsed=True, feature_resources=[layer])
        output = dict(title=T('Projects    Map'), form=form, map=map)
        response.s3.scripts.append(URL(c='static', f='scripts', args=['S3', 's3.project_map.js']))
        response.view = 'map.html'
        return output
    else:
        raise HTTP(405, current.ERROR.BAD_METHOD)
