All Projects → sylvainjule → kirby-locator

sylvainjule / kirby-locator

Licence: other
A simple map & geolocation field, built on top of open-source services and Mapbox. Kirby 3 only.

Programming Languages

Vue
7211 projects
SCSS
7915 projects
PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to kirby-locator

o.map
Open Street Map app - KaiOS
Stars: ✭ 51 (-38.55%)
Mutual labels:  map, leaflet, location
Googleapi
C# .NET Core Google Api (Maps, Places, Roads, Search, Translate). Supports all endpoints and requests / responses.
Stars: ✭ 346 (+316.87%)
Mutual labels:  geocoding, location, geolocation
Leaflet Locatecontrol
A leaflet control to geolocate the user.
Stars: ✭ 539 (+549.4%)
Mutual labels:  leaflet, location, mapbox
Pelias Android Sdk
Android sdk for pelias
Stars: ✭ 20 (-75.9%)
Mutual labels:  geocoding, location, geolocation
Maps
🌍🌏🌎 The whole world fits inside your cloud!
Stars: ✭ 253 (+204.82%)
Mutual labels:  map, location, mapbox
Mapbox.js
Mapbox JavaScript API, a Leaflet Plugin
Stars: ✭ 1,819 (+2091.57%)
Mutual labels:  map, leaflet, mapbox
Leaflet Geosearch
(Leaflet) GeoSearch / GeoCode provider
Stars: ✭ 666 (+702.41%)
Mutual labels:  geocoding, leaflet, geolocation
svelte-mapbox
MapBox Map and Autocomplete components for Svelte (or Vanilla JS)
Stars: ✭ 267 (+221.69%)
Mutual labels:  geocoding, location, mapbox
ReminderPro
ReminderPro(location, note, voice recording)
Stars: ✭ 27 (-67.47%)
Mutual labels:  map, location, mapbox
leaflet heatmap
简单的可视化湖州通话数据 假设数据量很大,没法用浏览器直接绘制热力图,把绘制热力图这一步骤放到线下计算分析。使用Apache Spark并行计算数据之后,再使用Apache Spark绘制热力图,然后用leafletjs加载OpenStreetMap图层和热力图图层,以达到良好的交互效果。现在使用Apache Spark实现绘制,可能是Apache Spark不擅长这方面的计算或者是我没有设计好算法,并行计算的速度比不上单机计算。Apache Spark绘制热力图和计算代码在这 https://github.com/yuanzhaokang/ParallelizeHeatmap.git .
Stars: ✭ 13 (-84.34%)
Mutual labels:  map, leaflet
Geodesy
Geodesy functions in Swift 🌎
Stars: ✭ 17 (-79.52%)
Mutual labels:  location, coordinates
traffic
Massively real-time traffic streaming application
Stars: ✭ 25 (-69.88%)
Mutual labels:  map, mapbox
simple-location
Adds Basic Location Support to Wordpress
Stars: ✭ 26 (-68.67%)
Mutual labels:  location, geolocation
telegram-nearby-map
Discover the location of nearby Telegram users 📡🌍
Stars: ✭ 329 (+296.39%)
Mutual labels:  map, location
localizator
Localizator is a flutter application that provides your current/given position,and gives you weather Forecasts
Stars: ✭ 46 (-44.58%)
Mutual labels:  map, location
leaflet-examples
🍁 A collection of examples of leaflet map usage
Stars: ✭ 90 (+8.43%)
Mutual labels:  geocoding, coordinates
map-with-me
🌍 Create collaborative maps with your friends (and enemies)
Stars: ✭ 23 (-72.29%)
Mutual labels:  map, location
mapus
A map tool with real-time collaboration 🗺️
Stars: ✭ 2,687 (+3137.35%)
Mutual labels:  map, leaflet
crisis-news-mapper
日本の災害関連ニュースをTwitterから収集して地図上にマッピングするFirebaseプロジェクト crisis.yuiseki.net
Stars: ✭ 13 (-84.34%)
Mutual labels:  leaflet, geolocation
discourse-locations
Tools for handling locations in Discourse
Stars: ✭ 31 (-62.65%)
Mutual labels:  location, geolocation

