1. Go to this page and download the library: Download ballen/cartographer 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/ */
ballen / cartographer example snippets
use Ballen\Cartographer\Core\LatLong;
use Ballen\Cartographer\Point;
$point = new Point(new LatLong(52.005523, 1.045936));
echo $point->generate();
// {"type":"Point","coordinates":[1.045936,52.005523]}
use Ballen\Cartographer\Core\LatLong;
use Ballen\Cartographer\LineString;
$points = [
new LatLong(51.973683,1.044497),
new LatLong(51.974067,1.044134),
new LatLong(51.974355,1.045795),
new LatLong(51.975010,1.049768),
new LatLong(51.976018,1.055869),
new LatLong(51.976195,1.056060),
new LatLong(51.976432,1.056083),
new LatLong(51.976774,1.056036),
new LatLong(51.977023,1.056115),
new LatLong(51.977107,1.056379),
new LatLong(51.977102,1.056658),
];
$linestring = new LineString($points);
echo $linestring->generate();
// {"type":"LineString","coordinates":[[1.044497,51.973683],[1.044134,51.974067],[1.045795,51.974355],[1.049768,51.97501],[1.055869,51.976018],[1.05606,51.976195],[1.056083,51.976432],[1.056036,51.976774],[1.056115,51.977023],[1.056379,51.977107],[1.056658,51.977102]]}
use Ballen\Cartographer\Core\LatLong;
use Ballen\Cartographer\Polygon;
use Ballen\Cartographer\Core\LinearRing;
$points = [
(new LatLong(52.064761, 1.174470))->lngLatArray(),
(new LatLong(52.065045, 1.176098))->lngLatArray(),
(new LatLong(52.064964, 1.176156))->lngLatArray(),
(new LatLong(52.065172, 1.177106))->lngLatArray(),
(new LatLong(52.064146, 1.177594))->lngLatArray(),
(new LatLong(52.063968, 1.176768))->lngLatArray(),
(new LatLong(52.063714, 1.174875))->lngLatArray(),
(new LatLong(52.064761, 1.174470))->lngLatArray(),
];
$linestring = new Polygon((new LinearRing())->addRing($points));
echo $linestring->generate();
// {"type":"Polygon","coordinates":[[[1.17447,52.064761],[1.176098,52.065045],[1.176156,52.064964],[1.177106,52.065172],[1.177594,52.064146],[1.176768,52.063968],[1.174875,52.063714],[1.17447,52.064761]]]}
use Ballen\Cartographer\Core\LatLong;
use Ballen\Cartographer\Feature;
use Ballen\Cartographer\Point;
$feature = new Feature(new Point(new LatLong(52.063186, 1.157385)), [
// Your own personal marker points (appear when you click on the Feature point)
'Park' => 'Christchurch Park',
'Post code' => 'IP4 2BX',
'Link' => 'http://focp.org.uk/',
// Optional Mapbox supported properties (See: https://www.mapbox.com/help/markers/)
'marker-color' => '#3bb2d0', // A light blue marker colour
'marker-symbol' => 'park',
'marker-size' => 'large',
]);
echo $feature->generate();
// {"type":"Feature","geometry":{"type":"Point","coordinates":[1.157385,52.063186]},"properties":{"Park":"Christchurch Park","Post code":"IP4 2BX","Link":"http:\/\/focp.org.uk\/","marker-color":"#3bb2d0","marker-symbol":"park","marker-size":"large"}}
use Ballen\Cartographer\Core\LatLong;
use Ballen\Cartographer\Feature;
use Ballen\Cartographer\Point;
$park = new Feature(new Point(new LatLong(52.063186, 1.157385)), [
// Your own personal marker points (appear when you click on the Feature point)
'Park' => 'Christchurch Park',
'Post code' => 'IP4 2BX',
'Link' => 'http://focp.org.uk/',
// Optional Mapbox supported properties (See: https://www.mapbox.com/help/markers/)
'marker-color' => '#3bb2d0', // A light blue marker colour
'marker-symbol' => 'park',
'marker-size' => 'large',
]);
// Train Station Specific codes
$station_properties = [
'marker-color' => '#F6546A',
'marker-symbol' => 'rail',
'marker-size' => 'medium'
];
// Set some train stations with their own names (merge the standard train station details)
$station_central = new Feature(new Point(new LatLong(52.050743, 1.143012)), array_merge($station_properties, ['Name' => 'Ipswich Train Station']));
$station_derbyroad = new Feature(new Point(new LatLong(52.050808, 1.182638)), array_merge($station_properties, ['Name' => 'Derby Road Station']));
$station_westerfield = new Feature(new Point(new LatLong(52.081026, 1.166773)), array_merge($station_properties, ['Name' => 'Westerfield Train Station']));
// Create the new collection and add each of the GeoJSON objects to it...
$collection = new Ballen\Cartographer\FeatureCollection([$station_central, $park, $station_westerfield, $station_derbyroad]);
echo $collection->generate();
// {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[1.143012,52.050743]},"properties":{"marker-color":"#F6546A","marker-symbol":"rail","marker-size":"medium","Name":"Ipswich Train Station"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[1.157385,52.063186]},"properties":{"Park":"Christchurch Park","Post code":"IP4 2BX","Link":"http:\/\/focp.org.uk\/","marker-color":"#3bb2d0","marker-symbol":"park","marker-size":"large"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[1.166773,52.081026]},"properties":{"marker-color":"#F6546A","marker-symbol":"rail","marker-size":"medium","Name":"Westerfield Train Station"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[1.182638,52.050808]},"properties":{"marker-color":"#F6546A","marker-symbol":"rail","marker-size":"medium","Name":"Derby Road Station"}}]}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.