From f8d3c8804ecc917da5478dbfbae52f393e2f58e3 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Mon, 10 Apr 2017 17:46:32 +0200 Subject: [PATCH 1/2] Gis Maps Feature: When scrolling in map, change font-size of labels. --- .../include/javascript/openlayers.pandora.js | 48 ++++++++++++++++++- .../operation/gis_maps/public_console.php | 2 +- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/javascript/openlayers.pandora.js b/pandora_console/include/javascript/openlayers.pandora.js index 943da65c7a..56874514e4 100755 --- a/pandora_console/include/javascript/openlayers.pandora.js +++ b/pandora_console/include/javascript/openlayers.pandora.js @@ -134,9 +134,11 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)}; map = new OpenLayers.Map(id_div, option); - + map.events.Event var baseLayer = null; + map.events.on({"zoomend": EventZoomEnd}); + //Define the maps layer for (var baselayerIndex in objBaseLayers) { if (isInt(baselayerIndex)) { @@ -224,6 +226,50 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob map.setCenter (lonLat, initial_zoom); } +function EventZoomEnd (evt) { + var actual_zoom = (evt.object.zoom < 6) ? 6 : evt.object.zoom; + var max_width_marker = 38; + var max_zoom_map = map.numZoomLevels; + var max_font_size = 15; + + var actual_font_size = (actual_zoom * max_font_size) / max_zoom_map; + + jQuery.each($("tspan"), function (i, tspan) { + if (actual_zoom <= 18 && actual_zoom > 13) + actual_font_size = (max_font_size - 3); + else if (actual_zoom <= 13 && actual_zoom >= 8) + actual_font_size = (max_font_size - 6); + else if (actual_zoom <= 8) + actual_font_size = (max_font_size - 6); + $(tspan).css('font-size', actual_font_size); + }); + + var layers = map.getLayersByClass("OpenLayers.Layer.Vector"); + + + jQuery.each(layers, function (i, layer) { + var features = layer.features; + + jQuery.each(features, function (j, feature) { + var graphicHeight = feature.style.graphicHeight || -1; + var graphicWidth = feature.style.graphicWidth || -1; + + if (graphicHeight > 0 && graphicWidth > 0) { + var new_width_marker = (actual_zoom * max_width_marker) / max_zoom_map; + var new_height_marker = (actual_zoom * max_width_marker) / max_zoom_map; + + console.log(feature); + feature.style.fontSize = '' + actual_font_size + ' !important'; + feature.style.graphicHeight = new_height_marker; + feature.style.graphicWidth = new_width_marker; + feature.style.labelYOffset = (new_width_marker * -1); + } + + }); + layer.redraw(); + }); +} + /** * Change the style of state button, and call the function "hideAgentsStatus" * whith new state for agents icons to show. diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 01a3af722a..7a517f65b5 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -14,7 +14,7 @@ // Real start -require_once ("../../include/config.php"); +include_once ("../../include/config.php"); // Set root on homedir, as defined in setup chdir ($config["homedir"]); From c316462802181a00c468ecdab84a674c6490f63e Mon Sep 17 00:00:00 2001 From: mlopez Date: Mon, 10 Apr 2017 17:53:01 +0200 Subject: [PATCH 2/2] Update public_console.php --- pandora_console/operation/gis_maps/public_console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 7a517f65b5..01a3af722a 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -14,7 +14,7 @@ // Real start -include_once ("../../include/config.php"); +require_once ("../../include/config.php"); // Set root on homedir, as defined in setup chdir ($config["homedir"]);