Kirby Locator

A simple map & geolocation field, built on top of open-source services and Mapbox.

screenshot


Overview

This plugin is completely free and published under the MIT license. However, if you are using it in a commercial project and want to help me keep up with maintenance, please consider making a donation of your choice or purchasing your license(s) through my affiliate link.


1. Installation

Download and copy this repository to /site/plugins/locator

Alternatively, you can install it with composer: composer require sylvainjule/locator


2. Setup

Out of the box, the field is set to use open-source services both for geocoding (Nominatim) and tiles-rendering (Positron), without any API-key requirements.

Keep in mind that these services are bound by strict usage policies, always double-check if your usage is compatible. Otherwise, please set-up the field to use Mapbox, see details below.

You can also directly enter latitude / longitude coordinates and bypass the geolocation (in a format such as: 15.23456, -30.67890).

mymap:
  label: Location
  type: locator

3. Tile-servers

3.1. Open-source / free tiles

tiles-opensource-2

You can pick one of the 4 free tile servers included:

  1. wikimedia (Terms of Use) → Public usage is now forbidden
  2. openstreetmap (Terms of Use)
  3. positron (default, Terms of Use [Under Free Basemaps Terms of Service])
  4. voyager (Terms of Use [Under Free Basemaps Terms of Service])
mymap:
  type: locator
  tiles: positron

You can also set this globally in your installation's main config.php, then you won't have to configure it in every blueprint:

return array(
    'sylvainjule.locator.tiles' => 'positron',
);

3.2. Mapbox tiles

tiles-mapbox-2

  1. mapbox.outdoorsmapbox/outdoors-v11 (default mapbox theme)
  2. mapbox.streetsmapbox/streets-v11
  3. mapbox.lightmapbox/light-v10
  4. mapbox.darkmapbox/dark-v10

In case your usage doesn't fall into the above policies (or if you don't want to rely on those services), you can set-up the field to use Mapbox' tiles.

You will have to set both the id of the tiles you want to use and your mapbox public key in your installation's main config.php:

return array(
    'sylvainjule.locator.mapbox.id'    => 'mapbox/outdoors-v11',
    'sylvainjule.locator.mapbox.token' => 'pk.vdf561vf8...',
);

You can now explicitely state in your blueprint that you want to use Mapbox tiles:

mymap:
  type: locator
  tiles: mapbox

You can also set this globally in your installation's main config.php, then you won't have to configure it in every blueprint:

return array(
    'sylvainjule.locator.tiles' => 'mapbox',
);

4. Geocoding services

4.1. Open-source API (Nominatim)

This is the default geocoding service. It doesn't require any additional configuration, but please double-check if your needs fit the Nominatim Usage Policy.

mymap:
  type: locator
  geocoding: nominatim

4.2. Mapbox API

In case your usage doesn't fall into the above policy (or if you don't want to use Nominatim), you can set-up the field to use Mapbox API.

If you haven't already, you will have to set your mapbox public key in your installation's main config.php:

return array(
    'sylvainjule.locator.mapbox.token' => 'pk.vdf561vf8...',
);

You can now explicitely state in your blueprint that you want to use Mapbox as a geocoding service:

mymap:
  type: locator
  geocoding: mapbox

You can also set this globally in your installation's main config.php, then you won't have to configure it in every blueprint:

return array(
    'sylvainjule.locator.geocoding' => 'mapbox',
);

5. Per-field options

5.1. center

The coordinates of the center of the map, if the field has no stored value. Default is {lat: 48.864716, lon: 2.349014} (Paris, FR).

mymap:
  type: locator
  center:
    lat: 48.864716
    lon: 2.349014

5.2. zoom

The min, default and max zoom values, where default will be the one used on every first-load of the map. Default is: {min: 2, default: 12, max: 18}.

mymap:
  type: locator
  zoom:
    min: 2
    default: 12
    max: 18

5.3. saveZoom

Whether the field should store the zoom level of the map when the marker was added, and use it as default zoom value afterwards. Default is false.

