Commit c6e0bb25b54026988d862f212ab906aab9bd5caf
1 parent
db418bc3
Exists in
master
and in
7 other branches
--no commit message
Showing
6 changed files
with
572 additions
and
571 deletions
Show diff stats
admin/html/estat_editor.html
... | ... | @@ -33,7 +33,7 @@ body { |
33 | 33 | <div id="ajuda" style="display: none"> |
34 | 34 | <div class="hd">Ajuda</div> |
35 | 35 | <div class="bd" style="height: 144px; overflow: auto"> |
36 | - <p>Este formulário permite editar as tabelas de dados utilizadas pelo | |
36 | + <p>Este formulário permite editar as tabelas que contém os dados utilizadas pelo | |
37 | 37 | sistema de metadados estatísticos |
38 | 38 | </div> |
39 | 39 | <div class="ft"></div> | ... | ... |
admin/html/estat_variavel.html
... | ... | @@ -48,7 +48,9 @@ body { |
48 | 48 | <div id="estatVariavelajuda"> |
49 | 49 | <div class="hd">Ajuda</div> |
50 | 50 | <div class="bd" style="height: 144px; overflow: auto"> |
51 | - <p> | |
51 | + <p>Esse formulário permite editar as varíáveis e suas medidas, definindo-se as fontes dos dados, tipos de classificação, | |
52 | + forma de representação etc. As váriáveis são fenômenos que possuem medidas estatísticas. Os parâmetros definem como | |
53 | + as variáveis são acessadas para a montagem dos cartogramas. | |
52 | 54 | </div> |
53 | 55 | <div class="ft"></div> |
54 | 56 | </div> |
... | ... | @@ -107,7 +109,7 @@ body { |
107 | 109 | locaplic : window.location.href.replace("/admin/html/estat_variavel.html","") |
108 | 110 | }; |
109 | 111 | // |
110 | - cabecalhoMetaestat("cabecalhoPrincipal", "arvore"); | |
112 | + cabecalhoMetaestat("cabecalhoPrincipal", "variavel"); | |
111 | 113 | temp = function() { |
112 | 114 | document.getElementById("formulario").style.display = "block"; |
113 | 115 | i3GEOadmin.variaveis.inicia(); | ... | ... |
admin/js/core.js
... | ... | @@ -79,6 +79,7 @@ function cabecalhoMetaestat(id,excluir){ |
79 | 79 | {id:"fonteinfo",titulo:"Fonte",link:"estat_fonteinfo.html"}, |
80 | 80 | {id:"editor",titulo:"Editor",link:"estat_editor.html"}, |
81 | 81 | {id:"uploaddados",titulo:"Upload",link:"estat_uploaddados.html"}, |
82 | + {id:"mapa",titulo:"Publicador",link:"estat_mapa.html"}, | |
82 | 83 | {id:"login",titulo:"Login",js:"i3GEO.login.dialogo.abreLogin()"} |
83 | 84 | ]; |
84 | 85 | n = botoes.length; | ... | ... |
classesjs/classe_interface.js
... | ... | @@ -715,7 +715,7 @@ i3GEO.Interface = { |
715 | 715 | //corrigido na versão 4.7 do i3geo (não tinha o if) |
716 | 716 | if(i3GEO.arvoreDeCamadas.ATIVATEMA === "") |
717 | 717 | {i3GEO.arvoreDeCamadas.ATIVATEMA = "i3GEO.Interface.ligaDesliga(this);i3GEO.eventos.executaEventos(i3GEO.eventos.ATUALIZAARVORECAMADAS);";} |
718 | - | |
718 | + | |
719 | 719 | i3GEO.util.multiStep([ |
720 | 720 | i3GEO.coordenadas.mostraCoordenadas, |
721 | 721 | montaMapa, |
... | ... | @@ -1479,7 +1479,7 @@ i3GEO.Interface = { |
1479 | 1479 | //carrega o javascript que permite fazer o zoom por box |
1480 | 1480 | // |
1481 | 1481 | if(!$i("keydragzoom_script")){ |
1482 | - js = i3GEO.configura.locaplic+"/pacotes/google/keydragzoom.js.php"; | |
1482 | + js = i3GEO.configura.locaplic+"/pacotes/google/keydragzoom.js"; | |
1483 | 1483 | i3GEO.util.scriptTag(js,"i3GEO.Interface.googlemaps.ativaZoomBox()","keydragzoom_script"); |
1484 | 1484 | } |
1485 | 1485 | i3GeoMapOverlay = new google.maps.OverlayView(); | ... | ... |
... | ... | @@ -0,0 +1,564 @@ |
1 | +/** | |
2 | + * @name Key Drag Zoom for V3 | |
3 | + * @version 1.0 | |
4 | + * @author: Nianwei Liu [nianwei at gmail dot com] e Gary Little [gary at luxcentral dot com] | |
5 | + * @fileoverview This library adds a drag zoom capability to a Google map. | |
6 | + * When drag zoom is enabled, holding down a user-defined hot key <code>(shift | ctrl | alt)</code> | |
7 | + * while dragging a box around an area of interest will zoom the map | |
8 | + * to that area when the hot key is released. | |
9 | + * Only one line of code is needed: <code>google.maps.Map.enableKeyDragZoom();</code> | |
10 | + * <p> | |
11 | + * Note that if the map's container has a border around it, the border widths must be specified | |
12 | + * in pixel units (or as thin, medium, or thick). This is required because of an MSIE limitation. | |
13 | + * <p>NL: 2009-05-28: initial port to core API V3. | |
14 | + */ | |
15 | +/*! | |
16 | + * | |
17 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
18 | + * you may not use this file except in compliance with the License. | |
19 | + * You may obtain a copy of the License at | |
20 | + * | |
21 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
22 | + * | |
23 | + * Unless required by applicable law or agreed to in writing, software | |
24 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
25 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
26 | + * See the License for the specific language governing permissions and | |
27 | + * limitations under the License. | |
28 | + */ | |
29 | +(function () { | |
30 | + /*jslint browser:true */ | |
31 | + /*global google */ | |
32 | + /** | |
33 | + * Converts 'thin', 'medium', and 'thick' to pixel widths | |
34 | + * in an MSIE environment. Not called for other browsers | |
35 | + * because getComputedStyle() returns pixel widths automatically. | |
36 | + * @param {String} widthValue | |
37 | + */ | |
38 | + var toPixels = function (widthValue) { | |
39 | + var px; | |
40 | + switch (widthValue) { | |
41 | + case 'thin': | |
42 | + px = "2px"; | |
43 | + break; | |
44 | + case 'medium': | |
45 | + px = "4px"; | |
46 | + break; | |
47 | + case 'thick': | |
48 | + px = "6px"; | |
49 | + break; | |
50 | + default: | |
51 | + px = widthValue; | |
52 | + } | |
53 | + return px; | |
54 | + }; | |
55 | + /** | |
56 | + * Get the widths of the borders of an HTML element. | |
57 | + * | |
58 | + * @param {Object} h HTML element | |
59 | + * @return {Object} widths object (top, bottom left, right) | |
60 | + */ | |
61 | + var getBorderWidths = function (h) { | |
62 | + var computedStyle; | |
63 | + var bw = {}; | |
64 | + if (document.defaultView && document.defaultView.getComputedStyle) { | |
65 | + computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, ""); | |
66 | + if (computedStyle) { | |
67 | + // The computed styles are always in pixel units (good!) | |
68 | + bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0; | |
69 | + bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0; | |
70 | + bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0; | |
71 | + bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0; | |
72 | + return bw; | |
73 | + } | |
74 | + } else if (document.documentElement.currentStyle) { // MSIE | |
75 | + if (h.currentStyle) { | |
76 | + // The current styles may not be in pixel units so try to convert (bad!) | |
77 | + bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0; | |
78 | + bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0; | |
79 | + bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0; | |
80 | + bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0; | |
81 | + return bw; | |
82 | + } | |
83 | + } | |
84 | + // Shouldn't get this far for any modern browser | |
85 | + bw.top = parseInt(h.style["border-top-width"], 10) || 0; | |
86 | + bw.bottom = parseInt(h.style["border-bottom-width"], 10) || 0; | |
87 | + bw.left = parseInt(h.style["border-left-width"], 10) || 0; | |
88 | + bw.right = parseInt(h.style["border-right-width"], 10) || 0; | |
89 | + return bw; | |
90 | + }; | |
91 | + | |
92 | + /** | |
93 | + * Get the position of the mouse relative to the document. | |
94 | + * @param {Object} e Mouse event | |
95 | + * @return {Object} left & top position | |
96 | + */ | |
97 | + var getMousePosition = function (e) { | |
98 | + var posX = 0, posY = 0; | |
99 | + e = e || window.event; | |
100 | + if (typeof e.pageX !== "undefined") { | |
101 | + posX = e.pageX; | |
102 | + posY = e.pageY; | |
103 | + } else if (typeof e.clientX !== "undefined") { | |
104 | + posX = e.clientX + | |
105 | + (typeof document.documentElement.scrollLeft !== "undefined" ? document.documentElement.scrollLeft : document.body.scrollLeft); | |
106 | + posY = e.clientY + | |
107 | + (typeof document.documentElement.scrollTop !== "undefined" ? document.documentElement.scrollTop : document.body.scrollTop); | |
108 | + } | |
109 | + return { | |
110 | + left: posX, | |
111 | + top: posY | |
112 | + }; | |
113 | + }; | |
114 | + | |
115 | + /** | |
116 | + * Get the position of an HTML element relative to the document. | |
117 | + * @param {Object} h HTML element | |
118 | + * @return {Object} left & top position | |
119 | + */ | |
120 | + var getElementPosition = function (h) { | |
121 | + var posX = h.offsetLeft; | |
122 | + var posY = h.offsetTop; | |
123 | + var parent = h.offsetParent; | |
124 | + // Add offsets for all ancestors in the hierarchy | |
125 | + while (parent !== null) { | |
126 | + // Adjust for scrolling elements which may affect the map position. | |
127 | + // | |
128 | + // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific | |
129 | + // | |
130 | + // "...make sure that every element [on a Web page] with an overflow | |
131 | + // of anything other than visible also has a position style set to | |
132 | + // something other than the default static..." | |
133 | + if (parent !== document.body && parent !== document.documentElement) { | |
134 | + posX -= parent.scrollLeft; | |
135 | + posY -= parent.scrollTop; | |
136 | + } | |
137 | + posX += parent.offsetLeft; | |
138 | + posY += parent.offsetTop; | |
139 | + parent = parent.offsetParent; | |
140 | + } | |
141 | + return { | |
142 | + left: posX, | |
143 | + top: posY | |
144 | + }; | |
145 | + }; | |
146 | + /** | |
147 | + * Set the properties of an object to those from another object. | |
148 | + * @param {Object} obj target object | |
149 | + * @param {Object} vals source object | |
150 | + */ | |
151 | + var setVals = function (obj, vals) { | |
152 | + if (obj && vals) { | |
153 | + for (var x in vals) { | |
154 | + if (vals.hasOwnProperty(x)) { | |
155 | + obj[x] = vals[x]; | |
156 | + } | |
157 | + } | |
158 | + } | |
159 | + return obj; | |
160 | + }; | |
161 | + /** | |
162 | + * Set the opacity. If op is not passed in, this function just performs an MSIE fix. | |
163 | + * @param {Node} div | |
164 | + * @param {Number} op (0-1) | |
165 | + */ | |
166 | + var setOpacity = function (div, op) { | |
167 | + if (typeof op !== 'undefined') { | |
168 | + div.style.opacity = op; | |
169 | + } | |
170 | + if (typeof div.style.opacity !== 'undefined') { | |
171 | + div.style.filter = "alpha(opacity=" + (div.style.opacity * 100) + ")"; | |
172 | + } | |
173 | + }; | |
174 | + | |
175 | + /** | |
176 | + * @name KeyDragZoomOptions | |
177 | + * @class This class represents the optional parameter passed into <code>google.maps.Map.enableDragBoxZoom</code>. | |
178 | + * @property {String} [key] the hot key to hold down to activate a drag zoom, <code>shift | ctrl | alt</code>. | |
179 | + * The default is <code>shift</code>. | |
180 | + * @property {Object} [boxStyle] the css style of the zoom box. | |
181 | + * The default is <code>{border: 'thin solid #FF0000'}</code>. | |
182 | + * Border widths must be specified in pixel units (or as thin, medium, or thick). | |
183 | + * @property {Object} [paneStyle] the css style of the pane which overlays the map when a drag zoom is activated. | |
184 | + * The default is <code>{backgroundColor: 'white', opacity: 0.0, cursor: 'crosshair'}</code>. | |
185 | + */ | |
186 | + /** | |
187 | + * @name DragZoom | |
188 | + * @class This class represents a drag zoom object for a map. The object is activated by holding down the hot key. | |
189 | + * This object is created when <code>google.maps.Map.enableKeyDragZoom</code> is called; it cannot be created directly. | |
190 | + * Use <code>google.maps.Map.getDragZoomObject</code> to gain access to this object in order to attach event listeners. | |
191 | + * @param {google.maps.Map} map | |
192 | + * @param {KeyDragZoomOptions} opt_zoomOpts | |
193 | + */ | |
194 | + function DragZoom(map, opt_zoomOpts) { | |
195 | + var ov = new google.maps.OverlayView(); | |
196 | + var me = this; | |
197 | + ov.onAdd = function () { | |
198 | + me.init_(map, opt_zoomOpts); | |
199 | + }; | |
200 | + ov.draw = function () { | |
201 | + }; | |
202 | + ov.onRemove = function () { | |
203 | + }; | |
204 | + ov.setMap(map); | |
205 | + this.prjov_ = ov; | |
206 | + } | |
207 | + /** | |
208 | + * Init the tool. | |
209 | + * @param {google.maps.Map} map | |
210 | + * @param {KeyDragZoomOptions} opt_zoomOpts | |
211 | + */ | |
212 | + DragZoom.prototype.init_ = function (map, opt_zoomOpts) { | |
213 | + this.map_ = map; | |
214 | + opt_zoomOpts = opt_zoomOpts || {}; | |
215 | + this.key_ = opt_zoomOpts.key || 'shift'; | |
216 | + this.key_ = this.key_.toLowerCase(); | |
217 | + this.borderWidths_ = getBorderWidths(this.map_.getDiv());//Container()); | |
218 | + this.paneDiv_ = document.createElement("div"); | |
219 | + this.paneDiv_.onselectstart = function () { | |
220 | + return false; | |
221 | + }; | |
222 | + // default style | |
223 | + setVals(this.paneDiv_.style, { | |
224 | + backgroundColor: 'white', | |
225 | + opacity: 0.0, | |
226 | + cursor: 'crosshair' | |
227 | + }); | |
228 | + // allow overwrite | |
229 | + setVals(this.paneDiv_.style, opt_zoomOpts.paneStyle); | |
230 | + // stuff that cannot be overwritten | |
231 | + setVals(this.paneDiv_.style, { | |
232 | + position: 'absolute', | |
233 | + overflow: 'hidden', | |
234 | + zIndex: 10001, | |
235 | + display: 'none' | |
236 | + }); | |
237 | + if (this.key_ === 'shift') { // Workaround for Firefox Shift-Click problem | |
238 | + this.paneDiv_.style.MozUserSelect = "none"; | |
239 | + } | |
240 | + setOpacity(this.paneDiv_); | |
241 | + // An IE fix: if the background is transparent, it cannot capture mousedown events | |
242 | + if (this.paneDiv_.style.backgroundColor === 'transparent') { | |
243 | + this.paneDiv_.style.backgroundColor = 'white'; | |
244 | + setOpacity(this.paneDiv_, 0); | |
245 | + } | |
246 | + this.map_.getDiv().appendChild(this.paneDiv_);//Container() | |
247 | + this.boxDiv_ = document.createElement('div'); | |
248 | + setVals(this.boxDiv_.style, { | |
249 | + border: 'thin solid #FF0000' | |
250 | + }); | |
251 | + setVals(this.boxDiv_.style, opt_zoomOpts.boxStyle); | |
252 | + setVals(this.boxDiv_.style, { | |
253 | + position: 'absolute', | |
254 | + display: 'none' | |
255 | + }); | |
256 | + setOpacity(this.boxDiv_); | |
257 | + this.map_.getDiv().appendChild(this.boxDiv_); | |
258 | + this.boxBorderWidths_ = getBorderWidths(this.boxDiv_); | |
259 | + var me = this; | |
260 | + this.keyDownListener_ = google.maps.event.addDomListener(document, 'keydown', function (e) { | |
261 | + me.onKeyDown_(e); | |
262 | + }); | |
263 | + this.keyUpListener_ = google.maps.event.addDomListener(document, 'keyup', function (e) { | |
264 | + me.onKeyUp_(e); | |
265 | + }); | |
266 | + this.mouseDownListener_ = google.maps.event.addDomListener(this.paneDiv_, 'mousedown', function (e) { | |
267 | + me.onMouseDown_(e); | |
268 | + }); | |
269 | + this.mouseDownListenerDocument_ = google.maps.event.addDomListener(document, 'mousedown', function (e) { | |
270 | + me.onMouseDownDocument_(e); | |
271 | + }); | |
272 | + this.mouseMoveListener_ = google.maps.event.addDomListener(document, 'mousemove', function (e) { | |
273 | + me.onMouseMove_(e); | |
274 | + }); | |
275 | + this.mouseUpListener_ = google.maps.event.addDomListener(document, 'mouseup', function (e) { | |
276 | + me.onMouseUp_(e); | |
277 | + }); | |
278 | + | |
279 | + this.hotKeyDown_ = false; | |
280 | + this.dragging_ = false; | |
281 | + this.startPt_ = null; | |
282 | + this.endPt_ = null; | |
283 | + this.boxMaxX_ = null; | |
284 | + this.boxMaxY_ = null; | |
285 | + this.mousePosn_ = null; | |
286 | + this.mapPosn_ = getElementPosition(this.map_.getDiv()); | |
287 | + this.mouseDown_ = false; | |
288 | + }; | |
289 | + | |
290 | + /** | |
291 | + * Returns true if the hot key is being pressed when an event occurs. | |
292 | + * @param {Event} e | |
293 | + * @return {Boolean} | |
294 | + */ | |
295 | + DragZoom.prototype.isHotKeyDown_ = function (e) { | |
296 | + var isHot; | |
297 | + e = e || window.event; | |
298 | + isHot = (e.shiftKey && this.key_ === 'shift') || (e.altKey && this.key_ === 'alt') || (e.ctrlKey && this.key_ === 'ctrl'); | |
299 | + if (!isHot) { | |
300 | + // Need to look at keyCode for Opera because it | |
301 | + // doesn't set the shiftKey, altKey, ctrlKey properties | |
302 | + // unless a non-modifier event is being reported. | |
303 | + // | |
304 | + // See http://cross-browser.com/x/examples/shift_mode.php | |
305 | + // Also see http://unixpapa.com/js/key.html | |
306 | + switch (e.keyCode) { | |
307 | + case 16: | |
308 | + if (this.key_ === 'shift') { | |
309 | + isHot = true; | |
310 | + } | |
311 | + break; | |
312 | + case 17: | |
313 | + if (this.key_ === 'ctrl') { | |
314 | + isHot = true; | |
315 | + } | |
316 | + break; | |
317 | + case 18: | |
318 | + if (this.key_ === 'alt') { | |
319 | + isHot = true; | |
320 | + } | |
321 | + break; | |
322 | + } | |
323 | + } | |
324 | + return isHot; | |
325 | + }; | |
326 | + | |
327 | + /** | |
328 | + * Checks if the mouse is on top of the map. The position is captured | |
329 | + * in onMouseMove_. | |
330 | + * @return true if mouse is on top of the map div. | |
331 | + */ | |
332 | + DragZoom.prototype.isMouseOnMap_ = function () { | |
333 | + var mousePos = this.mousePosn_; | |
334 | + if (mousePos) { | |
335 | + var mapPos = this.mapPosn_; | |
336 | + var mapDiv = this.map_.getDiv(); | |
337 | + return mousePos.left > mapPos.left && mousePos.left < mapPos.left + mapDiv.offsetWidth && | |
338 | + mousePos.top > mapPos.top && mousePos.top < mapPos.top + mapDiv.offsetHeight; | |
339 | + } else { | |
340 | + // if user never moved mouse | |
341 | + return false; | |
342 | + } | |
343 | + }; | |
344 | + | |
345 | + /** | |
346 | + * Show or hide the overlay pane, depending on whether the mouse is over the map. | |
347 | + */ | |
348 | + DragZoom.prototype.setPaneVisibility_ = function () { | |
349 | + if (this.map_ && this.hotKeyDown_ && this.isMouseOnMap_()) { | |
350 | + var mapDiv = this.map_.getDiv(); | |
351 | + this.paneDiv_.style.left = 0 + 'px'; | |
352 | + this.paneDiv_.style.top = 0 + 'px'; | |
353 | + this.paneDiv_.style.width = mapDiv.offsetWidth - (this.borderWidths_.left + this.borderWidths_.right) + 'px'; | |
354 | + this.paneDiv_.style.height = mapDiv.offsetHeight - (this.borderWidths_.top + this.borderWidths_.bottom) + 'px'; | |
355 | + this.paneDiv_.style.display = 'block'; | |
356 | + this.boxMaxX_ = parseInt(this.paneDiv_.style.width, 10) - (this.boxBorderWidths_.left + this.boxBorderWidths_.right); | |
357 | + this.boxMaxY_ = parseInt(this.paneDiv_.style.height, 10) - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom); | |
358 | + } else { | |
359 | + this.paneDiv_.style.display = 'none'; | |
360 | + } | |
361 | + }; | |
362 | + /** | |
363 | + * Handle key down. Activate the tool only if the mouse is on top of the map. | |
364 | + * @param {Event} e | |
365 | + */ | |
366 | + DragZoom.prototype.onKeyDown_ = function (e) { | |
367 | + var me = this; | |
368 | + if (this.map_ && !this.hotKeyDown_ && this.isHotKeyDown_(e)) { | |
369 | + //desativa o clique permanente | |
370 | + i3GEO.eventos.cliquePerm.desativa(); | |
371 | + me.hotKeyDown_ = true; | |
372 | + me.setPaneVisibility_(); | |
373 | + /** | |
374 | + * This event is fired when the hot key is pressed. | |
375 | + * @name DragZoom#activate | |
376 | + * @event | |
377 | + */ | |
378 | + google.maps.event.trigger(me, 'activate'); | |
379 | + } | |
380 | + }; | |
381 | + /** | |
382 | + * Get the <code>google.maps.Point</code> of the mouse position. | |
383 | + * @param {Object} e | |
384 | + * @return {google.maps.Point} point | |
385 | + * @private | |
386 | + */ | |
387 | + DragZoom.prototype.getMousePoint_ = function (e) { | |
388 | + var mousePosn = getMousePosition(e); | |
389 | + var p = new google.maps.Point(); | |
390 | + p.x = mousePosn.left - this.mapPosn_.left - this.borderWidths_.left; | |
391 | + p.y = mousePosn.top - this.mapPosn_.top - this.borderWidths_.top; | |
392 | + p.x = Math.min(p.x, this.boxMaxX_); | |
393 | + p.y = Math.min(p.y, this.boxMaxY_); | |
394 | + p.x = Math.max(p.x, 0); | |
395 | + p.y = Math.max(p.y, 0); | |
396 | + return p; | |
397 | + }; | |
398 | + /** | |
399 | + * Handle mouse down. | |
400 | + * @param {Event} e | |
401 | + */ | |
402 | + DragZoom.prototype.onMouseDown_ = function (e) { | |
403 | + if (this.map_ && this.hotKeyDown_) { | |
404 | + this.mapPosn_ = getElementPosition(this.map_.getDiv()); | |
405 | + this.dragging_ = true; | |
406 | + this.startPt_ = this.endPt_ = this.getMousePoint_(e); | |
407 | + var prj = this.prjov_.getProjection(); | |
408 | + var latlng = prj.fromDivPixelToLatLng(this.startPt_); | |
409 | + /** | |
410 | + * This event is fired when the drag operation begins. | |
411 | + * @name DragZoom#dragstart | |
412 | + * @param {GLatLng} startLatLng | |
413 | + * @event | |
414 | + */ | |
415 | + google.maps.event.trigger(this, 'dragstart', latlng); | |
416 | + } | |
417 | + }; | |
418 | + /** | |
419 | + * Handle mouse down at the document level. | |
420 | + * @param {Event} e | |
421 | + */ | |
422 | + DragZoom.prototype.onMouseDownDocument_ = function (e) { | |
423 | + this.mouseDown_ = true; | |
424 | + }; | |
425 | + /** | |
426 | + * Handle mouse move. | |
427 | + * @param {Event} e | |
428 | + */ | |
429 | + DragZoom.prototype.onMouseMove_ = function (e) { | |
430 | + this.mousePosn_ = getMousePosition(e); | |
431 | + if (this.dragging_) { | |
432 | + this.endPt_ = this.getMousePoint_(e); | |
433 | + var left = Math.min(this.startPt_.x, this.endPt_.x); | |
434 | + var top = Math.min(this.startPt_.y, this.endPt_.y); | |
435 | + var width = Math.abs(this.startPt_.x - this.endPt_.x); | |
436 | + var height = Math.abs(this.startPt_.y - this.endPt_.y); | |
437 | + this.boxDiv_.style.left = left + 'px'; | |
438 | + this.boxDiv_.style.top = top + 'px'; | |
439 | + this.boxDiv_.style.width = width + 'px'; | |
440 | + this.boxDiv_.style.height = height + 'px'; | |
441 | + this.boxDiv_.style.display = 'block'; | |
442 | + /** | |
443 | + * This event is repeatedly fired while the user drags the box. The southwest and northeast | |
444 | + * point are passed as parameters of type <code>google.maps.Point</code> (for performance reasons), | |
445 | + * relative to the map container. Note: the event listener is responsible | |
446 | + * for converting Pixel to LatLng, if necessary. | |
447 | + * @name DragZoom#drag | |
448 | + * @param {google.maps.Point} southwestPixel | |
449 | + * @param {google.maps.Point} northeastPixel | |
450 | + * @event | |
451 | + */ | |
452 | + google.maps.event.trigger(this, 'drag', new google.maps.Point(left, top + height), new google.maps.Point(left + width, top)); | |
453 | + } else if (!this.mouseDown_) { | |
454 | + this.setPaneVisibility_(); | |
455 | + } | |
456 | + }; | |
457 | + /** | |
458 | + * Handle mouse up. | |
459 | + * @param {Event} e | |
460 | + */ | |
461 | + DragZoom.prototype.onMouseUp_ = function (e) { | |
462 | + this.mouseDown_ = false; | |
463 | + if (this.dragging_) { | |
464 | + //desativa o clique permanente | |
465 | + i3GEO.eventos.cliquePerm.ativa(); | |
466 | + var left = Math.min(this.startPt_.x, this.endPt_.x); | |
467 | + var top = Math.min(this.startPt_.y, this.endPt_.y); | |
468 | + var width = Math.abs(this.startPt_.x - this.endPt_.x); | |
469 | + var height = Math.abs(this.startPt_.y - this.endPt_.y); | |
470 | + var prj = this.prjov_.getProjection(); | |
471 | + // 2009-05-29: since V3 does not have fromContainerPixel, | |
472 | + //needs find offset here | |
473 | + var containerPos = getElementPosition(this.map_.getDiv()); | |
474 | + var mapPanePos = getElementPosition(this.prjov_.getPanes().mapPane); | |
475 | + left = left + (containerPos.left - mapPanePos.left); | |
476 | + top = top + (containerPos.top - mapPanePos.top); | |
477 | + var sw = prj.fromDivPixelToLatLng(new google.maps.Point(left, top + height)); | |
478 | + var ne = prj.fromDivPixelToLatLng(new google.maps.Point(left + width, top)); | |
479 | + var bnds = new google.maps.LatLngBounds(sw, ne); | |
480 | + this.map_.fitBounds(bnds); | |
481 | + this.dragging_ = false; | |
482 | + this.boxDiv_.style.display = 'none'; | |
483 | + /** | |
484 | + * This event is fired when the drag operation ends. | |
485 | + * Note that the event is not fired if the hot key is released before the drag operation ends. | |
486 | + * @name DragZoom#dragend | |
487 | + * @param {GLatLngBounds} newBounds | |
488 | + * @event | |
489 | + */ | |
490 | + google.maps.event.trigger(this, 'dragend', bnds); | |
491 | + } | |
492 | + }; | |
493 | + | |
494 | + /** | |
495 | + * Handle key up. | |
496 | + * @param {Event} e | |
497 | + */ | |
498 | + DragZoom.prototype.onKeyUp_ = function (e) { | |
499 | + if (this.map_ && this.hotKeyDown_) { | |
500 | + this.hotKeyDown_ = false; | |
501 | + this.dragging_ = false; | |
502 | + this.boxDiv_.style.display = 'none'; | |
503 | + this.paneDiv_.style.display = "none"; | |
504 | + /** | |
505 | + * This event is fired while the user release the key | |
506 | + * @name DragZoom#deactivate | |
507 | + * @event | |
508 | + */ | |
509 | + google.maps.event.trigger(this, 'deactivate'); | |
510 | + } | |
511 | + }; | |
512 | + | |
513 | + | |
514 | + | |
515 | + | |
516 | + /** | |
517 | + * @name google.maps.Map | |
518 | + * @class These are new methods added to the Google Maps API's | |
519 | + * <a href = 'http://code.google.com/apis/maps/documentation/v3/reference.html#Map'>Map</a> | |
520 | + * class. | |
521 | + */ | |
522 | + /** | |
523 | + * Enable drag zoom. The user can zoom to an area of interest by holding down the hot key | |
524 | + * <code>(shift | ctrl | alt )</code> while dragging a box around the area. | |
525 | + * @param {KeyDragZoomOptions} opt_zoomOpts | |
526 | + */ | |
527 | + | |
528 | + google.maps.Map.prototype.enableKeyDragZoom = function (opt_zoomOpts) { | |
529 | + this.dragZoom_ = new DragZoom(this, opt_zoomOpts); | |
530 | + }; | |
531 | + /** | |
532 | + * Disable drag zoom. | |
533 | + */ | |
534 | + google.maps.Map.prototype.disableKeyDragZoom = function () { | |
535 | + var d = this.dragZoom_; | |
536 | + if (d) { | |
537 | + google.maps.event.removeListener(d.mouseDownListener_); | |
538 | + google.maps.event.removeListener(d.mouseDownListenerDocument_); | |
539 | + google.maps.event.removeListener(d.mouseMoveListener_); | |
540 | + google.maps.event.removeListener(d.mouseUpListener_); | |
541 | + google.maps.event.removeListener(d.keyUpListener_); | |
542 | + google.maps.event.removeListener(d.keyDownListener_); | |
543 | + this.getDiv().removeChild(d.boxDiv_); | |
544 | + this.getDiv().removeChild(d.paneDiv_); | |
545 | + this.dragZoom_ = null; | |
546 | + } | |
547 | + }; | |
548 | + /** | |
549 | + * Returns true if the drag zoom feature has been enabled. | |
550 | + * @return {Boolean} | |
551 | + */ | |
552 | + google.maps.Map.prototype.keyDragZoomEnabled = function () { | |
553 | + return this.dragZoom_ !== null; | |
554 | + }; | |
555 | + /** | |
556 | + * Returns the DragZoom object which is created when <code>google.maps.Map.enableKeyDragZoom</code> is called. | |
557 | + * With this object you can use <code>google.maps.event.addListener</code> to attach event listeners | |
558 | + * for the 'activate', 'deactivate', 'dragstart', 'drag', and 'dragend' events. | |
559 | + * @return {DragZoom} | |
560 | + */ | |
561 | + google.maps.Map.prototype.getDragZoomObject = function () { | |
562 | + return this.dragZoom_; | |
563 | + }; | |
564 | +})(); | ... | ... |
pacotes/google/keydragzoom.js.php
... | ... | @@ -1,566 +0,0 @@ |
1 | -<?php error_reporting(0);if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header("Content-type: text/javascript"); ?> | |
2 | -/** | |
3 | - * @name Key Drag Zoom for V3 | |
4 | - * @version 1.0 | |
5 | - * @author: Nianwei Liu [nianwei at gmail dot com] e Gary Little [gary at luxcentral dot com] | |
6 | - * @fileoverview This library adds a drag zoom capability to a Google map. | |
7 | - * When drag zoom is enabled, holding down a user-defined hot key <code>(shift | ctrl | alt)</code> | |
8 | - * while dragging a box around an area of interest will zoom the map | |
9 | - * to that area when the hot key is released. | |
10 | - * Only one line of code is needed: <code>google.maps.Map.enableKeyDragZoom();</code> | |
11 | - * <p> | |
12 | - * Note that if the map's container has a border around it, the border widths must be specified | |
13 | - * in pixel units (or as thin, medium, or thick). This is required because of an MSIE limitation. | |
14 | - * <p>NL: 2009-05-28: initial port to core API V3. | |
15 | - */ | |
16 | -/*! | |
17 | - * | |
18 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
19 | - * you may not use this file except in compliance with the License. | |
20 | - * You may obtain a copy of the License at | |
21 | - * | |
22 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
23 | - * | |
24 | - * Unless required by applicable law or agreed to in writing, software | |
25 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
26 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
27 | - * See the License for the specific language governing permissions and | |
28 | - * limitations under the License. | |
29 | - */ | |
30 | -(function () { | |
31 | - /*jslint browser:true */ | |
32 | - /*global google */ | |
33 | - /** | |
34 | - * Converts 'thin', 'medium', and 'thick' to pixel widths | |
35 | - * in an MSIE environment. Not called for other browsers | |
36 | - * because getComputedStyle() returns pixel widths automatically. | |
37 | - * @param {String} widthValue | |
38 | - */ | |
39 | - var toPixels = function (widthValue) { | |
40 | - var px; | |
41 | - switch (widthValue) { | |
42 | - case 'thin': | |
43 | - px = "2px"; | |
44 | - break; | |
45 | - case 'medium': | |
46 | - px = "4px"; | |
47 | - break; | |
48 | - case 'thick': | |
49 | - px = "6px"; | |
50 | - break; | |
51 | - default: | |
52 | - px = widthValue; | |
53 | - } | |
54 | - return px; | |
55 | - }; | |
56 | - /** | |
57 | - * Get the widths of the borders of an HTML element. | |
58 | - * | |
59 | - * @param {Object} h HTML element | |
60 | - * @return {Object} widths object (top, bottom left, right) | |
61 | - */ | |
62 | - var getBorderWidths = function (h) { | |
63 | - var computedStyle; | |
64 | - var bw = {}; | |
65 | - if (document.defaultView && document.defaultView.getComputedStyle) { | |
66 | - computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, ""); | |
67 | - if (computedStyle) { | |
68 | - // The computed styles are always in pixel units (good!) | |
69 | - bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0; | |
70 | - bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0; | |
71 | - bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0; | |
72 | - bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0; | |
73 | - return bw; | |
74 | - } | |
75 | - } else if (document.documentElement.currentStyle) { // MSIE | |
76 | - if (h.currentStyle) { | |
77 | - // The current styles may not be in pixel units so try to convert (bad!) | |
78 | - bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0; | |
79 | - bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0; | |
80 | - bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0; | |
81 | - bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0; | |
82 | - return bw; | |
83 | - } | |
84 | - } | |
85 | - // Shouldn't get this far for any modern browser | |
86 | - bw.top = parseInt(h.style["border-top-width"], 10) || 0; | |
87 | - bw.bottom = parseInt(h.style["border-bottom-width"], 10) || 0; | |
88 | - bw.left = parseInt(h.style["border-left-width"], 10) || 0; | |
89 | - bw.right = parseInt(h.style["border-right-width"], 10) || 0; | |
90 | - return bw; | |
91 | - }; | |
92 | - | |
93 | - /** | |
94 | - * Get the position of the mouse relative to the document. | |
95 | - * @param {Object} e Mouse event | |
96 | - * @return {Object} left & top position | |
97 | - */ | |
98 | - var getMousePosition = function (e) { | |
99 | - var posX = 0, posY = 0; | |
100 | - e = e || window.event; | |
101 | - if (typeof e.pageX !== "undefined") { | |
102 | - posX = e.pageX; | |
103 | - posY = e.pageY; | |
104 | - } else if (typeof e.clientX !== "undefined") { | |
105 | - posX = e.clientX + | |
106 | - (typeof document.documentElement.scrollLeft !== "undefined" ? document.documentElement.scrollLeft : document.body.scrollLeft); | |
107 | - posY = e.clientY + | |
108 | - (typeof document.documentElement.scrollTop !== "undefined" ? document.documentElement.scrollTop : document.body.scrollTop); | |
109 | - } | |
110 | - return { | |
111 | - left: posX, | |
112 | - top: posY | |
113 | - }; | |
114 | - }; | |
115 | - | |
116 | - /** | |
117 | - * Get the position of an HTML element relative to the document. | |
118 | - * @param {Object} h HTML element | |
119 | - * @return {Object} left & top position | |
120 | - */ | |
121 | - var getElementPosition = function (h) { | |
122 | - var posX = h.offsetLeft; | |
123 | - var posY = h.offsetTop; | |
124 | - var parent = h.offsetParent; | |
125 | - // Add offsets for all ancestors in the hierarchy | |
126 | - while (parent !== null) { | |
127 | - // Adjust for scrolling elements which may affect the map position. | |
128 | - // | |
129 | - // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific | |
130 | - // | |
131 | - // "...make sure that every element [on a Web page] with an overflow | |
132 | - // of anything other than visible also has a position style set to | |
133 | - // something other than the default static..." | |
134 | - if (parent !== document.body && parent !== document.documentElement) { | |
135 | - posX -= parent.scrollLeft; | |
136 | - posY -= parent.scrollTop; | |
137 | - } | |
138 | - posX += parent.offsetLeft; | |
139 | - posY += parent.offsetTop; | |
140 | - parent = parent.offsetParent; | |
141 | - } | |
142 | - return { | |
143 | - left: posX, | |
144 | - top: posY | |
145 | - }; | |
146 | - }; | |
147 | - /** | |
148 | - * Set the properties of an object to those from another object. | |
149 | - * @param {Object} obj target object | |
150 | - * @param {Object} vals source object | |
151 | - */ | |
152 | - var setVals = function (obj, vals) { | |
153 | - if (obj && vals) { | |
154 | - for (var x in vals) { | |
155 | - if (vals.hasOwnProperty(x)) { | |
156 | - obj[x] = vals[x]; | |
157 | - } | |
158 | - } | |
159 | - } | |
160 | - return obj; | |
161 | - }; | |
162 | - /** | |
163 | - * Set the opacity. If op is not passed in, this function just performs an MSIE fix. | |
164 | - * @param {Node} div | |
165 | - * @param {Number} op (0-1) | |
166 | - */ | |
167 | - var setOpacity = function (div, op) { | |
168 | - if (typeof op !== 'undefined') { | |
169 | - div.style.opacity = op; | |
170 | - } | |
171 | - if (typeof div.style.opacity !== 'undefined') { | |
172 | - div.style.filter = "alpha(opacity=" + (div.style.opacity * 100) + ")"; | |
173 | - } | |
174 | - }; | |
175 | - | |
176 | - /** | |
177 | - * @name KeyDragZoomOptions | |
178 | - * @class This class represents the optional parameter passed into <code>google.maps.Map.enableDragBoxZoom</code>. | |
179 | - * @property {String} [key] the hot key to hold down to activate a drag zoom, <code>shift | ctrl | alt</code>. | |
180 | - * The default is <code>shift</code>. | |
181 | - * @property {Object} [boxStyle] the css style of the zoom box. | |
182 | - * The default is <code>{border: 'thin solid #FF0000'}</code>. | |
183 | - * Border widths must be specified in pixel units (or as thin, medium, or thick). | |
184 | - * @property {Object} [paneStyle] the css style of the pane which overlays the map when a drag zoom is activated. | |
185 | - * The default is <code>{backgroundColor: 'white', opacity: 0.0, cursor: 'crosshair'}</code>. | |
186 | - */ | |
187 | - /** | |
188 | - * @name DragZoom | |
189 | - * @class This class represents a drag zoom object for a map. The object is activated by holding down the hot key. | |
190 | - * This object is created when <code>google.maps.Map.enableKeyDragZoom</code> is called; it cannot be created directly. | |
191 | - * Use <code>google.maps.Map.getDragZoomObject</code> to gain access to this object in order to attach event listeners. | |
192 | - * @param {google.maps.Map} map | |
193 | - * @param {KeyDragZoomOptions} opt_zoomOpts | |
194 | - */ | |
195 | - function DragZoom(map, opt_zoomOpts) { | |
196 | - var ov = new google.maps.OverlayView(); | |
197 | - var me = this; | |
198 | - ov.onAdd = function () { | |
199 | - me.init_(map, opt_zoomOpts); | |
200 | - }; | |
201 | - ov.draw = function () { | |
202 | - }; | |
203 | - ov.onRemove = function () { | |
204 | - }; | |
205 | - ov.setMap(map); | |
206 | - this.prjov_ = ov; | |
207 | - } | |
208 | - /** | |
209 | - * Init the tool. | |
210 | - * @param {google.maps.Map} map | |
211 | - * @param {KeyDragZoomOptions} opt_zoomOpts | |
212 | - */ | |
213 | - DragZoom.prototype.init_ = function (map, opt_zoomOpts) { | |
214 | - this.map_ = map; | |
215 | - opt_zoomOpts = opt_zoomOpts || {}; | |
216 | - this.key_ = opt_zoomOpts.key || 'shift'; | |
217 | - this.key_ = this.key_.toLowerCase(); | |
218 | - this.borderWidths_ = getBorderWidths(this.map_.getDiv());//Container()); | |
219 | - this.paneDiv_ = document.createElement("div"); | |
220 | - this.paneDiv_.onselectstart = function () { | |
221 | - return false; | |
222 | - }; | |
223 | - // default style | |
224 | - setVals(this.paneDiv_.style, { | |
225 | - backgroundColor: 'white', | |
226 | - opacity: 0.0, | |
227 | - cursor: 'crosshair' | |
228 | - }); | |
229 | - // allow overwrite | |
230 | - setVals(this.paneDiv_.style, opt_zoomOpts.paneStyle); | |
231 | - // stuff that cannot be overwritten | |
232 | - setVals(this.paneDiv_.style, { | |
233 | - position: 'absolute', | |
234 | - overflow: 'hidden', | |
235 | - zIndex: 10001, | |
236 | - display: 'none' | |
237 | - }); | |
238 | - if (this.key_ === 'shift') { // Workaround for Firefox Shift-Click problem | |
239 | - this.paneDiv_.style.MozUserSelect = "none"; | |
240 | - } | |
241 | - setOpacity(this.paneDiv_); | |
242 | - // An IE fix: if the background is transparent, it cannot capture mousedown events | |
243 | - if (this.paneDiv_.style.backgroundColor === 'transparent') { | |
244 | - this.paneDiv_.style.backgroundColor = 'white'; | |
245 | - setOpacity(this.paneDiv_, 0); | |
246 | - } | |
247 | - this.map_.getDiv().appendChild(this.paneDiv_);//Container() | |
248 | - this.boxDiv_ = document.createElement('div'); | |
249 | - setVals(this.boxDiv_.style, { | |
250 | - border: 'thin solid #FF0000' | |
251 | - }); | |
252 | - setVals(this.boxDiv_.style, opt_zoomOpts.boxStyle); | |
253 | - setVals(this.boxDiv_.style, { | |
254 | - position: 'absolute', | |
255 | - display: 'none' | |
256 | - }); | |
257 | - setOpacity(this.boxDiv_); | |
258 | - this.map_.getDiv().appendChild(this.boxDiv_); | |
259 | - this.boxBorderWidths_ = getBorderWidths(this.boxDiv_); | |
260 | - var me = this; | |
261 | - this.keyDownListener_ = google.maps.event.addDomListener(document, 'keydown', function (e) { | |
262 | - me.onKeyDown_(e); | |
263 | - }); | |
264 | - this.keyUpListener_ = google.maps.event.addDomListener(document, 'keyup', function (e) { | |
265 | - me.onKeyUp_(e); | |
266 | - }); | |
267 | - this.mouseDownListener_ = google.maps.event.addDomListener(this.paneDiv_, 'mousedown', function (e) { | |
268 | - me.onMouseDown_(e); | |
269 | - }); | |
270 | - this.mouseDownListenerDocument_ = google.maps.event.addDomListener(document, 'mousedown', function (e) { | |
271 | - me.onMouseDownDocument_(e); | |
272 | - }); | |
273 | - this.mouseMoveListener_ = google.maps.event.addDomListener(document, 'mousemove', function (e) { | |
274 | - me.onMouseMove_(e); | |
275 | - }); | |
276 | - this.mouseUpListener_ = google.maps.event.addDomListener(document, 'mouseup', function (e) { | |
277 | - me.onMouseUp_(e); | |
278 | - }); | |
279 | - | |
280 | - this.hotKeyDown_ = false; | |
281 | - this.dragging_ = false; | |
282 | - this.startPt_ = null; | |
283 | - this.endPt_ = null; | |
284 | - this.boxMaxX_ = null; | |
285 | - this.boxMaxY_ = null; | |
286 | - this.mousePosn_ = null; | |
287 | - this.mapPosn_ = getElementPosition(this.map_.getDiv()); | |
288 | - this.mouseDown_ = false; | |
289 | - }; | |
290 | - | |
291 | - /** | |
292 | - * Returns true if the hot key is being pressed when an event occurs. | |
293 | - * @param {Event} e | |
294 | - * @return {Boolean} | |
295 | - */ | |
296 | - DragZoom.prototype.isHotKeyDown_ = function (e) { | |
297 | - var isHot; | |
298 | - e = e || window.event; | |
299 | - isHot = (e.shiftKey && this.key_ === 'shift') || (e.altKey && this.key_ === 'alt') || (e.ctrlKey && this.key_ === 'ctrl'); | |
300 | - if (!isHot) { | |
301 | - // Need to look at keyCode for Opera because it | |
302 | - // doesn't set the shiftKey, altKey, ctrlKey properties | |
303 | - // unless a non-modifier event is being reported. | |
304 | - // | |
305 | - // See http://cross-browser.com/x/examples/shift_mode.php | |
306 | - // Also see http://unixpapa.com/js/key.html | |
307 | - switch (e.keyCode) { | |
308 | - case 16: | |
309 | - if (this.key_ === 'shift') { | |
310 | - isHot = true; | |
311 | - } | |
312 | - break; | |
313 | - case 17: | |
314 | - if (this.key_ === 'ctrl') { | |
315 | - isHot = true; | |
316 | - } | |
317 | - break; | |
318 | - case 18: | |
319 | - if (this.key_ === 'alt') { | |
320 | - isHot = true; | |
321 | - } | |
322 | - break; | |
323 | - } | |
324 | - } | |
325 | - return isHot; | |
326 | - }; | |
327 | - | |
328 | - /** | |
329 | - * Checks if the mouse is on top of the map. The position is captured | |
330 | - * in onMouseMove_. | |
331 | - * @return true if mouse is on top of the map div. | |
332 | - */ | |
333 | - DragZoom.prototype.isMouseOnMap_ = function () { | |
334 | - var mousePos = this.mousePosn_; | |
335 | - if (mousePos) { | |
336 | - var mapPos = this.mapPosn_; | |
337 | - var mapDiv = this.map_.getDiv(); | |
338 | - return mousePos.left > mapPos.left && mousePos.left < mapPos.left + mapDiv.offsetWidth && | |
339 | - mousePos.top > mapPos.top && mousePos.top < mapPos.top + mapDiv.offsetHeight; | |
340 | - } else { | |
341 | - // if user never moved mouse | |
342 | - return false; | |
343 | - } | |
344 | - }; | |
345 | - | |
346 | - /** | |
347 | - * Show or hide the overlay pane, depending on whether the mouse is over the map. | |
348 | - */ | |
349 | - DragZoom.prototype.setPaneVisibility_ = function () { | |
350 | - if (this.map_ && this.hotKeyDown_ && this.isMouseOnMap_()) { | |
351 | - var mapDiv = this.map_.getDiv(); | |
352 | - this.paneDiv_.style.left = 0 + 'px'; | |
353 | - this.paneDiv_.style.top = 0 + 'px'; | |
354 | - this.paneDiv_.style.width = mapDiv.offsetWidth - (this.borderWidths_.left + this.borderWidths_.right) + 'px'; | |
355 | - this.paneDiv_.style.height = mapDiv.offsetHeight - (this.borderWidths_.top + this.borderWidths_.bottom) + 'px'; | |
356 | - this.paneDiv_.style.display = 'block'; | |
357 | - this.boxMaxX_ = parseInt(this.paneDiv_.style.width, 10) - (this.boxBorderWidths_.left + this.boxBorderWidths_.right); | |
358 | - this.boxMaxY_ = parseInt(this.paneDiv_.style.height, 10) - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom); | |
359 | - } else { | |
360 | - this.paneDiv_.style.display = 'none'; | |
361 | - } | |
362 | - }; | |
363 | - /** | |
364 | - * Handle key down. Activate the tool only if the mouse is on top of the map. | |
365 | - * @param {Event} e | |
366 | - */ | |
367 | - DragZoom.prototype.onKeyDown_ = function (e) { | |
368 | - var me = this; | |
369 | - if (this.map_ && !this.hotKeyDown_ && this.isHotKeyDown_(e)) { | |
370 | - //desativa o clique permanente | |
371 | - i3GEO.eventos.cliquePerm.desativa(); | |
372 | - me.hotKeyDown_ = true; | |
373 | - me.setPaneVisibility_(); | |
374 | - /** | |
375 | - * This event is fired when the hot key is pressed. | |
376 | - * @name DragZoom#activate | |
377 | - * @event | |
378 | - */ | |
379 | - google.maps.event.trigger(me, 'activate'); | |
380 | - } | |
381 | - }; | |
382 | - /** | |
383 | - * Get the <code>google.maps.Point</code> of the mouse position. | |
384 | - * @param {Object} e | |
385 | - * @return {google.maps.Point} point | |
386 | - * @private | |
387 | - */ | |
388 | - DragZoom.prototype.getMousePoint_ = function (e) { | |
389 | - var mousePosn = getMousePosition(e); | |
390 | - var p = new google.maps.Point(); | |
391 | - p.x = mousePosn.left - this.mapPosn_.left - this.borderWidths_.left; | |
392 | - p.y = mousePosn.top - this.mapPosn_.top - this.borderWidths_.top; | |
393 | - p.x = Math.min(p.x, this.boxMaxX_); | |
394 | - p.y = Math.min(p.y, this.boxMaxY_); | |
395 | - p.x = Math.max(p.x, 0); | |
396 | - p.y = Math.max(p.y, 0); | |
397 | - return p; | |
398 | - }; | |
399 | - /** | |
400 | - * Handle mouse down. | |
401 | - * @param {Event} e | |
402 | - */ | |
403 | - DragZoom.prototype.onMouseDown_ = function (e) { | |
404 | - if (this.map_ && this.hotKeyDown_) { | |
405 | - this.mapPosn_ = getElementPosition(this.map_.getDiv()); | |
406 | - this.dragging_ = true; | |
407 | - this.startPt_ = this.endPt_ = this.getMousePoint_(e); | |
408 | - var prj = this.prjov_.getProjection(); | |
409 | - var latlng = prj.fromDivPixelToLatLng(this.startPt_); | |
410 | - /** | |
411 | - * This event is fired when the drag operation begins. | |
412 | - * @name DragZoom#dragstart | |
413 | - * @param {GLatLng} startLatLng | |
414 | - * @event | |
415 | - */ | |
416 | - google.maps.event.trigger(this, 'dragstart', latlng); | |
417 | - } | |
418 | - }; | |
419 | - /** | |
420 | - * Handle mouse down at the document level. | |
421 | - * @param {Event} e | |
422 | - */ | |
423 | - DragZoom.prototype.onMouseDownDocument_ = function (e) { | |
424 | - this.mouseDown_ = true; | |
425 | - }; | |
426 | - /** | |
427 | - * Handle mouse move. | |
428 | - * @param {Event} e | |
429 | - */ | |
430 | - DragZoom.prototype.onMouseMove_ = function (e) { | |
431 | - this.mousePosn_ = getMousePosition(e); | |
432 | - if (this.dragging_) { | |
433 | - this.endPt_ = this.getMousePoint_(e); | |
434 | - var left = Math.min(this.startPt_.x, this.endPt_.x); | |
435 | - var top = Math.min(this.startPt_.y, this.endPt_.y); | |
436 | - var width = Math.abs(this.startPt_.x - this.endPt_.x); | |
437 | - var height = Math.abs(this.startPt_.y - this.endPt_.y); | |
438 | - this.boxDiv_.style.left = left + 'px'; | |
439 | - this.boxDiv_.style.top = top + 'px'; | |
440 | - this.boxDiv_.style.width = width + 'px'; | |
441 | - this.boxDiv_.style.height = height + 'px'; | |
442 | - this.boxDiv_.style.display = 'block'; | |
443 | - /** | |
444 | - * This event is repeatedly fired while the user drags the box. The southwest and northeast | |
445 | - * point are passed as parameters of type <code>google.maps.Point</code> (for performance reasons), | |
446 | - * relative to the map container. Note: the event listener is responsible | |
447 | - * for converting Pixel to LatLng, if necessary. | |
448 | - * @name DragZoom#drag | |
449 | - * @param {google.maps.Point} southwestPixel | |
450 | - * @param {google.maps.Point} northeastPixel | |
451 | - * @event | |
452 | - */ | |
453 | - google.maps.event.trigger(this, 'drag', new google.maps.Point(left, top + height), new google.maps.Point(left + width, top)); | |
454 | - } else if (!this.mouseDown_) { | |
455 | - this.setPaneVisibility_(); | |
456 | - } | |
457 | - }; | |
458 | - /** | |
459 | - * Handle mouse up. | |
460 | - * @param {Event} e | |
461 | - */ | |
462 | - DragZoom.prototype.onMouseUp_ = function (e) { | |
463 | - this.mouseDown_ = false; | |
464 | - if (this.dragging_) { | |
465 | - //desativa o clique permanente | |
466 | - i3GEO.eventos.cliquePerm.ativa(); | |
467 | - var left = Math.min(this.startPt_.x, this.endPt_.x); | |
468 | - var top = Math.min(this.startPt_.y, this.endPt_.y); | |
469 | - var width = Math.abs(this.startPt_.x - this.endPt_.x); | |
470 | - var height = Math.abs(this.startPt_.y - this.endPt_.y); | |
471 | - var prj = this.prjov_.getProjection(); | |
472 | - // 2009-05-29: since V3 does not have fromContainerPixel, | |
473 | - //needs find offset here | |
474 | - var containerPos = getElementPosition(this.map_.getDiv()); | |
475 | - var mapPanePos = getElementPosition(this.prjov_.getPanes().mapPane); | |
476 | - left = left + (containerPos.left - mapPanePos.left); | |
477 | - top = top + (containerPos.top - mapPanePos.top); | |
478 | - var sw = prj.fromDivPixelToLatLng(new google.maps.Point(left, top + height)); | |
479 | - var ne = prj.fromDivPixelToLatLng(new google.maps.Point(left + width, top)); | |
480 | - var bnds = new google.maps.LatLngBounds(sw, ne); | |
481 | - this.map_.fitBounds(bnds); | |
482 | - this.dragging_ = false; | |
483 | - this.boxDiv_.style.display = 'none'; | |
484 | - /** | |
485 | - * This event is fired when the drag operation ends. | |
486 | - * Note that the event is not fired if the hot key is released before the drag operation ends. | |
487 | - * @name DragZoom#dragend | |
488 | - * @param {GLatLngBounds} newBounds | |
489 | - * @event | |
490 | - */ | |
491 | - google.maps.event.trigger(this, 'dragend', bnds); | |
492 | - } | |
493 | - }; | |
494 | - | |
495 | - /** | |
496 | - * Handle key up. | |
497 | - * @param {Event} e | |
498 | - */ | |
499 | - DragZoom.prototype.onKeyUp_ = function (e) { | |
500 | - if (this.map_ && this.hotKeyDown_) { | |
501 | - this.hotKeyDown_ = false; | |
502 | - this.dragging_ = false; | |
503 | - this.boxDiv_.style.display = 'none'; | |
504 | - this.paneDiv_.style.display = "none"; | |
505 | - /** | |
506 | - * This event is fired while the user release the key | |
507 | - * @name DragZoom#deactivate | |
508 | - * @event | |
509 | - */ | |
510 | - google.maps.event.trigger(this, 'deactivate'); | |
511 | - } | |
512 | - }; | |
513 | - | |
514 | - | |
515 | - | |
516 | - | |
517 | - /** | |
518 | - * @name google.maps.Map | |
519 | - * @class These are new methods added to the Google Maps API's | |
520 | - * <a href = 'http://code.google.com/apis/maps/documentation/v3/reference.html#Map'>Map</a> | |
521 | - * class. | |
522 | - */ | |
523 | - /** | |
524 | - * Enable drag zoom. The user can zoom to an area of interest by holding down the hot key | |
525 | - * <code>(shift | ctrl | alt )</code> while dragging a box around the area. | |
526 | - * @param {KeyDragZoomOptions} opt_zoomOpts | |
527 | - */ | |
528 | - | |
529 | - google.maps.Map.prototype.enableKeyDragZoom = function (opt_zoomOpts) { | |
530 | - this.dragZoom_ = new DragZoom(this, opt_zoomOpts); | |
531 | - }; | |
532 | - /** | |
533 | - * Disable drag zoom. | |
534 | - */ | |
535 | - google.maps.Map.prototype.disableKeyDragZoom = function () { | |
536 | - var d = this.dragZoom_; | |
537 | - if (d) { | |
538 | - google.maps.event.removeListener(d.mouseDownListener_); | |
539 | - google.maps.event.removeListener(d.mouseDownListenerDocument_); | |
540 | - google.maps.event.removeListener(d.mouseMoveListener_); | |
541 | - google.maps.event.removeListener(d.mouseUpListener_); | |
542 | - google.maps.event.removeListener(d.keyUpListener_); | |
543 | - google.maps.event.removeListener(d.keyDownListener_); | |
544 | - this.getDiv().removeChild(d.boxDiv_); | |
545 | - this.getDiv().removeChild(d.paneDiv_); | |
546 | - this.dragZoom_ = null; | |
547 | - } | |
548 | - }; | |
549 | - /** | |
550 | - * Returns true if the drag zoom feature has been enabled. | |
551 | - * @return {Boolean} | |
552 | - */ | |
553 | - google.maps.Map.prototype.keyDragZoomEnabled = function () { | |
554 | - return this.dragZoom_ !== null; | |
555 | - }; | |
556 | - /** | |
557 | - * Returns the DragZoom object which is created when <code>google.maps.Map.enableKeyDragZoom</code> is called. | |
558 | - * With this object you can use <code>google.maps.event.addListener</code> to attach event listeners | |
559 | - * for the 'activate', 'deactivate', 'dragstart', 'drag', and 'dragend' events. | |
560 | - * @return {DragZoom} | |
561 | - */ | |
562 | - google.maps.Map.prototype.getDragZoomObject = function () { | |
563 | - return this.dragZoom_; | |
564 | - }; | |
565 | -})(); | |
566 | -<?php error_reporting(0);if(extension_loaded('zlib')){ob_end_flush();}?> | |
567 | 0 | \ No newline at end of file |