Skip to content
This repository was archived by the owner on Jul 18, 2019. It is now read-only.

rasteiner/k3-map-section

Repository files navigation

Repository is archived and the plugin does not work with current versions of Kirby. Do not install.


Kirby 3 map section plugin

A Kirby 3 plugin to manipulate and store map related information.

Installation

Install with composer

Run composer require rasteiner/k3-map-section

Download a zip

Download the latest zip file from the relases tab on github.
Extract the contents into a folder in your site/plugins folder.

Configuration

You need a google API browser key with access to the Maps Javascript API. Then you need to set that in your config.php file, like this:

<?php

return [
  //...
  'rasteiner.MapSection' => [
    'key' => 'YOUR API KEY HERE',
  ],
  //...
];

Quickstart (TL;DR)

After installing the plugin, scroll down to the "Complete blueprint example" to see an example.

Usage

The section itself only shows a map. It does not store any data.

Creating the section

sections:
  mymap:
    type: map
    height: medium # | small | medium | large | huge

Saving data

The data for the map can optionally be stored in other fields that are on the same page. This allows for a greater flexibility in your blueprint setup (you choose what data you need to save).

To enable this you need to link the map section to fields, this can be done with the storage option:

sections:
  mymap:
    type: map
    storage:
      center: arbitraryname

  myfields:
    type: fields
    fields:
      arbitraryname:
        type: text
        label: Map Center

This tells the map section that you want to store the center position in the field arbitraryname

The center coordinates need to be stored in a field that accepts text, arrays or objects as values. This means you can store them in text fields, hidden fields or future compatible fields that store the coordinates as objects.

You can do the same with the zoom level. Storable in text, hidden, range or number fields.

sections:
  mymap:
    type: map
    storage:
      zoom: myzoomlevel

  myfields:
    type: fields
    fields:
      myzoomlevel:
        type: range
        min: 0
        max: 22
        step: 1

At last you can also store markers in a structure field (or any future field that accepts arrays as values). Each structure item needs to have at least a coords field. The field name title is also recognized as marker title (should work with any type that saves as text).

sections:
  mymap:
    type: map
    storage:
      markers: arbitrarymarkersname

  myfields:
    type: fields
    fields:
      arbitrarymarkersname:
        type: structure
        label: Markers
        mapsection: qux
        fields:
          coords:
            type: text
            label: Position
          title:
            type: text
            label: Title
          otherfields:
            type: textarea
            label: Description

Complete blueprint example

columns:
  - width: 1/2
    sections:
      mymap:
        type: map
        height: huge
        storage:
          center: arbitraryname
          zoom: arbitraryzoomname
          markers: arbitrarymarkersname

  - width: 1/2
    sections:
      myfields:
        type: fields
        fields:
          arbitraryname:
            type: text
            label: Map Center
          arbitraryzoomname:
            type: text
            label: Zoom
            min: 0
            max: 22
            step: 1
          arbitrarymarkersname:
            type: structure
            label: Markers
            fields:
              coords:
                type: text
                label: Position
              title:
                type: text
                label: Title
              otherfields:
                type: textarea
                label: Description

Other Map Providers

It's technically possible to register other map providers (like OpenStreetMap, Azure Maps, etc...) in plugins. Compatible plugins will be listed here.

About

A Kirby 3 plugin to manipulate and store map related information.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •