- Timestamp:
- Jul 24, 2007, 9:51:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gpx.npemap.org.uk/js/mapTiles.js
r451 r568 7 7 var sizeGridX = 6; // Size of visible grid (table) in each dimension 8 8 var sizeGridY = 4; // Size of visible grid (table) in each dimension 9 10 var minY = -86; // Minimum Y at scale 1 9 11 10 12 var tileWidth = 125; … … 196 198 197 199 198 // Need to use substring for IE, and it doesn't take negative numbers. 200 // Need to use substring for IE 201 // Pads to 3 digits with zeros, or - and 2 digits 199 202 function trimNumber(string) { 200 // If we have a 4 digit number, no need to do any padding 201 if(parseInt(string) >= 1000) { return string; } 203 // If we have a 3+ digit number, no need to do any padding 204 if(parseInt(string) >= 100) { return string; } 205 // Or a 2+ digit negative number, no need to do any padding 206 if(parseInt(string) <= -10) { return string; } 207 208 // Special case for 1 digit negative numbers 209 if(parseInt(string) <= 0) { 210 var num = parseInt(string); 211 return '-0' + (0-num); 212 } 202 213 203 214 // Pad it so that it'll always have leading 0s, and be at least 3 long … … 208 219 209 220 function trimSixDigits(string) { 210 // If we have a 7 digit number, no need to do any padding 211 if(parseInt(string) >= 1000000) { return string; } 221 // If we have a 6+ digit number, no need to do any padding 222 if(parseInt(string) >= 100000) { return string; } 223 // Or a 5+ digit negative number, no need to do any padding 224 if(parseInt(string) <= -10000) { return string; } 225 226 // Is it negative? 227 var num = parseInt(string) 228 var isNegative = (num < 0); 229 if(isNegative) { 230 num = 0 - num; 231 } 212 232 213 233 // Pad it so that it'll always have leading 0s, and be at least 6 long 214 str = '000000' + string234 str = '000000' + num; 215 235 // Grab the right most 6 digits, which will have any required padding 216 return str.substring(str.length -6) 217 } 236 str = str.substring(str.length -6) 237 // Add back in - at start if needed 238 if(isNegative) { 239 str = '-' + str.substring(1); 240 } 241 return str; 242 } 243 218 244 219 245 function refreshGrid() { … … 281 307 } 282 308 else if ( theDirection == 'down' ) { 283 if ( offsetGridY > 0)309 if ( offsetGridY > Math.round(minY / zooms[zoomLevel]) ) 284 310 offsetGridY --; 285 311 }
Note: See TracChangeset
for help on using the changeset viewer.