Skip to content

Latest commit

 

History

History
134 lines (86 loc) · 5.72 KB

README.md

File metadata and controls

134 lines (86 loc) · 5.72 KB

GIS Plugin

The Gis Plugin is an extension for Grav CMS. This plugin, using the Leaflet javascript library, aims to provide a simple way to geolocate contents and to display interactive maps.

Installation

Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under /your/site/grav/user/plugins. Then rename the folder to gis. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/gis

NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its blueprints.yaml-file on GitHub.

Dependencies

Configuration

Before configuring this plugin, you should copy the user/plugins/gis/gis.yaml to user/config/plugins/gis.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true              #
private:                   # Private Area
  load: true               # Loading Leaflet library inside the Private Area
  height: 340              # Height of the private area maps
  center: '51.505, -0.093' # Default coordinates for centering private area maps
  zoom: 13                 # Default zoom for private area maps
public:                    # Frontend
  load: true               # Loading Leaflet library on the frontend
  height: 340              # Default height for frontend maps
  center: '51.505, -0.093' # Default coordinates for centering frontend maps
  zoom: 13                 # Default zoom for frontend maps

Note that if you use the Admin Plugin, a file with your configuration named gis.yaml will be saved in the user/config/plugins/-folder once the configuration is saved in the Admin.

Usage

For editors

The plugin provides two features. First, you can geolocate your page: the plugin provide a Gis page, based on the default one, in which you can add several coordinates to your page frontmatter through interactive maps. These coordinates are then displayed on your site frontend through the {{ gis() }} Twig function (see below).

The second allows you to display interactive maps into your content: the plugin provides the [gis /] shortcode you can use in your content to display interactive maps, with or without markers. For example:

[gis /]

will display a simple map centered and zoomed accordingly to the plugin settings. You can pass several arguments as map height, center coordinates, zoom level:

[gis height=220 zoom=9 center=34.23,1.43 /]

You can add some markers to your map, using multiple markerN arguments:

[gis height=320 marker1="'Test 1', 43, 2, pink" marker2="'Test 2', 44, 1, orange" /]

The displayed maps are automatically centered and zoomed to fit all markers.

For developers

Inside your templates

The plugin provides the {{ gis() }} Twig function. Without parameters, it displays a map (which height is taken from the plugin settings) and populate it with markers, based on the page frontmatter. If there isn't any marker associated to the page, the map is centered and zoomd based on the plugin configuration.

You can specify the height of the map :

{{ gis({'height': 320}) }}

You can prevent the map from being populated with markers:

{{ gis({'markers': false}) }}

You can also pass an array of markers:

{{ gis({'height': 240, 'markers': [{'name': 'Test', 'icon': 'pink', 'latitude': '51.505', 'longitude': '-0.093'},{'name': 'Test2', 'icon': 'orange', 'latitude': '51', 'longitude': '-0.1'}]}) }}

Adding geolocation to page blueprints

As said above, the GIS plugin provides a Gis page blueprint that simply adds a Geolocation tab.

You can add this feature in your own page blueprints; for example, to add a tab:

geolocation:
  type: tab
  title: PLUGIN_GIS.GEOLOCATION
  import@:
    type: partials/gis

Available markers

blue green orange pink purple red teal yellow

Credits