//"; GEvent.addDomListener(this.gridLogoDiv, "click", function() { map.LocaPointGrid.onoff(); }); this.map_.getContainer().appendChild(this.gridLogoDiv); GEvent.addListener(map, 'movestart', function() {map.LocaPointGrid.remove();} ); GEvent.addListener(map, 'moveend', function() {map.LocaPointGrid.redraw_manual();} ); GEvent.addListener(map, 'zoomend', function(oldZoomLevel, newZoomLevel) {map.LocaPointGrid.redraw_manual();} ); //Attach to resize //if (window.addEventListener) { // window.addEventListener("resize", map.LocaPointGrid.redraw_manual, false); //}else if (window.attachEvent) { // window.attachEvent("on"+"resize", map.LocaPointGrid.redraw_manual.resize); //} this.enableflag = false; map.LocaPointGrid.redraw_manual(); } LocaPointGrid.prototype.onoff = function() { if(this.enableflag){ this.enableflag=false; }else{ this.enableflag=true; } this.redraw_manual(); } LocaPointGrid.prototype.enable = function() { this.enableflag = true; this.redraw_manual(); } LocaPointGrid.prototype.disable = function() { this.enableflag = false; this.redraw_manual(); } LocaPointGrid.prototype.remove = function() { this.lpgridcanvas.innerHTML=""; this.lpgridrulercanvas.innerHTML=""; } LocaPointGrid.prototype.copy = function() { return new LocaPointGrid(); } LocaPointGrid.prototype.redraw = function(force) { return; } LocaPointGrid.prototype.redraw_manual = function(manualLPlevel) { this.remove(); if(this.enableflag==false){ return; } //Bounds in map pane var bnds = this.map_.getBounds(); if(bnds.isFullLng()){ return; } //min and max x and y pixel values for Map DIV for visual range var pbl = this.map_.fromLatLngToDivPixel(bnds.getSouthWest()); var ptr = this.map_.fromLatLngToDivPixel(bnds.getNorthEast()); var VisualRangeTL = this.map_.fromContainerPixelToLatLng(new GPoint(0,0)); //var VisualRangeBR = this.map_.fromContainerPixelToLatLng(new GPoint(ptr.x - pbl.x, pbl.y - ptr.y)); var mapsize = map.getSize(); var VisualRangeBR = this.map_.fromContainerPixelToLatLng(new GPoint(mapsize.width, mapsize.height)); if(bnds.isFullLng()){ VisualRangeBR = new GLatLng(-180, 180+360+360, true); }else if (VisualRangeTL.lng() > VisualRangeBR.lng()){//over INTL' date line VisualRangeBR = new GLatLng(VisualRangeBR.lat(), VisualRangeBR.lng()+360, true); } //alert((bnds.isFullLng()?("Full Lat"):(" Not FUll Lat")) + "\n" // + bnds.getSouthWest().lng() + " to " + bnds.getNorthEast().lng() + "\n" // + pbl.x + " to " + ptr.x + "\n" // + VisualRangeTL.lng() + " to " + VisualRangeBR.lng() // ); var level = manualLPlevel-0; if(level!=1 && level!=2 && level!=3 && level!=4 && level!=5 && level!=6){ level = this.getLPGridAutoLevel(); } this.DrawLocaPointGrid(VisualRangeTL, VisualRangeBR, level); return; } LocaPointGrid.prototype.AppendDiv = function(left, top, width, height,bgcolor, color, opacity){ var d = document.createElement("DIV"); var s = d.style; s.position = "absolute"; s.overflow = "hidden"; s.left = left + "px"; s.top = top + "px"; s.width = (width!=""?width:"1")+"px"; s.height = (height!=""?height:"1")+"px"; s.backgroundColor = (bgcolor!=""?bgcolor:"#8888FF"); s.color = (color!=""?color:"#FFFFFF"); s.opacity = opacity/10; s.filter = 'alpha(opacity=' + opacity*10 + ')'; this.lpgridcanvas.appendChild(d); } LocaPointGrid.prototype.AppendDivRuler = function(left, top, width, height,bgcolor, color, opacity, htmltext, Vallign, Hallign){ var d = document.createElement("DIV"); var s = d.style; s.position = "absolute"; s.overflow = "hidden"; s.left = left + "px"; s.top = top + "px"; s.width = (width!=""?width:"1")+"px"; s.height = (height!=""?height:"1")+"px"; s.backgroundColor = (bgcolor!=""?bgcolor:"#8888FF"); s.color = (color!=""?color:"#FFFFFF"); s.fontFamily='Arial'; s.fontSize='x-small'; //s.font = "6px Arial; //'Courier New', Courier, monospace"; s.opacity = opacity/10; s.filter = 'alpha(opacity=' + opacity*10 + ')'; d.innerHTML = "
" + htmltext + "
"; this.lpgridrulercanvas.appendChild(d); } LocaPointGrid.prototype.DrawLocaPointGrid = function(VisualRangeTL, VisualRangeBR, gridlevel){ if(gridlevel>3){ this.DrawLocaPointGrid(VisualRangeTL, VisualRangeBR, 3); } //Constants var unitStep = Array(1757600, 67600, 6760, 260, 10, 1); var ast = "*"; var CHARWIDTH = 5; var LatLpInt, LonLpInt; var startLatInt = (VisualRangeTL.lat() +90)/180*45697600; var endLatInt = (VisualRangeBR.lat() +90)/180*45697600; var startLonInt = (VisualRangeTL.lng() +180)/360*45697600; var endLonInt = (VisualRangeBR.lng() +180)/360*45697600; var LatDone = false; var LonDone = false; var startPx = this.map_.fromLatLngToDivPixel(VisualRangeTL); // if(map.getBounds().isFullLng()){ // startPx = this.map_.fromLatLngToDivPixel(new GLatLng(VisualRangeTL.lat(), VisualRangeTL.lng()-360)); // } var endPx = this.map_.fromLatLngToDivPixel(VisualRangeBR); //alert("startPx= " + startPx.x + " endPx= " + endPx.x); // if(startPx.x > endPx.x){ // var WendPx = this.map_.fromLatLngToDivPixel(GLatLng(-180,0)); // var EendPx = this.map_.fromLatLngToDivPixel(GLatLng(180,0)); // endPx.x += (EendPx.x - WendPx.x); // } var LatRulerLeft = gridlevel<=3?(startPx.x):(startPx.x - 0 + CHARWIDTH*4 + 1); var LonRulerTop = gridlevel<=3?(startPx.y):(startPx.y - 0 + CHARWIDTH*2 + 1); var delta = unitStep[gridlevel -1]; LatLpInt = (Math.floor(endLatInt/delta)) * delta; LonLpInt = (Math.floor(startLonInt/delta)) * delta; this.color_ = this.map_.getCurrentMapType().getTextColor(); while(LatDone==false || LonDone==false){ //calc pixcels var targetPx = this.map_.fromLatLngToDivPixel(new GLatLng((LatLpInt/45697600)*180-90,((LonLpInt)/45697600)*360-180)); var nextPx = this.map_.fromLatLngToDivPixel(new GLatLng(((LatLpInt+delta)/45697600)*180-90,((LonLpInt+delta)/45697600)*360-180)); //Latitude Lines if(LatDone==false){ sY = startPx.y -0; eY = endPx.y - 0; tgY = targetPx.y - 0; nxY = nextPx.y - 0; var notagLat = false; //locapoint strings var a1 = String.fromCharCode((LatLpInt/unitStep[0]%26)+65); var a2 = String.fromCharCode((LatLpInt/unitStep[1]%26)+65); var a3 = String.fromCharCode((LatLpInt/unitStep[2]%10)+48); var l1 = String.fromCharCode((LatLpInt/unitStep[3]%26)+65); var l2 = String.fromCharCode((LatLpInt/unitStep[4]%26)+65); var l3 = String.fromCharCode((LatLpInt/unitStep[5]%10)+48); var areatext = "" + a1 + (gridlevel<2?ast:a2) + (gridlevel<3?ast:a3); var localtext = "" + l1 + (gridlevel<5?ast:l2) + (gridlevel<6?ast:l3); var htmltext = (gridlevel>3)?localtext:areatext; var lineStartPx = (gridlevel>3 && l1!="A")?(startPx.x- 0 + CHARWIDTH*4 + 2):(startPx.x-0); this.AppendDiv(lineStartPx, targetPx.y, endPx.x-lineStartPx , 1, this.color_, this.color_, this.lineopacity); if(eY3)?localtext:areatext; var lineStartPx = (gridlevel>3 && l1!="A")?(startPx.y - 0 + CHARWIDTH*2 + 1):(startPx.y-0); this.AppendDiv(targetPx.x, lineStartPx, 1, endPx.x-lineStartPx , this.color_, this.color_, this.lineopacity); if(nxX