Changeset 442


Ignore:
Timestamp:
Jan 14, 2007, 2:56:51 PM (13 years ago)
Author:
Nick Burch
Message:

Work with tiles > 999

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/static/tiles/mapTiles.js

    r430 r442  
    310310// Need to use substring for IE, and it doesn't take negative numbers.
    311311function trimNumber(string) {
    312   str = '000' + string
     312        // If we have a 4 digit number, no need to do any padding
     313        if(parseInt(string) >= 1000) { return string; }
     314
     315        // Pad it so that it'll always have leading 0s, and be at least 3 long
     316        str = '000' + string
     317        // Grab the right most 3 digits, which will have any required padding
    313318        return str.substring(str.length -3)
    314319}
    315320
    316321function trimSixDigits(string) {
    317   str = '000000' + string
     322        // If we have a 7 digit number, no need to do any padding
     323        if(parseInt(string) >= 1000000) { return string; }
     324
     325        // Pad it so that it'll always have leading 0s, and be at least 6 long
     326        str = '000000' + string
     327        // Grab the right most 6 digits, which will have any required padding
    318328        return str.substring(str.length -6)
    319329}
Note: See TracChangeset for help on using the changeset viewer.