1.1.1 • Published 4 years ago

ascii-worldmap v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

ASCII-WorldMap

Want to show where your team mates are around the world? But think Google's API is just way too practical?

Just use ASCII!

You can add markers to the map, or just return the map plain. There are added options for a border, padding and margins, just like css.

Basic Usage

See a demo on RunKit

import { drawMap } from "ascii-worldmap"

// you can ignore the icon and label fields, logo defaults to "#", label is unused
const markers = [
    { label: "London", lon: -0.192098, lat: 51.610002, icon: "\x1b[31m#\x1b[39m" },
    { label: "LA", lon: -118.441495, lat: 33.929047, icon: "\x1b[31m#\x1b[39m" },
    { label: "CHCH", lon: 172.63623, lat: -43.532055, icon: "\x1b[31m#\x1b[39m" }
];

const config = {
    border: true,
    margin: 2,
    padding: 2
}

console.log(drawMap(markers, config));

Screenshot

Docs

drawMap( markers: object, config: object, timeZoneOverlay )

markers (optional)

attributetypedescription
lonnumberLongitude
latnumberLatitude
labelstringLabel (Currently unsused)
icon (optionsl)stringIcon used when drawing to the map Defaults to "#"

config (optional)

attributetypedescription
margin (optional)numberNumber of spaces outside border. Is halved for vertical space
border (optional)booleanToggles border
padding (optional)numberNumber of spaces inside border. Is halved for vertical space

timeZoneOverlay (optional)

This overlays a pattern of the given char covering a time range. Each longitude is given an estimated UTC offset and the localTme is tested to be withing the given range (startTime -> endTime).

attributetypedescription
startHournumberPoints with estimated time after this appear with overlay eg: 7:01 counts as after 7:00 (is overlayed)
endHournumberPoints with estimated time before this appear with overlay eg: 6:59 counts as before 7:00 (is overlayed)
charstringchar used for overlay. Recommended: "`"
coverMapbooleanBy default the map only replaces empty spaces in the map with an overlay (so the overlay is transparent and you can still see the map). This makes the overlay cover the map totally (excluding markers)
testHour (optional)numberFor testing purposes you can force the hour to be static at a given UTC. Not recommended outside of testing

Usage

See a demo on RunKit

import { drawMap } from "ascii-worldmap"

console.log(drawMap([], {}, {startHour: 7, endHour: 17, char: "`"}));

Output

``````````.`_..::__:  ,-"-"._       |]       ,     _,.__    ``````````
``_.___`_`_<_>`!(._`.`-.    /        _._     `_ ,_/  '  '-._.---.-.__`
.{`````"`"``-==,',._\{  \  / {) _   / _ ">_,-' `            `````/-/_`
\_.:--.````````._`)`^-. "'     / ( [_/(                     ``__,/-'``
'"'````\````````"`   _\        -_,--'                  )    `/.`(|````
```````|`````````` ,'         _)_.\\._<> {}              _,'`/``'`````
````````.`````````/          [_/_'` `"(                <'}  )`````````
````````\\````.-.`)          /   `-'"..' `:._          _)  '``````````
``````````\``(```(          /         `:\  > \  ,-^.  /' '  ``````````
````````````._,```""        |           \`'   \|   ?_)  {\  ``````````
```````````````=.---.       `._._       ,'     "`  |' ,- '. ``````````
````````````````|`   `-._        |     /          `:`<_|=--._`````````
````````````````(`       >       .     | ,          `=.__.`-'\````````
``````````````````.     /        |     |{|              ,-.,\`````.```
``````````````````|   ,'          \   / `'            ,"    `\````````
``````````````````|  /             |_'                |  __ `/````````
``````````````````| |                                 '-'  `-'```\.```
``````````````````|/                                        "````/````
``````````````````\.                                        ````'`````
``````````````````                                          ``````````
`````````````````` ,/           ______._.--._ _..---.---------.```````
__,-----"-..?----_/ )\    . ,-'"             "              ````(__--/
``````````````````  /__/\/                                  ``````````
1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago