Create beautiful JavaScript maps with one line of Ruby
Create beautiful JavaScript maps with one line of Ruby
Create beautiful JavaScript maps with one line of Ruby. No more fighting with mapping libraries!
:fire: For static maps, check out Mapkick Static, and for charts, check out Chartkick
Add this line to your application’s Gemfile:
gem "mapkick-rb"Mapkick uses Mapbox GL JS v1. To use tiles from Mapbox, create a Mapbox account to get an access token and set ENV["MAPBOX_ACCESS_TOKEN"] in your environment (or set Mapkick.options[:access_token] in an initializer).
Then follow the instructions for your JavaScript setup:
In config/importmap.rb, add:
pin "mapkick/bundle", to: "mapkick.bundle.js"And in app/javascript/application.js, add:
import "mapkick/bundle"Run:
bun add mapkick
# or
yarn add mapkickAnd in app/javascript/application.js, add:
import "mapkick/bundle"In app/assets/javascripts/application.js, add:
//= require mapkick.bundlePoint map
Area map
Data can be an array
Or a URL that returns JSON (same format as above)
Use latitude or lat for latitude and longitude, lon, or lng for longitude
You can specify a label, tooltip, and color for each data point
{
latitude: ...,
longitude: ...,
label: "Hot Chicken Takeover",
tooltip: "5 stars",
color: "#f84d4d"
}Use geometry with a GeoJSON Polygon or MultiPolygon
You can specify a label, tooltip, and color for each data point
{
geometry: {type: "Polygon", coordinates: ...},
label: "Hot Chicken Takeover",
tooltip: "5 stars",
color: "#0090ff"
}Id, width, and height
Marker color
Show tooltips on click instead of hover
Allow HTML in tooltips (must sanitize manually)
Map style
Zoom and controls
Refresh data from a remote source every n seconds
Pass options directly to the mapping library
See the documentation for Mapbox GL JS for more info
To set options for all of your maps, create an initializer config/initializers/mapkick.rb with:
Mapkick.options[:height] = "400px"Download mapkick.bundle.js and include it manually.
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
To get started with development:
git clone https://github.com/ankane/mapkick.git
cd mapkick
bundle install
bundle exec rake testNo open issues yet, or sync has not completed.