mymap:
  type: locator
  saveZoom: false

5.4. autoSaveZoom

Whether the field should store the zoom level of the map when the user changes the zoom manually, and use it as default zoom value afterwards. Default is false.

mymap:
  type: locator
  autoSaveZoom: false

5.5. display

The informations to be displayed in the panel. Note that it will only hide them from the panel view, they will still be stored (if available) in the .txt file. To be picked from lat, lon, number, address, postcode, city, region and country. Default includes them all.

If you are using Nominatim, the field also stores the OpenStreetMap ID under the osm key, which you can also display by adding it to the list.

If you don't want any information to show up, set it to false.

mymap:
  type: locator
  display:
    - lat
    - lon
    - number
    - address
    - postcode
    - city
    - region
    - country

5.6. draggable

If set to true, the marker will be repositionable in case search result isn't precise enough. After being moved, only the new lat and lng will be stored. Default is true.

5.7. autocomplete

If set to true, when Mapbox is used for geocoding, you will be presented up to 5 suggestions while typing your request. Default is true.

5.8. liststyle

liststyle

The style of the informations block, either columns or table. Default is table.

mymap:
  type: locator
  liststyle: table

5.9. marker

The color of the marker used, either dark, light or your own HEX value. Default is dark.

mymap:
  type: locator
  marker: dark

5.10. language

If this option is set with an ISO 639-1 code (en, fr, de, etc.), the geocoding service will return results in the requested language if available. Default is false.

mymap:
  type: locator
  language: false # or 'de' | 'fr' | 'en' | …

5.11. dblclick

Whether a double click on the map should trigger a zoom (zoom) or add a marker / move the existing marker to the coordinates of the click event (marker). Default is zoom.

mymap:
  type: locator
  dblclick: zoom # or 'marker'

6. Global options

The same options are available globally, which means you can set them all in your installation's config.php file and don't worry about setting it up individually afterwards:

return array(
    'sylvainjule.locator.center.lat'   => 48.864716,
    'sylvainjule.locator.center.lon'   => 2.349014,
    'sylvainjule.locator.zoom.min'     => 2,
    'sylvainjule.locator.zoom.default' => 12,
    'sylvainjule.locator.zoom.max'     => 18,
    'sylvainjule.locator.saveZoom'     => false,
    'sylvainjule.locator.autoSaveZoom' => false,
    'sylvainjule.locator.display'      => array('lat','lon','number','address','postcode','city','country'),
    'sylvainjule.locator.draggable'    => true,
    'sylvainjule.locator.autocomplete' => true,
    'sylvainjule.locator.liststyle'    => 'columns',
    'sylvainjule.locator.marker'       => 'dark',
    'sylvainjule.locator.language'     => false,
    'sylvainjule.locator.dblclick'     => 'zoom',
);

7. Front-end usage

The location data is stored as YAML and therefore needs to be decoded with the yaml method or using the toLocation method (see below):

$location = $page->mymap()->yaml();

Potential stored keys are:

  • lat (Latitude)
  • lon (Longitude)
  • number (Street number)
  • address (Street / road / place)
  • city (city / village)
  • region (region / state)
  • country (country)
  • osm (OpenStreetMap ID, if using Nominatim)

It is possible that the found location doesn't have one of those keys, which will therefore not be saved. It is important to always check if the key exists, and if it's not empty. Here's one way to do it:

$location = $page->mymap()->yaml();

if(!empty($location['postcode'])) {
    // there is a filled 'postcode' key
}
else {
    // there is no / an empty 'postcode' key
}

Alternatively, you can use the toLocation method to convert the value to a new collection, an use it kirby-style:

$location = $page->mymap()->toLocation();

// You now have access to
// $location->lat()
// $location->lon()
// ...

if($location->has('postcode')) {
    if($location->postcode()->isNotEmpty()) {
        // there is a filled 'postcode' key
    }
    else {
        // there is an empty 'postcode' key
    }
}
else {
  // there is no 'postcode' key
}

8. Credits

Services:

K2 fields:


9. License

MIT

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].