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.