PHPackages                             dantsu/php-osm-static-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dantsu/php-osm-static-api

ActiveLibrary[API Development](/categories/api)

dantsu/php-osm-static-api
=========================

PHP library to easily get static image from OpenStreetMap (OSM), add markers and draw lines.

0.6.4(2y ago)97141.0k↓18.3%23[5 issues](https://github.com/DantSu/php-osm-static-api/issues)[1 PRs](https://github.com/DantSu/php-osm-static-api/pulls)1MITPHPPHP &gt;=7.0

Since Sep 8Pushed 2y ago2 watchersCompare

[ Source](https://github.com/DantSu/php-osm-static-api)[ Packagist](https://packagist.org/packages/dantsu/php-osm-static-api)[ Docs](https://github.com/DantSu/php-osm-static-api)[ GitHub Sponsors](https://github.com/DantSu)[ RSS](/packages/dantsu-php-osm-static-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (21)Used By (1)

[![Packagist](https://camo.githubusercontent.com/51fb2ebee53bf92f1974a88085a618b462b58e0e131d9c1a9582f2ee50383de3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f44616e7453752f7068702d6f736d2d7374617469632d6170692e737667)](https://packagist.org/packages/DantSu/php-osm-static-api)[![Latest Stable Version](https://camo.githubusercontent.com/0b23227a32eb9366f98da5225868250fbfeef1c0ae8555f998d6fc74dbf5ac7c/68747470733a2f2f706f7365722e707567782e6f72672f44616e7453752f7068702d6f736d2d7374617469632d6170692f762f737461626c65)](https://packagist.org/packages/DantSu/php-osm-static-api)[![GitHub license](https://camo.githubusercontent.com/a752ac0fd5611f8dc629fd0aae1e6b06b4505853184b9a84e9cd4855a2c34c90/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f44616e7453752f7068702d6f736d2d7374617469632d6170692e737667)](https://github.com/DantSu/php-osm-static-api/blob/master/LICENSE)

PHP OpenStreetMap Static API
============================

[](#php-openstreetmap-static-api)

PHP library to easily get static image from OpenStreetMap with markers, lines, circles and polygons.

This project uses the [Tile Server](https://wiki.openstreetmap.org/wiki/Tile_servers) of the OpenStreetMap Foundation which runs entirely on donated resources, see [Tile Usage Policy](https://operations.osmfoundation.org/policies/tiles/) for more information.

✨ Supporting
------------

[](#-supporting)

⭐ Star this repository to support this project. You will contribute to increase the visibility of this library 🙂

Installation
------------

[](#installation)

Install this library easily with composer :

```
composer require dantsu/php-osm-static-api
```

How to use
----------

[](#how-to-use)

### Generate OpenStreetMap static image with markers and polygon :

[](#generate-openstreetmap-static-image-with-markers-and-polygon-)

```
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Polygon;
use \DantSu\OpenStreetMapStaticAPI\Markers;

\header('Content-type: image/png');
(new OpenStreetMap(new LatLng(44.351933, 2.568113), 17, 600, 400))
    ->addMarkers(
        (new Markers(__DIR__ . '/resources/marker.png'))
            ->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
            ->addMarker(new LatLng(44.351933, 2.568113))
            ->addMarker(new LatLng(44.351510, 2.570020))
            ->addMarker(new LatLng(44.351873, 2.566250))
    )
    ->addDraw(
        (new Polygon('FF0000', 2, 'FF0000DD'))
            ->addPoint(new LatLng(44.351172, 2.571092))
            ->addPoint(new LatLng(44.352097, 2.570045))
            ->addPoint(new LatLng(44.352665, 2.568107))
            ->addPoint(new LatLng(44.352887, 2.566503))
            ->addPoint(new LatLng(44.352806, 2.565972))
            ->addPoint(new LatLng(44.351517, 2.565672))
    )
    ->getImage()
    ->displayPNG();
```

[![Exported OpenStreetMap image](./src/samples/resources/sample1.png)](./src/samples/resources/sample1.png)

### Align and zoom the map to drawings and markers :

[](#align-and-zoom-the-map-to-drawings-and-markers-)

- `->fitToDraws(int $padding = 0)`
- `->fitToMarkers(int $padding = 0)`
- `->fitToDrawsAndMarkers(int $padding = 0)`
- `->fitToPoints(LatLng[] $points, int $padding = 0)`

`$padding` sets the amount of padding in the borders of the map that shouldn't be accounted for when setting the view to fit bounds. This can be positive or negative according to your needs.

```
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Polygon;
use \DantSu\OpenStreetMapStaticAPI\Markers;

\header('Content-type: image/png');
(new OpenStreetMap(new LatLng(0, 0), 0, 600, 400))
    ->addMarkers(
        (new Markers(__DIR__ . '/resources/marker.png'))
            ->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
            ->addMarker(new LatLng(44.351933, 2.568113))
            ->addMarker(new LatLng(44.351510, 2.570020))
            ->addMarker(new LatLng(44.351873, 2.566250))
    )
    ->addDraw(
        (new Polygon('FF0000', 2, 'FF0000DD'))
            ->addPoint(new LatLng(44.351172, 2.571092))
            ->addPoint(new LatLng(44.352097, 2.570045))
            ->addPoint(new LatLng(44.352665, 2.568107))
            ->addPoint(new LatLng(44.352887, 2.566503))
            ->addPoint(new LatLng(44.352806, 2.565972))
            ->addPoint(new LatLng(44.351517, 2.565672))
    )
    ->fitToDraws(10)
    ->getImage()
    ->displayPNG();
```

Documentation
-------------

[](#documentation)

ClassDescription[Circle](./docs/classes/DantSu/OpenStreetMapStaticAPI/Circle.md)DantSu\\OpenStreetMapStaticAPI\\Circle draw circle on the map.[LatLng](./docs/classes/DantSu/OpenStreetMapStaticAPI/LatLng.md)DantSu\\OpenStreetMapStaticAPI\\LatLng define latitude and longitude for map, lines, markers.[Line](./docs/classes/DantSu/OpenStreetMapStaticAPI/Line.md)DantSu\\OpenStreetMapStaticAPI\\Line draw line on the map.[MapData](./docs/classes/DantSu/OpenStreetMapStaticAPI/MapData.md)DantSu\\OpenStreetMapStaticAPI\\MapData convert latitude and longitude to image pixel position.[Markers](./docs/classes/DantSu/OpenStreetMapStaticAPI/Markers.md)DantSu\\OpenStreetMapStaticAPI\\Markers display markers on the map.[OpenStreetMap](./docs/classes/DantSu/OpenStreetMapStaticAPI/OpenStreetMap.md)DantSu\\OpenStreetMapStaticAPI\\OpenStreetMap is a PHP library created for easily get static image from OpenStreetMap with markers, lines, polygons and circles.[Polygon](./docs/classes/DantSu/OpenStreetMapStaticAPI/Polygon.md)DantSu\\OpenStreetMapStaticAPI\\Polygon draw polygon on the map.[TileLayer](./docs/classes/DantSu/OpenStreetMapStaticAPI/TileLayer.md)DantSu\\OpenStreetMapStaticAPI\\TileLayer define tile server url and related configuration[XY](./docs/classes/DantSu/OpenStreetMapStaticAPI/XY.md)DantSu\\OpenStreetMapStaticAPI\\XY define X and Y pixel position for map, lines, markers.Contributing
------------

[](#contributing)

Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity49

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~2 days

Total

20

Last Release

1017d ago

PHP version history (2 changes)0.0.0PHP ^7.0

0.2.5PHP &gt;=7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4188774?v=4)[Franck Alary](/maintainers/DantSu)[@DantSu](https://github.com/DantSu)

---

Top Contributors

[![DantSu](https://avatars.githubusercontent.com/u/4188774?v=4)](https://github.com/DantSu "DantSu (44 commits)")[![cquest](https://avatars.githubusercontent.com/u/1202668?v=4)](https://github.com/cquest "cquest (1 commits)")[![davetha](https://avatars.githubusercontent.com/u/8431567?v=4)](https://github.com/davetha "davetha (1 commits)")[![mandrasch](https://avatars.githubusercontent.com/u/777278?v=4)](https://github.com/mandrasch "mandrasch (1 commits)")[![stephan-strate](https://avatars.githubusercontent.com/u/19595615?v=4)](https://github.com/stephan-strate "stephan-strate (1 commits)")

---

Tags

composercomposer-librarycomposer-packageimagemapmapsopenstreetmapopenstreetmapsosmphpphp-libraryphp7phpapiimagemapstaticmapsosmOpenStreetMap

### Embed Badge

![Health badge](/badges/dantsu-php-osm-static-api/health.svg)

```
[![Health](https://phpackages.com/badges/dantsu-php-osm-static-api/health.svg)](https://phpackages.com/packages/dantsu-php-osm-static-api)
```

###  Alternatives

[mtownsend/remove-bg

A PHP package to interface with the remove.bg api.

183315.4k](/packages/mtownsend-remove-bg)[jeroendesloovere/geolocation-php-api

This Geolocation PHP class connects to Google Maps API to find latitude/longitude or address.

75316.8k4](/packages/jeroendesloovere-geolocation-php-api)[kenguest/services-openstreetmap

More information available at https://pear.php.net/package/Services\_OpenStreetMap

20341.4k](/packages/kenguest-services-openstreetmap)[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)[riverside/php-nominatim

PHP client for Nominatim, a search engine for OpenStreetMap data.

1225.9k1](/packages/riverside-php-nominatim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
