// joyzoom control function NewCtrlJoyZoom(map, ctrlJoyZoom) { var ctrl = this; var imageThis = this; ctrl.hndzoomend = null; ctrl.hndgradend = null; ctrl.map = map; ctrl.mapi = null; ctrl.zoommin = 5; ctrl.zoommax = 19; ctrl.isongps = false; ctrl.poslat = '-'; ctrl.poslng = '-'; ctrl.posh = '-'; ctrl.mapclicklistener = null; ctrl.node = ctrlJoyZoom; ctrl.node.style.position = "absolute"; ctrl.node.style.left = '0px'; ctrl.nodebkg = document.createElement('div'); ctrl.nodebkg.style.position = "absolute"; ctrl.nodebkg.style.cursor = "default"; ctrl.nodebkg.style.backgroundAttachment = 'scroll'; ctrl.nodebkg.style.backgroundClip = ''; ctrl.nodebkg.style.backgroundColor = 'transparent'; ctrl.nodebkg.style.backgroundImage = 'url("http://www.kamennimuzici.cz/images/bg_tools.png")'; ctrl.nodebkg.style.backgroundOrigin = ''; ctrl.nodebkg.style.backgroundPosition = '0% 0%'; ctrl.nodebkg.style.backgroundRepeat = 'repeat'; ctrl.nodebkg.style.backgroundSize = ''; ctrl.nodebkg.style.marginTop = "0px"; ctrl.nodebkg.style.marginLeft = "0px"; ctrl.nodebkg.style.width = "296px"; ctrl.nodebkg.style.height = (85)+"px"; ctrl.node.appendChild(ctrl.nodebkg); ctrl.nodebtncenter = document.createElement('div'); ctrl.nodebtncenter.style.position = "absolute"; ctrl.nodebtncenter.style.width = "22px"; ctrl.nodebtncenter.style.height = "23px"; ctrl.nodebtncenter.style.marginTop = "31px"; ctrl.nodebtncenter.style.marginLeft = "31px"; ctrl.nodebtncenter.style.backgroundColor = "#FFFFFF"; ctrl.nodebtncenter.style.cursor = "default"; ctrl.node.appendChild(ctrl.nodebtncenter); ctrl.nodebtnup = document.createElement('div'); ctrl.nodebtnup.style.position = "absolute"; ctrl.nodebtnup.style.width = "22px"; ctrl.nodebtnup.style.height = "21px"; ctrl.nodebtnup.style.marginTop = "10px"; ctrl.nodebtnup.style.marginLeft = "32px"; ctrl.nodebtnup.style.background = "url('http://www.kamennimuzici.cz/images/nav_up.png')"; ctrl.nodebtnup.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtnup); ctrl.nodebtnleft = document.createElement('div'); ctrl.nodebtnleft.style.position = "absolute"; ctrl.nodebtnleft.style.width = "22px"; ctrl.nodebtnleft.style.height = "23px"; ctrl.nodebtnleft.style.marginTop = "31px"; ctrl.nodebtnleft.style.marginLeft = "10px"; ctrl.nodebtnleft.style.background = "url('http://www.kamennimuzici.cz/images/nav_left.png')"; ctrl.nodebtnleft.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtnleft); ctrl.nodebtnright = document.createElement('div'); ctrl.nodebtnright.style.position = "absolute"; ctrl.nodebtnright.style.width = "22px"; ctrl.nodebtnright.style.height = "23px"; ctrl.nodebtnright.style.marginTop = "31px"; ctrl.nodebtnright.style.marginLeft = "53px"; ctrl.nodebtnright.style.background = "url('http://www.kamennimuzici.cz/images/nav_right.png')"; ctrl.nodebtnright.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtnright); ctrl.nodebtndown = document.createElement('div'); ctrl.nodebtndown.style.position = "absolute"; ctrl.nodebtndown.style.width = "22px"; ctrl.nodebtndown.style.height = "23px"; ctrl.nodebtndown.style.marginTop = "52px"; ctrl.nodebtndown.style.marginLeft = "32px"; ctrl.nodebtndown.style.background = "url('http://www.kamennimuzici.cz/images/nav_down.png')"; ctrl.nodebtndown.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtndown); ctrl.nodebtnzoomtop = document.createElement('div'); ctrl.nodebtnzoomtop.style.position = "absolute"; ctrl.nodebtnzoomtop.style.width = "18px"; ctrl.nodebtnzoomtop.style.height = "7px"; ctrl.nodebtnzoomtop.style.marginTop = "107px"; ctrl.nodebtnzoomtop.style.marginLeft = "34px"; ctrl.nodebtnzoomtop.style.background = "url('http://www.kamennimuzici.cz/images/nav_zoomtop.png')"; //ctrl.node.appendChild(ctrl.nodebtnzoomtop); ctrl.nodebtnzoomin = document.createElement('div'); ctrl.nodebtnzoomin.style.position = "absolute"; ctrl.nodebtnzoomin.style.width = "23px"; ctrl.nodebtnzoomin.style.height = "22px"; ctrl.nodebtnzoomin.style.marginTop = "10px"; ctrl.nodebtnzoomin.style.marginLeft = "90px"; ctrl.nodebtnzoomin.style.background = "url('http://www.kamennimuzici.cz/images/nav_zoomin.png')"; ctrl.nodebtnzoomin.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtnzoomin); ctrl.nodebtnzoomlvl = new Array(); for (var ti = ctrl.zoommin; ti <= ctrl.zoommax; ti++) { var ti2 = ctrl.nodebtnzoomlvl.length; ctrl.nodebtnzoomlvl[ti2] = document.createElement('div'); ctrl.nodebtnzoomlvl[ti2].style.position = "absolute"; ctrl.nodebtnzoomlvl[ti2].style.width = "18px"; ctrl.nodebtnzoomlvl[ti2].style.height = "9px"; ctrl.nodebtnzoomlvl[ti2].style.marginTop = (113 + ti2 * 9)+"px"; ctrl.nodebtnzoomlvl[ti2].style.marginLeft = "34px"; ctrl.nodebtnzoomlvl[ti2].style.background = "url('http://www.kamennimuzici.cz/images/nav_zoomi.png')"; //ctrl.node.appendChild(ctrl.nodebtnzoomlvl[ti2]); } ctrl.nodebtnzoombottom = document.createElement('div'); ctrl.nodebtnzoombottom.style.position = "absolute"; ctrl.nodebtnzoombottom.style.width = "18px"; ctrl.nodebtnzoombottom.style.height = "7px"; ctrl.nodebtnzoombottom.style.marginTop = (113 + (ctrl.zoommax - ctrl.zoommin + 1) * 9)+"px"; ctrl.nodebtnzoombottom.style.marginLeft = "34px"; ctrl.nodebtnzoombottom.style.background = "url('http://www.kamennimuzici.cz/images/nav_zoombot.png')"; //ctrl.node.appendChild(ctrl.nodebtnzoombottom); ctrl.nodebtnzoomout = document.createElement('div'); ctrl.nodebtnzoomout.style.position = "absolute"; ctrl.nodebtnzoomout.style.width = "23px"; ctrl.nodebtnzoomout.style.height = "22px"; ctrl.nodebtnzoomout.style.marginTop = (55)+"px"; ctrl.nodebtnzoomout.style.marginLeft = "90px"; ctrl.nodebtnzoomout.style.background = "url('http://www.kamennimuzici.cz/images/nav_zoomout.png')"; ctrl.nodebtnzoomout.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtnzoomout); ctrl.nodebtnzoomsliderbound = document.createElement('div'); ctrl.nodebtnzoomsliderbound.style.position = "absolute"; ctrl.nodebtnzoomsliderbound.style.width = "25px"; ctrl.nodebtnzoomsliderbound.style.height = ((ctrl.zoommax - ctrl.zoommin + 1) * 9)+"px"; ctrl.nodebtnzoomsliderbound.style.marginTop = "113px"; ctrl.nodebtnzoomsliderbound.style.marginLeft = "30px"; ctrl.nodebtnzoomsliderbound.style.cursor = "pointer"; //ctrl.node.appendChild(ctrl.nodebtnzoomsliderbound); ctrl.nodebtnzoomslider = document.createElement('div'); ctrl.nodebtnzoomslider.style.position = "absolute"; ctrl.nodebtnzoomslider.style.width = "28px"; ctrl.nodebtnzoomslider.style.height = "13px"; ctrl.nodebtnzoomslider.style.background = "url('http://www.kamennimuzici.cz/images/nav_zoomact.png')"; //ctrl.nodebtnzoomsliderbound.appendChild(ctrl.nodebtnzoomslider); ctrl.nodebtngps = document.createElement('div'); ctrl.nodebtngps.style.position = "absolute"; ctrl.nodebtngps.style.width = "52px"; ctrl.nodebtngps.style.height = "33px"; ctrl.nodebtngps.style.background = "url('http://www.kamennimuzici.cz/images/gps.png')"; ctrl.nodebtngps.style.marginTop = (10) + 'px'; ctrl.nodebtngps.style.marginLeft = "150px"; ctrl.nodebtngps.style.cursor = "pointer"; ctrl.node.appendChild(ctrl.nodebtngps); ctrl.nodebtnpos = document.createElement('div'); ctrl.nodebtnpos.style.position = "absolute"; ctrl.nodebtnpos.style.display = "none"; ctrl.nodebtnpos.style.color = "#F0F0FF"; ctrl.nodebtnpos.style.backgroundColor = "#729332"; ctrl.nodebtnpos.style.border = "1px solid #FFFFFF"; ctrl.nodebtnpos.style.padding = "3px"; ctrl.nodebtnpos.style.marginTop = (50) + 'px'; ctrl.nodebtnpos.style.marginLeft = (150) + 'px'; ctrl.nodebtnpos.style.whiteSpace = 'nowrap'; ctrl.nodebtnpos.innerHTML = 'Klikněte na pozici v mapě'; ctrl.node.appendChild(ctrl.nodebtnpos); ctrl.nodebtncenterZoom = document.createElement('div'); ctrl.nodebtncenterZoom.style.position = "absolute"; ctrl.nodebtncenterZoom.style.width = "22px"; ctrl.nodebtncenterZoom.style.height = "22px"; ctrl.nodebtncenterZoom.style.marginTop = "32px"; ctrl.nodebtncenterZoom.style.marginLeft = "90px"; ctrl.nodebtncenterZoom.style.backgroundColor = "#FFFFFF"; ctrl.nodebtncenterZoom.style.cursor = "default"; ctrl.nodebtncenterZoom.style.textAlign = "center"; ctrl.nodebtncenterZoom.style.verticalAlign = "center"; ctrl.nodebtncenterZoom.style.fontWeight = "bolder"; ctrl.nodebtncenterZoom.innerHTML = this.map.gmap.getZoom();; ctrl.node.appendChild(ctrl.nodebtncenterZoom); ctrl.printable = function() { return false; } ctrl.selectable = function() { return false; } ctrl.zoomend = function() { this.nodebtncenterZoom.innerHTML = this.map.gmap.getZoom(); //var zl = nl; //if (this.zoommax < zl) zl = this.zoommax; //if (this.zoommin > zl) zl = this.zoommin; //this.nodebtnzoomsliderdrg.moveTo(new GPoint(0, (ctrl.zoommax - zl) * 9)); } ctrl.dragend = function() { var h = this.nodebtnzoomslider.style.top.replace(/px/g, ""); var zl = this.zoommax - Math.round(h / 9); if (this.zoommax < zl) zl = this.zoommax; if (this.zoommin > zl) zl = this.zoommin; this.map.gmap.setZoom(zl); return true; } ctrl.zoomclick = function(a, b) { var h = (a.layerY?a.layerY:a.offsetY) - 5; var zl = this.zoommax - Math.round(h / 9); if (this.zoommax < zl) zl = this.zoommax; if (this.zoommin > zl) zl = this.zoommin; this.map.gmap.setZoom(zl); } ctrl.panDirectionUp = function() { this.map.gmap.panBy(0, 10); } ctrl.panDirectionDown = function() { this.map.gmap.panBy(0, -10); } ctrl.panDirectionLeft = function() { this.map.gmap.panBy(10, 0); } ctrl.panDirectionRight = function() { this.map.gmap.panBy(-10, 0) } ctrl.zoomout = function() { zl = this.map.gmap.getZoom(); if (this.zoommin < zl) this.map.gmap.setZoom(zl-1); } ctrl.zoomin = function() { zl = this.map.gmap.getZoom(); if (this.zoommax > zl) this.map.gmap.setZoom(zl+1); } ctrl.flipGPS = function() { if (this.isongps) { this.hideGPS(); } else { this.showGPS(); } } ctrl.hideGPS = function() { this.nodebtnpos.style.display = 'none'; this.isongps = false; } ctrl.showGPS = function() { this.nodebtnpos.style.display = 'block'; this.isongps = true; } ctrl.updateGPS = function() { var pos = 'Klikněte na pozici v mapě'; if (this.poslat != '-') { var pos = DtoDMS(this.poslat) + ', ' + DtoDMS(this.poslng); if (this.posh != '-') pos+= ' (' + this.posh + 'm)'; } this.nodebtnpos.innerHTML = pos; } ctrl.onMapClick = function(e) { latlng = e.latLng; //PJ if (latlng) { this.poslat = latlng.lat(); this.poslng = latlng.lng(); this.updateGPS(); this.updateGPSHeight(); } } ctrl.foundGPSHeight = function(data) { if (data.charAt(0) == 'H') { this.posh = data.substr(1); } else { this.posh = '-'; } this.updateGPS(); } ctrl.errorGPSHeight = function() { this.posh = '-'; this.updateGPS(); } ctrl.completeGPSHeight = function() { } ctrl.updateGPSHeight = function() { addCallback(callbacktype.gpsheightsuccess, this, this.foundGPSHeight); addCallback(callbacktype.gpsheightcomplete, this, this.completeGPSHeight); addCallback(callbacktype.gpsheighterror, this, this.errorGPSHeight); var url = 'getpointheight.php?lat=' + this.poslat + '&lng=' + this.poslng; jQuery.ajax({cache:false, error:function() { runCallback(callbacktype.gpsheighterror, ''); }, success:function(data) { runCallback(callbacktype.gpsheightsuccess, data); }, complete:function() { runCallback(callbacktype.gpsheightcomplete, ''); }, url:url}); } if (ctrl.mapclicklistener) google.maps.event.removeListener(ctrl.mapclicklistener); ctrl.mapclicklistener = google.maps.event.addListener(this.map.gmap, "click", function(e) {ctrl.onMapClick(e);}); google.maps.event.clearInstanceListeners(ctrl.nodebtnup); google.maps.event.addDomListener(ctrl.nodebtnup, "click", function() {ctrl.panDirectionUp();}); google.maps.event.clearInstanceListeners(ctrl.nodebtnleft); google.maps.event.addDomListener(ctrl.nodebtnleft, "click", function() {ctrl.panDirectionLeft();}); google.maps.event.clearInstanceListeners(ctrl.nodebtnright); google.maps.event.addDomListener(ctrl.nodebtnright, "click", function() {ctrl.panDirectionRight();}); google.maps.event.clearInstanceListeners(ctrl.nodebtndown); google.maps.event.addDomListener(ctrl.nodebtndown, "click", function() {ctrl.panDirectionDown();}); google.maps.event.clearInstanceListeners(ctrl.nodebtnzoomin); google.maps.event.addDomListener(ctrl.nodebtnzoomin, "click", function() {ctrl.zoomin();}); google.maps.event.clearInstanceListeners(ctrl.nodebtnzoomout); google.maps.event.addDomListener(ctrl.nodebtnzoomout, "click", function() {ctrl.zoomout();}); //google.maps.event.clearInstanceListeners(ctrl.nodebtnzoomsliderbound); //google.maps.event.addDomListener(ctrl.nodebtnzoomsliderbound, "mousedown", function() {ctrl.zoomclick();}); google.maps.event.clearInstanceListeners(ctrl.nodebtngps); google.maps.event.addDomListener(ctrl.nodebtngps, "click", function() {ctrl.flipGPS();}); //this.nodebtnzoomsliderdrg = new GDraggableObject(this.nodebtnzoomslider, {left: 0, top: 0, container: this.nodebtnzoomsliderbound}); //this.hndgradend = GEvent.bind(this.nodebtnzoomsliderdrg, "dragend", this, this.dragend); if (ctrl.hndzoomend != null) google.maps.event.removeListener(ctrl.hndzoomend); ctrl.hndzoomend = google.maps.event.bind(map.gmap, "zoom_changed", this, function() {this.zoomend();} ); //var zl = ctrl.map.getZoom(); //if (this.zoommax < zl) zl = this.zoommax; //if (this.zoommin > zl) zl = this.zoommin; //this.nodebtnzoomsliderdrg.moveTo(new GPoint(0, (ctrl.zoommax - zl) * 9)); return ctrl; } // menu item function MenuItem(name, callback) { var names = ["KRESLENÍ TRASY","DETAILY TRASY","ZÁJMOVÉ BODY","VRSTVY MAPY","HLEDÁNÍ V MAPĚ","HLEDÁNÍ TRAS"]; this.name = names[name]; this.callback = callback; this.select = function () { this.node.getElementsByTagName('a')[0].className = 'active'; } this.unSelect = function () { this.node.getElementsByTagName('a')[0].className = ''; } } // menu control function NewCtrlMenu(map) { var ctrl = this; var imageThis = this; ctrl.map = map; ctrl.mapi = null; ctrl.items = new Array(); ctrl.node = document.createElement('div'); ctrl.node.style.position = "absolute"; ctrl.node.style.left = "0px"; ctrl.node.style.right = "0px"; ctrl.nodebkg = document.createElement('div'); ctrl.nodebkg.id = 'menu'; ctrl.node.appendChild(ctrl.nodebkg); ctrl.nodecontainer = document.createElement('ul'); ctrl.nodebkg.appendChild(ctrl.nodecontainer); ctrl.nodehome = document.createElement('li'); ctrl.nodehome.className = 'm0'; ctrl.nodehome.innerHTML = 'Kamenní mužíci'; ctrl.nodecontainer.appendChild(ctrl.nodehome); google.maps.event.addDomListener(ctrl.nodehome, "click", function(e) { if (confirm('Opravdu si přejte opustit mapovou aplikaci? Všechny neuložené změny budou ztraceny.')) { return true; } else { try { e.preventDefault(); } catch (ex) { } return false; } }); ctrl.nodeprint = document.createElement('span'); ctrl.nodeprint.id = 'print'; ctrl.nodeprint.style.cursor = 'pointer'; ctrl.nodebkg.appendChild(ctrl.nodeprint); ctrl.nodehr = document.createElement('hr'); ctrl.nodebkg.appendChild(ctrl.nodehr); ctrl.printable = function() { return false; } ctrl.selectable = function() { return false; } //initialize google.maps.event.clearInstanceListeners(this.nodeprint); google.maps.event.addDomListener(this.nodeprint, "mousedown", function() {imageThis.mapi.print.call(imageThis);}); //end init ctrl.addItem = function(item) { item.node = document.createElement('li'); item.node.innerHTML = '' + item.name + ''; ctrl.nodecontainer.appendChild(item.node); google.maps.event.clearInstanceListeners(item.node); google.maps.event.addDomListener(item.node, 'click', item.click); ctrl.items.push(item); } return ctrl; } // CONTROL PANEL function NewCtrlPanel(map) { var ctrl = new Object(); ctrl.map = map; ctrl.mapi = null; ctrl.visible = true; ctrl.activetool = null; ctrl.defaulttool = null; ctrl.toolbanner = null; ctrl.items = new Array(); try { ctrl.node = document.createElement('