2017 © Pedro Peláez
 

library php-leaflet

PHP leaflet definition and javascript generator

image

netzmacht/php-leaflet

PHP leaflet definition and javascript generator

  • Tuesday, October 17, 2017
  • by netzmacht
  • Repository
  • 2 Watchers
  • 5 Stars
  • 710 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 7 % Grown

The README.md

PHP Leaflet library

Build Status Version License Downloads Contao Community Alliance coding standard, (*1)

This library provides a PHP API to setup the Leaflet map definitions. The goal of the library is to provide a handy way to handle dynamic map configurations working in a PHP context., (*2)

Install

You can install the library using composer:, (*3)

$ php composer.phar require netzmacht/php-leaflet

Features

This library provides different components:, (*4)

  • Definition classes to define the leaflet map with all layers, controls and so on.
  • Value classes which have real behaviour and can be used to handle LatLng or GeoJSON features.
  • The Encoder component to convert the PHP leaflet definition into javascript.
  • Support for several Leaflet plugins.
  • Assets handling to autoload all required javascripts and css files from all plugins.

Before you start

  • The definition classes has some mixed behaviours. There useful behaviour is implemented. Some method creates just javascript method calls.
  • The goal is to have a close reflection of the Javascript API. Since the languages differs there are some changes which you should be aware of.

Requirements

This library requires PHP 5.6 and the symfony event dispatcher. The event dispatcher is used by the php-javascript-builder which encodes the PHP definition., (*5)

Example


/* * 1. Setup the encoder */ // The event dispatcher $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher(); // All encoders are event subscribers. $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\ControlEncoder()); $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\GroupEncoder()); $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\MapEncoder()); $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\RasterEncoder()); $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\TypeEncoder()); $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\UIEncoder()); $dispatcher->addSubscriber(new Netzmacht\LeafletPHP\Encoder\VectorEncoder()); // Create a custom factory for the javascript builder which uses the event dispatcher. // The order of the registered encoders are important! Only change if you know what you do. $factory = function(Output $output) use ($dispatcher) { $encoder = new ChainEncoder(); $encoder ->register(new \Netzmacht\JavascriptBuilder\Encoder\MultipleObjectsEncoder()) ->register(new \Netzmacht\JavascriptBuilder\Symfony\EventDispatchingEncoder($dispatcher)) ->register(new \Netzmacht\JavascriptBuilder\Encoder\JavascriptEncoder($output)); return $encoder; }; $builder = new \Netzmacht\JavascriptBuilder\Builder($factory); $leaflet = new \Netzmacht\LeafletPHP\leaflet($builder, $dispatcher); /* * 2. Create the map definitions */ $map = new \Netzmacht\LeafletPHP\Definition\Map('html_id', 'map'); $map ->setZoom(12) ->addControl(...) ->addLayer(...); /* * 3. Build the javascript */ // Will return javascript with following local vars: "map", "layers", "controls", "icons". echo $leaflet->build($map);

The Versions

17/10 2017

dev-master

9999999-dev

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

17/10 2017

1.0.2

1.0.2.0

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

05/10 2017

1.0.1

1.0.1.0

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

30/01 2017

1.0.0

1.0.0.0

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

14/11 2016

1.0.0-beta2

1.0.0.0-beta2

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

13/11 2016

dev-feature/extra-markers

dev-feature/extra-markers

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

09/11 2016

dev-feature/overpass-api

dev-feature/overpass-api

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

05/10 2016

dev-develop

dev-develop

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

05/10 2016

1.0.0-beta1

1.0.0.0-beta1

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet

28/01 2015

dev-support/0.7.x

dev-support/0.7.x

PHP leaflet definition and javascript generator

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

library javascript maps leaflet