Code Monkey home page Code Monkey logo

contao-leaflet-maps's Introduction

Leaflet integration into Contao CMS

Build Status Version License Downloads Contao Community Alliance coding standard

This extension provides a backend gui for integrating Leaflet into the Contao CMS.

It has a highly flexible and customizable design so that 3rd party extensions and custom development is really easy. Developing map applications in Contao with the modern Open Source Map library Leaflet made easy!

Features

Documentation

A basic user documentation written in German is available.

Changelog

View the CHANGELOG.md for the latest changes.

Requirements

  • Contao 4.4
  • PHP >= 7.0

Install

$ php composer.phar require netzmacht/contao-leaflet-maps:~3.0

Credits

The integrated icons are part of the Farm Fresh Web Icons and are licensed under the CC BY 3.0 US

The about icon is part of the Web Blog Icons by SEM Labs and is licensed under the CC BY 4.0.

English translations when possible where copied from the used libraries. Mainly the leaflet documentation is used.

contao-leaflet-maps's People

Contributors

baumannsven avatar dependabot[bot] avatar dmolineus avatar fritzmg avatar stefanheimes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

contao-leaflet-maps's Issues

icons.js missing, when not using icons at all

Trying to load a map in the frontend, containing no "Icon" results in this error:

Warning: filemtime(): stat failed for /var/customers/webs/moarhof/assets/leaflet/js/icons.js in system/modules/core/library/Contao/Controller.php on line 857

#0 [internal function]: __error(2, 'filemtime(): st...', '/var/customers/...', 857, Array)
#1 system/modules/core/library/Contao/Controller.php(857): filemtime('/var/customers/...')
#2 system/modules/core/classes/FrontendTemplate.php(102): Contao\Controller::replaceDynamicScriptTags('...')
#3 system/modules/core/pages/PageRegular.php(190): Contao\FrontendTemplate->output(true)
#4 system/modules/core/controllers/FrontendIndex.php(285): Contao\PageRegular->generate(Object(Contao\PageModel), true)
#5 index.php(20): Contao\FrontendIndex->run()
#6 {main}


Fatal error: Uncaught exception Exception with message File assets/leaflet/js/icons.js does not exist thrown in system/modules/core/library/Contao/Combiner.php on line 139

#0 system/modules/core/library/Contao/Controller.php(860): Contao\Combiner->add('assets/leaflet/...', false)
#1 system/modules/core/classes/FrontendTemplate.php(102): Contao\Controller::replaceDynamicScriptTags('...')
#2 system/modules/core/pages/PageRegular.php(190): Contao\FrontendTemplate->output(true)
#3 system/modules/core/controllers/FrontendIndex.php(285): Contao\PageRegular->generate(Object(Contao\PageModel), true)
#4 index.php(20): Contao\FrontendIndex->run()
#5 {main}

Adding an dummy icon to the map, removes the error and loads the map as intent, because a icons.js gets generated. Obviously loading the asset should be skipped when there is no need. Additionally I noticed the icons.js not being deleted or emptied when removing the last Icon from Backend. Therefore if you ever added and removed an Icon the error above will never appear.

Transifex

Export translations to transifex and get translators.

Database error on every backend page.

Copied from #42:

Also on the bottom of every backend page i get this:

Fatal error: Uncaught exception 'Exception' with message 'Invalid connection resource' in /var/customers/webs/moarhof/system/modules/core/library/Contao/Database/Statement.php:92
Stack trace:
#0 /var/customers/webs/moarhof/system/modules/core/library/Contao/Database/Mysql.php(355): Contao\Database\Statement->__construct(Resource id #2, false)
#1 /var/customers/webs/moarhof/system/modules/core/library/Contao/Database.php(181): Contao\Database\Mysql->createStatement(Resource id #2, false)
#2 /var/customers/webs/moarhof/system/modules/core/classes/BackendUser.php(163): Contao\Database->prepare('UPDATE tl_user ...')
#3 [internal function]: Contao\BackendUser->__destruct()
#4 {main}
  thrown in /var/customers/webs/moarhof/system/modules/core/library/Contao/Database/Statement.php on line 92

