Esempio n. 1
0
def getPopups(layer, safeLayerName, highlight, popupsOnHover, popup, vts,
              feedback):
    if vts is not None:
        return "", ""
    fields = layer.fields()
    field_names = popup.keys()
    field_vals = popup.values()
    table = ""
    for field in popup:
        tablestart = "'<table>\\"
        row = ""
        for field, val in zip(field_names, field_vals):
            fieldIndex = fields.indexFromName(str(field))
            editorWidget = layer.editorWidgetSetup(fieldIndex).type()
            displayName = layer.attributeDisplayName(fieldIndex).replace(
                "'", "\\'")
            if (editorWidget == 'Hidden'):
                continue

            row += """
                    <tr>\\"""
            if val == 'inline label':
                row += """
                        <th scope="row">"""
                row += displayName
                row += """</th>\\
                        <td>"""
            else:
                row += """
                        <td colspan="2">"""
            if val == "header label":
                row += '<strong>'
                row += displayName
                row += '</strong><br />'
            row += "' + "
            row += "(feature.properties[\'" + str(field) + "\'] "
            row += "!== null ? "

            if (editorWidget == 'ExternalResource'):
                row += "'<img src=\"images/' + "
                row += "String(feature.properties['" + str(field)
                row += r"']).replace(/[\\\/:]/g, '_').trim()"
                row += " + '\">' : '') + '"
            else:
                row += "Autolinker.link("
                row += "feature.properties['" + str(field)
                row += "'].toLocaleString(), {truncate: {length: 30, "
                row += "location: 'smart'}}) : '') + '"

            row += """</td>\\
                    </tr>\\"""
        tableend = """
                </table>'"""
        table = tablestart + row + tableend
    if popup != 0 and table != "":
        popFuncs = popFuncsScript(table)
    else:
        popFuncs = ""
    new_pop = popupScript(safeLayerName, popFuncs, highlight, popupsOnHover)
    return new_pop, popFuncs
def getPopups(layer, safeLayerName, highlight, popupsOnHover, popup, vts):
    if vts is not None:
        return "", ""
    fields = layer.fields()
    field_names = popup.keys()
    field_vals = popup.values()
    html_prov = False
    table = ""
    for field in popup:
        tablestart = "'<table>\\"
        row = ""
        for field, val in zip(field_names, field_vals):
            fieldIndex = fields.indexFromName(unicode(field))
            editorWidget = layer.editorWidgetSetup(fieldIndex).type()

            if (editorWidget == 'Hidden'):
                continue

            row += """
                    <tr>\\"""
            if val == 'inline label':
                row += """
                        <th scope="row">"""
                row += layer.attributeDisplayName(fieldIndex)
                row += """</th>\\
                        <td>"""
            else:
                row += """
                        <td colspan="2">"""
            if val == "header label":
                row += '<strong>'
                row += layer.attributeDisplayName(fieldIndex)
                row += '</strong><br />'
            row += "' + "
            row += "(feature.properties[\'" + unicode(field) + "\'] "
            row += "!== null ? "

            if (editorWidget == 'Photo'):
                row += "'<img src=\"images/' + "
                row += "String(feature.properties['" + unicode(field)
                row += r"']).replace(/[\\\/:]/g, '_').trim()"
                row += " + '\">' : '') + '"
            else:
                row += "Autolinker.link("
                row += "String(feature.properties['" + unicode(field)
                row += "'])) : '') + '"

            row += """</td>\\
                    </tr>\\"""
        tableend = """
                </table>'"""
        table = tablestart + row + tableend
    if popup != 0 and table != "":
        popFuncs = popFuncsScript(table)
    else:
        popFuncs = ""
    new_pop = popupScript(safeLayerName, popFuncs, highlight, popupsOnHover)
    return new_pop, popFuncs
Esempio n. 3
0
def getPopups(layer, safeLayerName, highlight, popupsOnHover, popup, vts):
    if vts is not None:
        return "", ""
    fields = layer.fields()
    field_names = popup.keys()
    field_vals = popup.values()
    html_prov = False
    table = ""
    for field in popup:
        tablestart = "'<table>\\"
        row = ""
        for field, val in zip(field_names, field_vals):
            fieldIndex = fields.indexFromName(unicode(field))
            editorWidget = layer.editorWidgetSetup(fieldIndex).type()

            if (editorWidget == 'Hidden'):
                continue

            row += """
                    <tr>\\"""
            if val == 'inline label':
                row += """
                        <th scope="row">"""
                row += layer.attributeDisplayName(fieldIndex)
                row += """</th>\\
                        <td>"""
            else:
                row += """
                        <td colspan="2">"""
            if val == "header label":
                row += '<strong>'
                row += layer.attributeDisplayName(fieldIndex)
                row += '</strong><br />'
            row += "' + "
            row += "(feature.properties[\'" + unicode(field) + "\'] "
            row += "!== null ? "

            if (editorWidget == 'Photo'):
                row += "'<img src=\"images/' + "
                row += "String(feature.properties['" + unicode(field)
                row += "']).replace(/[\\\/:]/g, '_').trim()"
                row += " + '\">' : '') + '"
            else:
                row += "Autolinker.link("
                row += "String(feature.properties['" + unicode(field)
                row += "'])) : '') + '"

            row += """</td>\\
                    </tr>\\"""
        tableend = """
                </table>'"""
        table = tablestart + row + tableend
    if popup != 0 and table != "":
        popFuncs = popFuncsScript(table)
    else:
        popFuncs = ""
    new_pop = popupScript(safeLayerName, popFuncs, highlight, popupsOnHover)
    return new_pop, popFuncs