| 75 | | getScreenWidth: function(){ |
|---|
| | 70 | getBarLen: function(maxLen, units){ |
|---|
| | 71 | // produce set of thresholds (in metres) |
|---|
| | 72 | var thresholds = [1,2,5,10,20,50,100,200,500,1000,2000,5000, |
|---|
| | 73 | 10000,20000,50000,100000,200000,500000]; |
|---|
| | 74 | |
|---|
| 95 | | // scale = parseInt(scale); |
|---|
| 96 | | |
|---|
| 97 | | var extent = this.map.getExtent(); |
|---|
| 98 | | var width = extent.right - extent.left; |
|---|
| 99 | | |
|---|
| 100 | | // we just want the line to be about 10% of the width of the plot, so shrink it down. |
|---|
| 101 | | width /= 10; |
|---|
| 102 | | |
|---|
| 103 | | // produce set of thresholds (in metres) |
|---|
| 104 | | var thresholds = [1,2,5,10,20,50,100,200,500,1000,2000,5000, |
|---|
| 105 | | 10000,20000,50000,100000,200000,500000]; |
|---|
| 106 | | |
|---|
| 107 | | // convert width to metres |
|---|
| 108 | | var widthMetres = parseInt(width * 60 * 1852); |
|---|
| 109 | | var thisWidth; |
|---|
| 110 | | |
|---|
| 111 | | for(i=0;i<thresholds.length;i++) |
|---|
| 112 | | { |
|---|
| 113 | | var thisT = thresholds[i]; |
|---|
| 114 | | if(thisT > widthMetres) |
|---|
| 115 | | { |
|---|
| 116 | | break; |
|---|
| 117 | | } |
|---|
| 118 | | } |
|---|
| 119 | | |
|---|
| 120 | | // move down two sizes |
|---|
| 121 | | if(i > 2) |
|---|
| 122 | | { |
|---|
| 123 | | i -= 2; |
|---|
| 124 | | } |
|---|
| 125 | | |
|---|
| 126 | | thisWidth = thresholds[i]; |
|---|
| 127 | | |
|---|
| 128 | | // convert this width to back to degrees |
|---|
| 129 | | var thisWidthDegs = thisWidth / (60 * 1852) |
|---|
| | 97 | // and back to data units |
|---|
| | 98 | var barMetricDegs = barMetricKm / OpenLayers.INCHES_PER_UNIT["km"] * OpenLayers.INCHES_PER_UNIT["degrees"]; |
|---|
| | 99 | var barImperialDegs = barImperialMiles / OpenLayers.INCHES_PER_UNIT["mi"] * OpenLayers.INCHES_PER_UNIT["degrees"]; |
|---|
| 135 | | |
|---|
| 136 | | // if (scale >= 9500 && scale <= 950000) { |
|---|
| 137 | | // scale = Math.round(scale / 1000) + "K"; |
|---|
| 138 | | // } else if (scale >= 950000) { |
|---|
| 139 | | // scale = Math.round(scale / 1000000) + "M"; |
|---|
| 140 | | // } else { |
|---|
| 141 | | // scale = Math.round(scale); |
|---|
| 142 | | // } |
|---|
| 143 | | |
|---|
| 144 | | this.metric.style.width=thisWidthDegs / 5; |
|---|
| 145 | | this.imperial.style.width=140; |
|---|
| | 106 | this.metric.style.width= barMetricPx; |
|---|
| | 107 | this.imperial.style.width= barImperialPx; |
|---|