js-src/aggregate.jsm
/**
 * Given a GeoJSON object, introspect it to find the property fields and set up the menus 
 * so that users can specify name and ID fields.
 * @param geojson
 */
Given a GeoJSON object, introspect it to find the property fields and set up the menus
so that users can specify name and ID fields.
@param geojson
Given a GeoJSON object introspect it to find the property fields and set up the menus so that users can specify name and ID fields . @param geojson
function updateDetailsForm(geojson) {
    let options = []
    if (geojson.features && geojson.features.length > 0) {
        let p = geojson.features[0].properties;
        options.push(['', ' -- none -- '])
        Object.keys(p).forEach(k => options.push([k, k]))
    } else {
        options.push(['', 'No fields found'])
    }
    let name_field = document.querySelector('select#name_field')
    while (name_field.hasChildNodes()) name_field.firstChild.remove()
    let id_field = document.querySelector('select#id_field')
    while (id_field.hasChildNodes()) id_field.firstChild.remove()
    options.forEach(pair => {
        [name_field, id_field].forEach(f => {
            let opt = document.createElement('option')
            opt.value = pair[0]
            opt.label = pair[1]
            f.appendChild(opt)
        })
    })
    showDetailsForm()
}
function updateDetailsForm ( geojson ) { let options = [ ] if ( geojson . features && geojson . features . length > 0 ) { let p = geojson . features [ 0 ] . properties ; options . push ( [ '' , ' -- none -- ' ] ) Object . keys ( p ) . forEach ( k => options . push ( [ k , k ] ) ) } else { options . push ( [ '' , 'No fields found' ] ) } let name_field = document . querySelector ( 'select#name_field' ) while ( name_field . hasChildNodes ( ) ) name_field . firstChild . remove ( ) let id_field = document . querySelector ( 'select#id_field' ) while ( id_field . hasChildNodes ( ) ) id_field . firstChild . remove ( ) options . forEach ( pair => { [ name_field , id_field ] . forEach ( f => { let opt = document . createElement ( 'option' ) opt . value = pair [ 0 ] opt . label = pair [ 1 ] f . appendChild ( opt ) } ) } ) showDetailsForm ( ) }
Given a GeoJSON object, introspect it to find the property fields and set up the menus
 so that users can specify name and ID fields.
Given a GeoJSON object introspect it to find the property fields and set up the menus so that users can specify name and ID fields .