mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Gis Maps Feature: When scrolling in map, change font-size of labels.
This commit is contained in:
parent
b3d6575176
commit
f8d3c8804e
@ -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)};
|
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)};
|
||||||
|
|
||||||
map = new OpenLayers.Map(id_div, option);
|
map = new OpenLayers.Map(id_div, option);
|
||||||
|
map.events.Event
|
||||||
var baseLayer = null;
|
var baseLayer = null;
|
||||||
|
|
||||||
|
map.events.on({"zoomend": EventZoomEnd});
|
||||||
|
|
||||||
//Define the maps layer
|
//Define the maps layer
|
||||||
for (var baselayerIndex in objBaseLayers) {
|
for (var baselayerIndex in objBaseLayers) {
|
||||||
if (isInt(baselayerIndex)) {
|
if (isInt(baselayerIndex)) {
|
||||||
@ -224,6 +226,50 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob
|
|||||||
map.setCenter (lonLat, initial_zoom);
|
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"
|
* Change the style of state button, and call the function "hideAgentsStatus"
|
||||||
* whith new state for agents icons to show.
|
* whith new state for agents icons to show.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
// Real start
|
// Real start
|
||||||
|
|
||||||
require_once ("../../include/config.php");
|
include_once ("../../include/config.php");
|
||||||
|
|
||||||
// Set root on homedir, as defined in setup
|
// Set root on homedir, as defined in setup
|
||||||
chdir ($config["homedir"]);
|
chdir ($config["homedir"]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user