All Projects → AugustMiller → kirby-map-field

AugustMiller / kirby-map-field

Licence: MIT license
🗺 An easy way to use maps and location data in Kirby.

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to kirby-map-field

Kirby Focus
Better image cropping for Kirby CMS
Stars: ✭ 170 (+314.63%)
Mutual labels:  kirby, kirby-plugin
laravel-mix-kirby
Laravel Mix helper for Kirby
Stars: ✭ 23 (-43.9%)
Mutual labels:  kirby, kirby-plugin
Kirby Visual Markdown
Visual Markdown Editor for Kirby CMS 2
Stars: ✭ 171 (+317.07%)
Mutual labels:  kirby, kirby-plugin
Kirby Imagekit
Asynchronous thumbnail creation and optimization for Kirby 2
Stars: ✭ 109 (+165.85%)
Mutual labels:  kirby, kirby-plugin
field-engineer
A Kirby field for complex field structures.
Stars: ✭ 49 (+19.51%)
Mutual labels:  kirby, kirby-plugin
Kirby Imageset
A flexible, responsive image component for Kirby 2, featuring lazy-loading, fancy placeholders and much more.
Stars: ✭ 122 (+197.56%)
Mutual labels:  kirby, kirby-plugin
kirby-highlighter
🌐 Server-side syntax highlighting for the Kirby code block & KirbyText
Stars: ✭ 18 (-56.1%)
Mutual labels:  kirby, kirby-plugin
Embed
Media embed plugin for Kirby 2 CMS
Stars: ✭ 73 (+78.05%)
Mutual labels:  kirby, kirby-plugin
kirby-hashed-assets
🛷 File name hashes support for css() and js() helpers. Without rewrite rules!
Stars: ✭ 15 (-63.41%)
Mutual labels:  kirby, kirby-plugin
kirby-podcast
A KirbyCMS-Podcast-Plugin
Stars: ✭ 22 (-46.34%)
Mutual labels:  kirby, kirby-plugin
Field Multiselect
Multiselect field for Kirby 2 CMS
Stars: ✭ 84 (+104.88%)
Mutual labels:  kirby, kirby-plugin
kirby-sortable
Making subpage managing a breeze
Stars: ✭ 82 (+100%)
Mutual labels:  kirby, kirby-plugin
Kirby Typography
Typographic enhancements for your Kirby-driven website.
Stars: ✭ 80 (+95.12%)
Mutual labels:  kirby, kirby-plugin
Kirby Autogit
⬢ Saves every change made via Kirby Panel to a Git repository
Stars: ✭ 147 (+258.54%)
Mutual labels:  kirby, kirby-plugin
Kirby Calendar Plugin
A plugin for the Kirby CMS to easily implement an event calendar.
Stars: ✭ 76 (+85.37%)
Mutual labels:  kirby, kirby-plugin
Kirby Uniform
A versatile Kirby plugin to handle web form actions.
Stars: ✭ 214 (+421.95%)
Mutual labels:  kirby, kirby-plugin
Select A Structure
A select field for Kirby populated by a structure field.
Stars: ✭ 44 (+7.32%)
Mutual labels:  kirby, kirby-plugin
Panel Bar
panelBar for Kirby 2 CMS
Stars: ✭ 70 (+70.73%)
Mutual labels:  kirby, kirby-plugin
kirby-highlight
Themeable server-side syntax highlighting for Kirby
Stars: ✭ 14 (-65.85%)
Mutual labels:  kirby, kirby-plugin
KirbyComments
[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
Stars: ✭ 68 (+65.85%)
Mutual labels:  kirby, kirby-plugin

Map Field

I've found that adding location data to Kirby CMS forms to be super useful.

Unfortunately, this isn't one of the many fields available to us, out of the box.

Features

  • Familiar Google Maps UI
  • Discrete storage of location name, latitude and longitude
  • Geocoding of location names and addresses
  • Repositionable marker (in case search doesn't nail it)
  • Support for multiple map fields per form
  • Support for map fields within structure fields
  • Support for map fields in file forms
  • Easy to implement (See "Getting Started", below)
  • Customizable initial position and zoom— globally and on a per-field basis
  • Compatible with Kirby 2.3.0+

Kirby Map Field Screenshot

Getting Started

If you like the command line, adding this to your project is super easy.

Be sure you have a plugins folder in your site folder, then:

cd /path/to/your/project
git submodule add https://github.com/AugustMiller/kirby-map-field.git site/plugins/map

It's important that the folder be named map, because kirby looks for the plugin class's definition in a PHP file with the same name as the folder.

You can also directly download an archive of the current project state, rename the folder to map, and add it to the site/plugins folder of your project.

Once you've added the plugin, you can add a map field to your blueprints, like this:

fields:
  location:
    label: Location
    type: map
    center:
      lat: 45.5230622
      lng: -122.6764816
      zoom: 9
    help: >
      Move the pin wherever you'd like, or search for a location!

The center key allows you to customize the initial position and zoom level of the map interface.

You can also set global defaults, in your config.php:

c::set('map.defaults.lat', 45.5230622);
c::set('map.defaults.lng', -122.6764816);
c::set('map.defaults.zoom', 9);

These options will be overridden by any set on individual fields. Without either configured, it will default to hard-coded values.

Keys

Google recently announced that all usage must be accompanied by a valid browser key. This means that in order to use the Maps and Geocoding APIs, you must apply for a key in Google's Developer Console/API Manager, and add it to your installation's configuration file:

c::set('map.key', 'your-browser-key');

Access to the Maps API is free up to 25,000 loads per day. Be aware that you will need to manually enable both the JS Maps API and the Geocoding API individually.

Usage

The Map Field stores data in YAML.

You must manually transform the field to an associative array by calling the yaml field method.

The resulting array can be used just like any other:

$page->location()->yaml()['lat'];
// Or!
$location = $page->location()->yaml();
echo $location['lng']; # => -122.6764816

Properties address, lat and lng should exist in the decoded object, but may be empty.

Kirby creator Bastian Allgeier recently created the Geo Plugin, which is a great toolkit for working with coordinates. Check it out!

🌳

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].