flowaxy/geomap

An SVG map generator from GeoJSON for Flowaxy projects.

v1.0.0 2025-04-23 02:05 UTC

This package is not auto-updated.

Last update: 2025-05-08 02:12:54 UTC


README

GeoMapSvgGenerator is a PHP class for generating interactive SVG maps from GeoJSON data.
It supports region tooltips, customizable dimensions, and custom markers (icons, counts, etc).

Features

  • Convert GeoJSON to interactive SVG maps
  • Render regions with optional tooltips
  • Add markers with icons, labels, or counts
  • Control output size and language for region names

Installation

Use Composer to install the library:

composer require flowaxy/geomap

Usage

use Flowaxy\GeoMapSvgGenerator;

$geojson = 'ukraine.geojson';
$markers = [
    ['lat' => 50.45, 'lng' => 30.52, 'type' => 'capital', 'icon' => '', 'name' => 'Kyiv'],
];

$generator = new GeoMapSvgGenerator($geojson, $markers, 1000, 800, true, 'uk');
$svg = $generator->generateSvg();

file_put_contents('map.svg', $svg);

Marker Format

Each marker may contain:

  • lat (float): Latitude
  • lng (float): Longitude
  • type (string): Marker type (used as CSS class)
  • icon (string): Emoji or symbol instead of circle
  • count (int): Number shown below
  • label (string): Text label
  • name (string): Tooltip text

Getting GeoJSON files

You can download GeoJSON files for countries, regions, or the entire world from:

For Ukraine specifically, you can try:

Make sure your file contains valid GeoJSON structure with features and geometry.

License

MIT