Add expert options setting to layers

Like the map has an expert setting to pass custom options it should be available for layers as well.

We cannot do it for markers and vectors as they get created from GeoJSON. Use an input field to create an feature.properties.data field instead. Use the data property instead of the properties so that it is not mixed with some internal data being set.

Local unique aliases

Allow to use aliases which are unique by it's parent id. Map controls do not really have an unique database id.

Support of Leaflet 1.0.0

Check which has changed in coming 1.0.0 release and build compatibility layer

  • Removal of Multiple* vector layers
  • ....

User permissions

Add user permissions to limit access to specific parts of Contao leaflet.

  • Grant access to specific layers only.
  • Only grant access to edit data on a layer.
  • Grant access to style, icon and popup

Contao 4

I just wondered if there will be a version for the new Contao 4 LTS, and asking what I can do for that (besides pull requests for the manager).

Add credits page

Add credits page for all used libraries, plugins, extensions.

Support custom tile layers.

At the moment only tile layers of leaflet-providers can be defined. Provide support for custom tile layers.

Support TopoJson

Additional to the used geosjon data format, topo json should be supported as well.

  • Consider which leaflet plugin to use, probably mapbox/leaflet-omnivore
  • Implement topo json encoding in PHP (or find a library for that.)

White page on articles with leaflet map using contao 3.5

Problem
When using a leaflet-map as article element, you get a white screen after saving the changes in backend and frontend every time you visit the article.

Reproduce
Install Contao 3.5 as well as contao-leaflet-maps 1.0.0-beta3 ref ff8cda1 from composer. Create any map-provider and any map with it. Navigate to an article and insert it there as element.

Errors
When enabling error messages you will get this output: Fatal error: Cannot make static method Contao\Controller::replaceInsertTags() non static in class Netzmacht\Contao\Leaflet\Frontend\Helper\FrontendApi in /path/composer/vendor/netzmacht/contao-leaflet-maps/src/Netzmacht/Contao/Leaflet/Frontend/Helper/FrontendApi.php on line 30

Solution
Apparently the line in question misses a static and should be written

public static function replaceInsertTags($strBuffer, $blnCache = true)

instead. This way everything shows correctly on both, front- and backend.

Duplicating maps

Duplicating maps fails because the alias is set as an unique field so far. Contao does not trigger a save callback when copying the map, so have to find a way to fix it.

Maybe use nullIfEmpty helps?

Use own config system.

We use a lot of config variables. Consider to move them into an own config.

At the moment following globals are used:

LEAFLET_MAPPERS
LEAFLET_ENCODERS
LEAFLET_LAYERS
LEAFLET_CONTROLS
LEAFLET_ICONS
LEAFLET_VECTORS
LEAFLET_STYLES
LEAFLET_TILE_PROVIDERS
LEAFLET_LIBRARIES

Each configuration should go into a config/leaflet.php or config/leaflet.json file.

return array(
    'mappers' => array(
        // ...
    ),
    'encoders' => array(
        // ...
    ),
    // ...
);

Could be implemented like the contao-bootstrap configuration subsystem. Drawback would be that removing an item from the config is not possible enymore as the arrays would be merged together.

Layers control

When switching between overlay/baselayer for an already added layer saving does not work.

Replace bit3/contao-meta-palettes

I get this message on composer install:

Package bit3/contao-meta-palettes is abandoned, you should avoid using it.
Use contao-community-alliance/meta-palettes instead.

So the package should be replaced.

Use a custom route for data requests

Instead of handle the ajax request in the frontend module/content element a custom route should be used.
We have to emulate the contao page environment for it otherwise some functions won't work. MetaModels integration could be the show stopper here.

Support encoded polylines

Support encoded polylines.

  • Choose best leaflet plugin
  • Find/implement PHP encoding of the polyline

Cannot create map - Contao 3.5, Leaflet-maps 2.0.0-beta2

Trying to add a map on a brand new installed netzmacht/contao-leaflet-maps 2.0.0-beta2 throws me this error:

