flowaxy / geomap
An SVG map generator from GeoJSON for Flowaxy projects.
v1.0.0
2025-04-23 02:05 UTC
Requires
- php: >=8.2
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): Latitudelng
(float): Longitudetype
(string): Marker type (used as CSS class)icon
(string): Emoji or symbol instead of circlecount
(int): Number shown belowlabel
(string): Text labelname
(string): Tooltip text
Getting GeoJSON files
You can download GeoJSON files for countries, regions, or the entire world from:
- https://geojson-maps.ash.ms
- https://datahub.io/core/geo-countries
- https://github.com/datasets/geo-countries
- https://github.com/deldersveld/topojson (convert TopoJSON to GeoJSON using tools like https://mapshaper.org/)
For Ukraine specifically, you can try:
- https://github.com/flowaxy/GeoJSON/blob/main/countries/ukraine.geojson
- https://mapshaper.org/ to convert or simplify GeoJSON files
Make sure your file contains valid GeoJSON structure with features and geometry.
License
MIT