1

Re: Distribution Map for Single Species

Hello,
we are wondering if its possible to build a distribution map with the possibility to select a species for showing its distribution. now, we get the data entries for all the species for each user.
in the distribution map are fields for the taxon identifier, but we got at least 2000 different species.

thanks for suggestions,

gaby

2

Re: Distribution Map for Single Species

Hi Gaby
Sure, this is something I would like to add to the distribution map form, at least as an option. For now you could add an autocomplete input above the map (using the data_entry_helper class) to let the user pick a species. Then add a button which sends this value back to the form (using a GET rather than POST). The name of the input would need to be set to taxon so that the distribution map code can detect it and filter the map. You will also need to untick the Show All Species checkbox on the form configuration.
Best Wishe

John van Breda
Biodiverse IT

3

Re: Distribution Map for Single Species

Hi,
we got some help on this one - a javascript wizard scripted a species selector for us!
The Code in distribution_map_1.php looks like this now, starting in row 134:

// setup the map options
    $options = iform_map_get_map_options($args, $readAuth);
    $olOptions = iform_map_get_ol_options($args);
    if (!$args['show_all_species']) {

inserted here: !isset($_GET['taxon']) &&

      if (!isset($_GET['taxon']) && isset($args['taxon_identifier']) && !empty($args['taxon_identifier']))
        // This page is for a predefined species map
        $taxonIdentifier = $args['taxon_identifier'];
      else {
        if (isset($_GET['taxon']))
        $taxonIdentifier = $_GET['taxon'];
        else
        return lang::get("The distribution map cannot be displayed without a taxon identifier");
      }

followed by:

// select box for taxons
    $fetchOpts = array(
        'table' => 'occurrence',
            'extraParams' => $readAuth + array('view'=>'detail','deleted'=>'f'),
        'nocache' => true,
        'fieldname' => 'taxon',
        'id' => 'select_taxon',
        'captionField' => 'taxon',
        'valueField' => 'taxon_meaning_id',
        'default' => $taxonIdentifier
    );
    $r .= data_entry_helper::select($fetchOpts);
    $r .= <<<EOT
    <script type='text/javascript'>
        $('#select_taxon').change(function() {
            var selectedTaxonId = $(this).val();

            var re = new RegExp('(?:&|\\\\?)taxon=([^&]*)');
            var result = location.search.match(re);
            if (result == null) {
            location.search += '&taxon=' + selectedTaxonId;
            }
            else {
            var newTaxonParam = result[0].replace(result[1], selectedTaxonId);
            location.search = location.search.replace(result[0], newTaxonParam);
            }
        });
    </script>
EOT;