forked from the-sz/Apple-StandBy-Clock-Worldmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.js
38 lines (32 loc) · 1011 Bytes
/
create.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require('fs');
const DottedMap = require('dotted-map').default;
const map = new DottedMap(
{
height: 40, // number of lines
grid: 'vertical' // grid style: 'vertical' or 'diagonal'
});
// create a highlighted location
map.addPin(
{
lat: 37.3376716,
lng: -121.8874266,
svgOptions:
{
radius: 0.6, // dot size
color: '#F6A300' // dot color
}
});
const svgMap = map.getSVG(
{
radius: 0.3, // dot size
shape: 'circle', // dot style: 'circle' or 'hexagon'
color: '#827670', // dot color
backgroundColor: '#020300', // background color
});
// fix viewBox, add 1 to all sides, otherwise dots at the edge get cut off
const svgMapFixed = svgMap.replace(/viewBox=\"(\d+) (\d+) (\d+) (\d+)\"/,
function(val, part1, part2, part3, part4)
{
return 'viewBox="'+(parseInt(part1)-1)+' '+(parseInt(part2)-1)+' '+(parseInt(part3)+1)+' '+(parseInt(part4)+1)+'"';
});
fs.writeFileSync('./map.svg', svgMapFixed);