Fatal error: Uncaught exception Exception with message Query error: Column 'cacheLifeTime' cannot be null (INSERT INTO tl_leaflet_map (zoom, adjustZoomExtra, dragging, touchZoom, scrollWheelZoom, doubleClickZoom, boxZoom, tap, trackResize, bounceAtZoomLimits, closeOnClick, keyboard, keyboardPanOffset, keyboardZoomOffset, zoomControl, adjustBounds, dynamicLoad, locate, locateWatch, locateTimeout, locateMaximumAge, enableHighAccuracy, cache, cacheLifeTime, tstamp) VALUES ('', 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 80, 1, 1, 0, 0, 0, 0, NULL, NULL, 0, 0, NULL, 0)) thrown in system/modules/core/library/Contao/Database/Statement.php on line 295

#0 system/modules/core/library/Contao/Database/Statement.php(264): Contao\Database\Statement->query()
#1 system/modules/core/drivers/DC_Table.php(689): Contao\Database\Statement->execute()
#2 system/modules/core/classes/Backend.php(650): Contao\DC_Table->create()
#3 system/modules/core/controllers/BackendMain.php(131): Contao\Backend->getBackendModule('leaflet_map')
#4 contao/main.php(20): Contao\BackendMain->run()
#5 {main}

Also on the bottom of every backend page i get this:

Fatal error: Uncaught exception 'Exception' with message 'Invalid connection resource' in /var/customers/webs/moarhof/system/modules/core/library/Contao/Database/Statement.php:92
Stack trace:
#0 /var/customers/webs/moarhof/system/modules/core/library/Contao/Database/Mysql.php(355): Contao\Database\Statement->__construct(Resource id #2, false)
#1 /var/customers/webs/moarhof/system/modules/core/library/Contao/Database.php(181): Contao\Database\Mysql->createStatement(Resource id #2, false)
#2 /var/customers/webs/moarhof/system/modules/core/classes/BackendUser.php(163): Contao\Database->prepare('UPDATE tl_user ...')
#3 [internal function]: Contao\BackendUser->__destruct()
#4 {main}
  thrown in /var/customers/webs/moarhof/system/modules/core/library/Contao/Database/Statement.php on line 92

Contao 3.5

This Package is not installable via Composer using Contao 3.5, because the following requirement cannot be met:
contao/core >=3.2,<3.5-dev

Instead the core requirement should be:
contao/core >=3.2,<4.0-dev

Uninstall via composer client not working

After uninstalling contao-leaflet-maps it only disapears from the extension list in the composer client (Paketverwaltung). Maps, layers etc. are still there in the backend menu. Also the folders system/modules/leaflet and system/modules/leaflet-libs are not removed.

Cache layer

Implement a cache layer for icons and map definitions.

Travis CI

Setup travis CI and fix code style.

Metamodels layer

Implement a meta models layer, which can:

  • Define coordinates by attributes
  • Provides geojson feature as attribute value
  • Provides file list of geojson files as attribute value
  • Render item as popup content
  • Map attributes to feature options

Input validation

Improve usability by adding input validation for:

  • Coordinates
  • Multiple Coordinates
  • Javascript expression
  • JSON data input

Set model properties as vector/marker feature properties

To stay extendable it would be nice if some model properties are automatically set as feature properties.

Not every model property should be there, it would be a huge overload. The data would be available at feature.properties.model.

  • Implement an event where extensions can hook in set the properties.
  • Make it easy to extend the config and define properties there:
// Add the id value
$GLOBALS['LEAFLET_FEATURE_MODEL_DATA']['marker'][] = 'id';

// Define the intended output
$GLOBALS['LEAFLET_FEATURE_MODEL_DATA']['marker'][] = array('itemList', 'array');

Supported data formats could be:

  • array/object do a deserialize and return an array or object
  • json data is handles ad json data
  • file containing a single file path.
  • files containing multiple files as array
  • custom Allow any value and pass it to an event dispatcher.

Missing alias leads to error notice

If no alias is given to a layer, creating a new layer is impossible. Alias must be unique, but it is not a required field. Self-filling field (like other alias fields in Contao) would be great.

Add style types

In addition to the fixed style setting, add others:

  • Random style. Get a random style from a specific set of styles.
  • Color range. Get a random color in a defined color range.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.