#!/usr/bin/perl

use strict;
use warnings;

use File::Slurp;
use HTML::OSM;

my @coordinates = (
        [undef, undef, 'San Francisco', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png'],
        [undef, undef, 'New York'],
        [51.5074, -0.1278, 'London'],  # Already has coordinates
);

my $map = HTML::OSM->new(coordinates => \@coordinates, zoom => 10);

my ($head, $map_div) = $map->onload_render();

my $html = qq {
	<!DOCTYPE html>
	<html>
	<head>
};

$html .= $head;

$html .= qq {
	</head>
	<body>
};

$html .= $map_div;

$html .= qq {
	</body>
	</html>
};

write_file('map.html', $html);
print "Interactive map saved as map.html. Open this file in a browser.\n";
