comparison geotemco/js/Map/MapZoomSlider.js @ 0:57bde4830927

first commit
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 24 Mar 2015 11:37:17 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:57bde4830927
1 /*
2 * MapZoomSlider.js
3 *
4 * Copyright (c) 2012, Stefan Jänicke. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301 USA
20 */
21
22 /**
23 * @class MapZoomSlider
24 * GeoTemCo style for map zoom control
25 * @author Stefan Jänicke (stjaenicke@informatik.uni-leipzig.de)
26 * @release 1.0
27 * @release date: 2012-07-27
28 * @version date: 2012-07-27
29 */
30 function MapZoomSlider(parent, orientation) {
31
32 this.parent = parent;
33
34 var zs = this;
35 this.div = document.createElement("div");
36 this.div.setAttribute('class', 'sliderStyle-' + orientation);
37
38 var sliderContainer = document.createElement("div");
39 sliderContainer.setAttribute('class', 'zoomSliderContainer-' + orientation);
40 var sliderDiv = document.createElement("div");
41 sliderDiv.tabIndex = 1;
42 var sliderInputDiv = document.createElement("div");
43 sliderDiv.appendChild(sliderInputDiv);
44 sliderContainer.appendChild(sliderDiv);
45 this.slider = new Slider(sliderDiv, sliderInputDiv, orientation);
46 this.div.appendChild(sliderContainer);
47
48 var zoomIn = document.createElement("img");
49 zoomIn.src = GeoTemConfig.path + "zoom_in.png";
50 zoomIn.setAttribute('class', 'zoomSliderIn-' + orientation);
51 zoomIn.onclick = function() {
52 zs.parent.zoom(1);
53 }
54 this.div.appendChild(zoomIn);
55
56 var zoomOut = document.createElement("img");
57 zoomOut.src = GeoTemConfig.path + "zoom_out.png";
58 zoomOut.setAttribute('class', 'zoomSliderOut-' + orientation);
59 zoomOut.onclick = function() {
60 zs.parent.zoom(-1);
61 }
62 this.div.appendChild(zoomOut);
63
64 this.slider.onclick = function() {
65 console.info(zs.slider.getValue());
66 }
67
68 this.slider.handle.onmousedown = function() {
69 var oldValue = zs.slider.getValue();
70 document.onmouseup = function() {
71 if (!zs.parent.zoom((zs.slider.getValue() - oldValue) / zs.max * zs.levels)) {
72 zs.setValue(oldValue);
73 }
74 document.onmouseup = null;
75 }
76 }
77
78 this.setValue = function(value) {
79 this.slider.setValue(value / this.levels * this.max);
80 }
81
82 this.setMaxAndLevels = function(max, levels) {
83 this.max = max;
84 this.levels = levels;
85 this.slider.setMaximum(max);
86 }
87 // this.setMaxAndLevels(1000,parent.openlayersMap.getNumZoomLevels());
88 // this.setValue(parent.getZoom());
89
90 this.setLanguage = function() {
91 zoomIn.title = GeoTemConfig.getString('zoomIn');
92 zoomOut.title = GeoTemConfig.getString('zoomOut');
93 this.slider.handle.title = GeoTemConfig.getString('zoomSlider');
94 }
95 }