PHP code example of chillerlan / php-geojson-helpers

1. Go to this page and download the library: Download chillerlan/php-geojson-helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chillerlan / php-geojson-helpers example snippets


$featureCollection = (new FeatureCollection)->setBbox([0, 0, 1024, 1024]);

// add a single feature
$feature = new Feature([512, 512], 'Point', 1);
$featureCollection->addFeature($feature);

// add an iterable of features
$featureCollection->addFeatures([$feature, /* ... more features ... */]);

// create the GeoJSON, feed leaflet
$json = $featureCollection->toJSON();

// as of v2.x via JsonSerializable
$json = json_encode($featureCollection);


$polylineCoords = [[11, 12], [21, 22], [31, 32], /* ... */];

$ps             = new PolylineSimplifyer($polylineCoords);
$simplified     = $ps->simplify(5, true);
json
{
	": "^7.4 || ^8.0",
		"chillerlan/php-geojson-helpers": "dev-master"
	}
}