• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ayastreb/jekyll-maps: Embed maps with filterable locations in Jekyll

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ayastreb/jekyll-maps

开源软件地址:

https://github.com/ayastreb/jekyll-maps

开源编程语言:

Ruby 86.7%

开源软件介绍:

Jekyll Maps

Gem Version Build Status Code Climate Test Coverage Dependency Status

Jekyll Maps is a plugin that allows you to easily create different maps on your Jekyll site pages. It allows you to select which points to display on the map with different filters.

GoogleMaps Marker Clusterer can be used if you have many points within close proximity.

Installation

  1. Add the following to your site's Gemfile:
gem 'jekyll-maps'
  1. Add the following to your site's _config.yml:
plugins:
  - jekyll-maps

Usage

Configure Google API Key

To be able to use Google Maps you need to obtain API Key.

Once you have your API Key you need to add it to Jekyll's _config.yml:

maps:
  google:
    api_key: <YOUR_KEY>

Data Source

First, add location information to your posts YAML front-matter:

location:
  latitude: 51.5285582
  longitude: -0.2416807

You can specify multiple locations per post:

location:
  - latitude: 51.5285582
    longitude: -0.2416807
  - latitude: 52.5285582
    longitude: -2.2416807
  - title: custom marker title
    image: custom marker image
    url: custom marker url
    latitude: 51.5285582
    longitude: -0.2416807

Alternatively, you can add location info to your custom collection's documents or even in data files:

- title: Paris
  url: http://google.fr
  location:
    latitude: 48.8587741
    longitude: 2.2074741

- title: Madrid
  url: http://google.es
  location:
    latitude: 40.4378698
    longitude: -3.8196204

By default this plugin will display location from the page it's placed on:

{% google_map %}

But you can use src attribute to load locations from other places, like posts, collections or data files!

For example, this map will show locations from all posts from 2016:

{% google_map src="_posts/2016" %}

This map will show locations from a collection called 'my_collection':

{% google_map src="_collections/my_collection" %}

This map will show locations from all data files located in 'my_points' sub-folder:

{% google_map src="_data/my_points" %}

You can configure map's dimensions and assign custom CSS class to the element:

{% google_map width="100%" height="400" class="my-map" %}

You can also just set marker coordinates directly in tag attributes:

{% google_map latitude="48.8587741" longitude="2.2074741" marker_title="My Location" marker_img="/img.jpg" marker_url="/my-location.html" %}

This will create a map with single marker in given location. marker_title, marker_img and marker_url attributes are optional and current page's data will be used by default.

Filters

You can also filter which locations to display on the map!
For instance, following tag will only display locations from documents which have lang: en in their front-matter data.

{% google_map src="_posts" lang="en" %}

Marker Cluster

By default Marker Clusterer is enabled. If you have many markers on the map, it will group them and show icon with the count of markers in each cluster - see example.

If you don't want to use marker cluster, you can disable it globally in _config.yml:

maps:
  google:
    marker_cluster:
      enabled: false

Or you can disable it per single map tag:

{% google_map no_cluster %}

If you have any questions or proposals - open up an issue!

Examples

Want to see it in action? Check out Demo Page!

Contributing

  1. Fork it (https://github.com/ayastreb/jekyll-maps/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

MIT. Feel free to use, copy or distribute it.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap