summaryrefslogtreecommitdiff
path: root/chimere/templates/search/search_js.html
blob: 2d545b4d30a260675cb0a0f5772c86fe18f3ef93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<script type='text/javascript'>
$(function(){
    // clean checked categories
    $('.subcategory').each(function(){ $(this).removeClass('selected'); });
    $('.subcategory input[type=checkbox]').attr('checked', false);

    var geo_objects = [];
    {% if results %}
    var c_lst ={{results|safe}};
    for (idx in c_lst){
        geo_objects.push(c_lst[idx]);
    }{% endif %}
    var geo_features = {};
    for (idx_obj=0 ; idx_obj < geo_objects.length ; idx_obj++){
        var c_idx_obj = geo_objects[idx_obj].properties.pk;

        if (search_result.indexOf(c_idx_obj) == -1){
            search_result.push(c_idx_obj);
            var geom_type = geo_objects[idx_obj].geometry.type;
            if (geom_type == 'Point'){
                action = 'addMarker';
            } else if (geom_type == 'LineString'){
                action = 'addRoute';
            } else if (geom_type == 'Polygon' || geom_type == 'MultiPolygon'){
                action = 'addPolygon';
            } else {
                continue
            }
            geo_features[c_idx_obj] = $('#main-map').chimere(action,
                                                         geo_objects[idx_obj]);
        }
    }
    if (geo_objects.length){
        window.setTimeout(function(){$("#main-map").chimere("zoomToMarkerExtent")}, 500);
    }
});
</script>