diff options
Diffstat (limited to 'ishtar_common/static/js')
| -rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 62 | 
1 files changed, 43 insertions, 19 deletions
| diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index a0709c059..ae591db08 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -14,6 +14,18 @@ var base_color_V = 66;  var base_color_B = 193;  var base_color_rvb; +var base_colors = [ +    "rgba(230,0,73, 1)", +    "rgba(11,180,255, 1)", +    "rgba(80,233,145, 1)", +    "rgba(230,216,0, 1)", +    "rgba(155,25,245, 1)", +    "rgba(255,163,0, 1)", +    "rgba(220,10,180, 1)", +    "rgba(179,212,255, 1)", +    "rgba(0,191,160, 1)" +]; +  var map_default_center = 'SRID=4326;POINT (2.4397 46.5528)';  var map_default_zoom = '7';  var min_auto_zoom_on_cluster = 13; @@ -263,16 +275,24 @@ var get_icon_style = function(feature){      });  }; +var get_random_int = function(max) { +    return Math.floor(Math.random() * max); +} + +var _vector_style_cache = {}; +var tmp; + +  var get_vector_style = function(feature){ -    return new ol.style.Style({ -        stroke: new ol.style.Stroke({ -            color: 'rgba(' + base_color_rvb + ', 1)', -            width: 2 -        }), -        fill: new ol.style.Fill({ -            color: 'rgba(' + base_color_rvb + ', 0.2)' -        }) -    }); +    let feature_id = feature.getProperties()["id"] +    if (!(feature_id in _vector_style_cache)){ +        _vector_style_cache[feature_id] = new ol.style.Style({ +            stroke: new ol.style.Stroke({ +            color: base_colors[get_random_int(base_colors.length)], +            width: 2}) +        }); +    } +    return _vector_style_cache[feature_id];  };  var cluster_get_style = function(feature, resolution){ @@ -944,22 +964,26 @@ const refresh_map_finds_crs = function(url, attrs, idx, crs_check, find_check) {              if (data) {                  if (data["context-records"] && data["context-records"]["features"]) {                      for (let feat of data["context-records"]["features"]){ -                        if (feat["geometry"]["type"] === 'Point' || -                            feat["geometry"]["type"] === 'MultiPoint'){ -                            _point_list_crs[idx].push(feat); -                        } else { -                            _other_list_crs[idx].push(feat); +                        if (feat["geometry"]){ +                            if (feat["geometry"]["type"] === 'Point' || +                                feat["geometry"]["type"] === 'MultiPoint'){ +                                _point_list_crs[idx].push(feat); +                            } else { +                                _other_list_crs[idx].push(feat); +                            }                          }                      }                      if (crs_check) _refresh_map_crs(idx);                  }                  if (data["finds"] && data["finds"]["features"]) {                      for (let feat of data["finds"]["features"]){ -                        if (feat["geometry"]["type"] === 'Point' || -                            feat["geometry"]["type"] === 'MultiPoint'){ -                            _point_list_finds[idx].push(feat); -                        } else { -                            _other_list_finds[idx].push(feat); +                        if (feat["geometry"]){ +                            if (feat["geometry"]["type"] === 'Point' || +                                feat["geometry"]["type"] === 'MultiPoint'){ +                                _point_list_finds[idx].push(feat); +                            } else { +                                _other_list_finds[idx].push(feat); +                            }                          }                      }                      if (finds_check) _refresh_map_finds(idx); | 
