summaryrefslogtreecommitdiff
path: root/ishtar_common/static/js
diff options
context:
space:
mode:
authorÉtienne Loks <etienne@peacefrogs.net>2019-02-06 19:08:42 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-04-24 19:38:56 +0200
commit7940a5e8379f822da0514e3f9068f9b3221331e3 (patch)
tree40856bb52074133833bb506a57118d11b96a0dfa /ishtar_common/static/js
parent251a3124d2c462620a5f6ecfff9160f853a113b0 (diff)
downloadIshtar-7940a5e8379f822da0514e3f9068f9b3221331e3.tar.bz2
Ishtar-7940a5e8379f822da0514e3f9068f9b3221331e3.zip
Sheet - Map: WIP - manage vector source for polygons
Diffstat (limited to 'ishtar_common/static/js')
-rw-r--r--ishtar_common/static/js/ishtar-map.js60
1 files changed, 52 insertions, 8 deletions
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js
index 226767914..ceef3a59e 100644
--- a/ishtar_common/static/js/ishtar-map.js
+++ b/ishtar_common/static/js/ishtar-map.js
@@ -52,6 +52,18 @@ var get_icon_style = function(feature){
});
};
+var get_vector_style = function(feature){
+ return new ol.style.Style({
+ stroke: new ol.style.Stroke({
+ color: 'red',
+ width: 2
+ }),
+ fill: new ol.style.Fill({
+ color: 'rgba(255,0,0,0.2)'
+ })
+ });
+};
+
var cluster_get_style = function(feature, resolution){
feature.set('key', 'cluster');
var cluster_features = feature.get('features');
@@ -356,6 +368,9 @@ var proj_options = {
var geojson_format = new ol.format.GeoJSON(proj_options);
var wkt_format = new ol.format.WKT(proj_options);
var link_template;
+var vector_source;
+var vector_layer;
+var vector_features;
var initialize_base_map = function(layers){
center = wkt_format.readGeometry(map_default_center).getCoordinates();
@@ -385,27 +400,56 @@ var redraw_map = function(layers){
};
-var display_map = function(current_map_id, points, layers){
- link_template = points['link_template'];
+var display_map = function(current_map_id, points, lines_and_polys, layers){
+ if (points){
+ link_template = points['link_template'];
+ } else {
+ /// link_template = lines_and_polys['link_template'];
+ }
map_id = current_map_id;
if (map){
redraw_map(layers);
} else {
initialize_base_map(layers);
}
- point_features = geojson_format.readFeatures(points);
+ display_points(points);
+ display_lines_and_polys(lines_and_polys);
- enable_clustering();
- cluster_source.getSource().addFeatures(point_features);
init_popup();
+ map.on('click', manage_click_on_map);
+ map.on('pointermove', manage_hover);
+};
+
+var display_points = function(points){
+ if (!points) return;
+ point_features = geojson_format.readFeatures(points);
+ enable_clustering();
+ cluster_source.getSource().addFeatures(point_features);
if (points.features.length){
map_view.fit(cluster_source.getSource().getExtent());
if (map_view.getZoom() > 12){
map_view.setZoom(12);
}
}
+};
- map.on('click', manage_click_on_map);
- map.on('pointermove', manage_hover);
-}
+var display_lines_and_polys = function(lines_and_polys){
+ if (!lines_and_polys) return;
+ vector_features = geojson_format.readFeatures(lines_and_polys);
+ vector_source = new ol.source.Vector();
+ vector_layer = new ol.layer.Vector({
+ source: vector_source,
+ style: get_vector_style
+ });
+ vector_source.addFeatures(vector_features);
+ vector_source.addFeature(new ol.Feature(
+ new ol.geom.Circle([6.079860710813087, 43.11452983279191], 2))) ;
+ map_layers.push(vector_layer);
+ if (lines_and_polys.features.length){
+ map_view.fit(vector_source.getExtent());
+ if (map_view.getZoom() > 12){
+ map_view.setZoom(12);
+ }
+ }
+};