Simple Map Tiles Generator allow to make a Map Tiles with PHP and Imagick. That allows to build a simple custom map. It does not include any geographical calculations.
- PHP >= 5.3 version
- PHP Imagick extension >= 3.0 version
- A lot CPU time (for images with high resolution and for high zoom level)
- A lot free disc space
- Patience ;)
Make custom map, based on my-image.jpg.
Generate a tiles:
// Setup
$tiler = new Fedik\MapTiles\MapTiles('/full/path/to/my-image.jpg', array(
'tiles_path' => '/full/path/to/where-to-store-tiles/',
'zoom_max' => 3
));
// Generate tiles
$tiler->process(true);Display the result with Leaflet.js
<html>
<head>
<link rel="stylesheet" href="path/to/leaflet.css" />
<script src="path/to/leaflet.js"></script>
<script type="module">
const tiles = L.tileLayer('tiles-path/{z}/{x}/{y}.jpg', {
minZoom: 0,
maxZoom: 5,
tms: true
});
const map = L.map('map', {
center: [0, 0],
zoom: 1,
layers:[tiles]
});
</script>
</head>
<body>
<div id="map" style="height: 100vh"></div>
</body>
</html>tile_sizeA tile size (def: 256);store_structureA tile name, can contain/for splitzoom,x,yby folder (def:'%d/%d/%d');forceForce create new tile if it already exist (def:false);tmsUse TMS tile addressing, which is used in open-source projects like OpenLayers or TileCache (def:true);fill_colorColor for fill a free space if tile is not a square (def:white);zoom_minMinimum zoom level for make tiles (def:0);zoom_maxMaximum zoom level for make tiles (def:8);scaling_upZoom level when scaling up still allowed, when a base image have less size than need for a requested zoom level (def:0);formatImage format (def:jpeg);quality_jpegQuality for jpeg format (def:80);imagick_tmpTemporary folder for ImageMagick, useful if system /tmp folder have not enough free space (def: null);
__construct($image_path, $options = array())Class constructor.setOptions($options)Set/change options.getOptions()Get options array.process($clean_up = false)Generate tiles, set$clean_up=trueto remove a base zoom images.prepareZoomBaseImages($min = null, $max = null)Prepare a base zoom images,$min- min zoom level,$max- max zoom level.removeZoomBaseImages($min = null, $max = null)Remove the base zoom images.tilesForZoom($zoom)Generate tiles for given$zoomlevel.