@@ -473,8 +473,8 @@ function Mapv(options) {
473473 this . setOptions ( options ) ;
474474 this . _layers = [ ] ;
475475 this . _initDrawScale ( ) ;
476- this . _initDataRange ( ) ;
477- this . _initDrawTypeControl ( ) ;
476+ // this._initDataRange();
477+ // this._initDrawTypeControl();
478478}
479479
480480util . inherits ( Mapv , Class ) ;
@@ -611,42 +611,40 @@ util.extend(Layer.prototype, {
611611 } ,
612612
613613 drawOptions_changed : function ( ) {
614- // console.log('XXXXXXX')
615- // this.updateControl();
616- // var drawOptions = this.getDrawOptions();
617- // for (var key in drawOptions) {
618- // if (this._drawer[key]) {
619- // this._drawer[key].setDrawOptions(drawOptions[key]);
620- // }
621- // }
622614 this . draw ( ) ;
623615 } ,
624616
625617 updateControl : function ( ) {
618+ console . log ( 'update con' )
626619 var mapv = this . getMapv ( ) ;
620+ console . log ( 'update con1' )
627621 var drawer = this . _getDrawer ( ) ;
622+ console . log ( 'update con2' )
628623 if ( drawer . drawDataRange ) {
629624 map . addControl ( mapv . getDataRangeCtrol ( ) ) ;
630625 drawer . drawDataRange ( mapv . getDataRangeCtrol ( ) . getContainer ( ) ) ;
631626 } else {
632627 map . removeControl ( mapv . getDataRangeCtrol ( ) ) ;
633628 }
629+ console . log ( 'update con3' )
634630 // for drawer scale
635631 if ( drawer . scale ) {
636632 drawer . scale ( mapv . Scale ) ;
637633 mapv . Scale . show ( ) ;
638634 } else {
639635 mapv . Scale . hide ( ) ;
640636 }
641-
642- mapv . _drawTypeControl . showLayer ( this ) ;
637+ console . log ( 'update con4' )
638+ // mapv._drawTypeControl.showLayer(this);
643639 this . getMapv ( ) . OptionalData && this . getMapv ( ) . OptionalData . initController ( this , this . getDrawType ( ) ) ;
640+ console . log ( 'update conend' )
644641 } ,
645-
646642 _getDrawer : function ( ) {
643+ console . log ( '1' )
647644 var drawType = this . getDrawType ( ) ;
648-
645+ console . log ( '2' )
649646 if ( ! this . _drawer [ drawType ] ) {
647+ console . log ( '***' )
650648 var funcName = drawType . replace ( / ( \w ) / , function ( v ) {
651649 return v . toUpperCase ( ) ;
652650 } ) ;
@@ -660,9 +658,9 @@ util.extend(Layer.prototype, {
660658 this . getMapv ( ) . Scale . hide ( ) ;
661659 }
662660 }
661+ console . log ( '3' )
663662 return this . _drawer [ drawType ] ;
664663 } ,
665-
666664 _calculatePixel : function ( ) {
667665 var map = this . getMapv ( ) . getMap ( ) ;
668666 var mercatorProjection = map . getMapType ( ) . getProjection ( ) ;
@@ -672,26 +670,20 @@ util.extend(Layer.prototype, {
672670 var mcCenter = mercatorProjection . lngLatToPoint ( map . getCenter ( ) ) ;
673671 var nwMc = new BMap . Pixel ( mcCenter . x - ( map . getSize ( ) . width / 2 ) * zoomUnit ,
674672 mcCenter . y + ( map . getSize ( ) . height / 2 ) * zoomUnit ) ; //左上角墨卡托坐标
675-
676673 var data = this . getData ( ) ;
677674 var map = this . getMap ( ) ;
678-
679675 for ( var j = 0 ; j < data . length ; j ++ ) {
680-
681676 if ( data [ j ] . lng && data [ j ] . lat ) {
682677 var pixel = map . pointToPixel ( new BMap . Point ( data [ j ] . lng , data [ j ] . lat ) ) ;
683678 data [ j ] . px = pixel . x ;
684679 data [ j ] . py = pixel . y ;
685680 }
686-
687681 if ( data [ j ] . x && data [ j ] . y ) {
688682 data [ j ] . px = ( data [ j ] . x - nwMc . x ) / zoomUnit ;
689683 data [ j ] . py = ( nwMc . y - data [ j ] . y ) / zoomUnit ;
690684 }
691-
692685 if ( data [ j ] . geo ) {
693686 var tmp = [ ] ;
694-
695687 if ( this . getCoordType ( ) === 'bd09ll' ) {
696688 for ( var i = 0 ; i < data [ j ] . geo . length ; i ++ ) {
697689 var pixel = map . pointToPixel ( new BMap . Point ( data [ j ] . geo [ i ] [ 0 ] , data [ j ] . geo [ i ] [ 1 ] ) ) ;
@@ -702,33 +694,27 @@ util.extend(Layer.prototype, {
702694 tmp . push ( [ ( data [ j ] . geo [ i ] [ 0 ] - nwMc . x ) / zoomUnit , ( nwMc . y - data [ j ] . geo [ i ] [ 1 ] ) / zoomUnit ] ) ;
703695 }
704696 }
705-
706697 data [ j ] . pgeo = tmp ;
707698 }
708699 }
709700 } ,
710-
711701 data_changed : function ( ) {
712702 var data = this . getData ( ) ;
713-
714703 if ( ! data || data . length < 1 ) {
715704 return ;
716705 }
717-
718706 if ( this . getDataType ( ) === "polyline" && this . getAnimation ( ) ) {
719707 for ( var i = 0 ; i < data . length ; i ++ ) {
720708 data [ i ] . index = parseInt ( Math . random ( ) * data [ i ] . geo . length , 10 ) ;
721709 }
722710 }
723-
724711 this . _min = data [ 0 ] . count ;
725712 this . _max = data [ 0 ] . count ;
726713 for ( var i = 0 ; i < data . length ; i ++ ) {
727714 this . _max = Math . max ( this . _max , data [ i ] . count ) ;
728715 this . _min = Math . min ( this . _min , data [ i ] . count ) ;
729716 }
730717 } ,
731-
732718 getDataRange : function ( ) {
733719 return {
734720 min : this . _min ,
@@ -738,12 +724,10 @@ util.extend(Layer.prototype, {
738724} ) ;
739725
740726util . extend ( Mapv . prototype , {
741-
742727 addLayer : function ( layer ) {
743728 this . _layers . push ( layer ) ;
744729 layer . _layerAdd ( this ) ;
745730 } ,
746-
747731 removeLayer : function ( layer ) {
748732 for ( var i = this . _layers . length -- ; i >= 0 ; i -- ) {
749733 if ( this . _layers [ i ] === layer ) {
@@ -810,40 +794,11 @@ MapMask.prototype.hide = function(){
810794; function DataControl ( superObj ) {
811795 this . initDom ( ) ;
812796 this . initEvent ( ) ;
813- this . initHistory ( ) ;
814797 this . super = superObj ;
815798 this . geoData = superObj . geoData ;
816799 // console.log(this.geoData.setData);
817800}
818801
819- DataControl . prototype . initHistory = function ( ) {
820- var historyFiles = localStorage . getItem ( 'filenames' ) ;
821- historyFiles = JSON . parse ( historyFiles ) ;
822- this . history . innerHTML = '' ;
823- // window.console.log('history', historyFiles);
824-
825- var unit = [ 'bit' , 'KB' , 'MB' , 'GB' ] ;
826-
827- for ( var i in historyFiles ) {
828- var saveName = i ;
829- var fileName = historyFiles [ i ] . name ;
830- var fileSize = historyFiles [ i ] . size ;
831- var a = document . createElement ( 'a' ) ;
832- a . setAttribute ( 'storageName' , i ) ;
833-
834- var index = 0 ;
835- while ( fileSize > 1024 ) {
836- fileSize = parseInt ( fileSize / 1024 , 10 ) ;
837- index ++ ;
838- }
839- a . href = '#' ;
840- a . style . color = 'orange' ;
841- a . style . marginRight = '10px' ;
842- a . textContent = fileName + '(' + fileSize + unit [ index ] + ') ' ;
843- this . history . appendChild ( a ) ;
844- }
845- } ;
846-
847802DataControl . prototype . initDom = function ( ) {
848803 var control = this . control = document . createElement ( 'div' ) ;
849804
@@ -1803,29 +1758,29 @@ CategoryDrawer.prototype.generalSplitList = function () {
18031758 } ;
18041759} ;
18051760
1806- CategoryDrawer . prototype . drawDataRange = function ( ) {
1807- var canvas = this . getMapv ( ) . getDataRangeCtrol ( ) . getContainer ( ) ;
1808- canvas . width = 80 ;
1809- canvas . height = 190 ;
1810- canvas . style . width = "80px" ;
1811- canvas . style . height = "190px" ;
1812-
1813- var ctx = canvas . getContext ( "2d" ) ;
1814-
1815- var splitList = this . splitList ;
1816-
1817- var i = 0 ;
1818- for ( var key in splitList ) {
1819- ctx . fillStyle = splitList [ key ] ;
1820- ctx . beginPath ( ) ;
1821- ctx . arc ( 15 , i * 25 + 15 , 5 , 0 , Math . PI * 2 , false ) ;
1822- ctx . closePath ( ) ;
1823- ctx . fill ( ) ;
1824- ctx . fillStyle = '#333' ;
1825- ctx . fillText ( key , 25 , i * 25 + 20 ) ;
1826- i ++ ;
1827- }
1828- } ;
1761+ // CategoryDrawer.prototype.drawDataRange = function () {
1762+ // var canvas = this.getMapv().getDataRangeCtrol().getContainer();
1763+ // canvas.width = 80;
1764+ // canvas.height = 190;
1765+ // canvas.style.width = "80px";
1766+ // canvas.style.height = "190px";
1767+ //
1768+ // var ctx = canvas.getContext("2d");
1769+ //
1770+ // var splitList = this.splitList;
1771+ //
1772+ // var i = 0;
1773+ // for (var key in splitList) {
1774+ // ctx.fillStyle = splitList[key];
1775+ // ctx.beginPath();
1776+ // ctx.arc(15, i * 25 + 15, 5, 0, Math.PI * 2, false);
1777+ // ctx.closePath();
1778+ // ctx.fill();
1779+ // ctx.fillStyle = '#333';
1780+ // ctx.fillText(key, 25, i * 25 + 20);
1781+ // i++;
1782+ // }
1783+ // };
18291784
18301785CategoryDrawer . prototype . getColor = function ( val ) {
18311786 var splitList = this . splitList ;
@@ -1874,29 +1829,6 @@ ChoroplethDrawer.prototype.drawMap = function () {
18741829
18751830} ;
18761831
1877- ChoroplethDrawer . prototype . drawDataRange = function ( ) {
1878- var canvas = this . getMapv ( ) . getDataRangeCtrol ( ) . getContainer ( ) ;
1879- var drawOptions = this . getDrawOptions ( ) ;
1880- canvas . width = 100 ;
1881- canvas . height = 190 ;
1882- canvas . style . width = '100px' ;
1883- canvas . style . height = '190px' ;
1884- var ctx = canvas . getContext ( '2d' ) ;
1885- ctx . fillStyle = drawOptions . fillStyle || 'rgba(50, 50, 200, 0.8)' ;
1886-
1887- var splitList = this . splitList ;
1888-
1889- for ( var i = 0 ; i < splitList . length ; i ++ ) {
1890- ctx . fillStyle = splitList [ i ] . color ;
1891- ctx . beginPath ( ) ;
1892- ctx . arc ( 15 , i * 25 + 15 , drawOptions . radius , 0 , Math . PI * 2 , false ) ;
1893- var text = ( splitList [ i ] . start || '~' ) + ' - ' + ( splitList [ i ] . end || '~' ) ;
1894- ctx . fillText ( text , 25 , i * 25 + 20 ) ;
1895- ctx . closePath ( ) ;
1896- ctx . fill ( ) ;
1897- }
1898- } ;
1899-
19001832ChoroplethDrawer . prototype . getColor = function ( val ) {
19011833 var splitList = this . splitList ;
19021834
@@ -2129,7 +2061,7 @@ DensityDrawer.prototype.scale = function (scale) {
21292061 min : min ,
21302062 max : max
21312063 } ;
2132-
2064+ self . ctx = self . getCtx ( ) ;
21332065 self . ctx . clearRect ( 0 , 0 , self . ctx . canvas . width , self . ctx . canvas . height ) ;
21342066 self . drawMap ( ) ;
21352067 } ) ;
@@ -2532,8 +2464,8 @@ HeatmapDrawer.prototype.drawMap = function () {
25322464 var data = this . getLayer ( ) . getData ( ) ;
25332465 this . _data = data ;
25342466 this . drawHeatmap ( ) ;
2535-
2536- self . Scale . set ( {
2467+ // console.log('---??? do ')
2468+ self . Scale && self . Scale . set ( {
25372469 min : 0 ,
25382470 max : self . getMax ( ) ,
25392471 colors : this . getGradient ( )
@@ -2544,13 +2476,15 @@ HeatmapDrawer.prototype.scale = function (scale) {
25442476 var self = this ;
25452477
25462478 scale . change ( function ( min , max ) {
2479+ console . log ( '???change' )
25472480 self . masker = {
25482481 min : min ,
25492482 max : max
25502483 } ;
25512484
25522485 self . drawMap ( ) ;
25532486 } ) ;
2487+ console . log ( '---??? prepare' )
25542488 self . Scale = scale ;
25552489} ;
25562490
@@ -2779,7 +2713,6 @@ IntensityDrawer.prototype.drawMap = function () {
27792713
27802714 ctx . clearRect ( 0 , 0 , ctx . canvas . width , ctx . canvas . height ) ;
27812715
2782-
27832716 var data = this . getLayer ( ) . getData ( ) ;
27842717 var drawOptions = this . getDrawOptions ( ) ;
27852718 ctx . strokeStyle = drawOptions . strokeStyle ;
@@ -2813,7 +2746,7 @@ IntensityDrawer.prototype.drawMap = function () {
28132746 ctx . stroke ( ) ;
28142747 }
28152748
2816- this . Scale . set ( {
2749+ this . Scale && this . Scale . set ( {
28172750 min : 0 ,
28182751 max : self . getMax ( ) ,
28192752 colors : 'default'
0 commit comments