Repository URL to install this package:
Version:
0.1.0pre1 ▾
|
app |
lib |
vendor |
MIT-LICENSE |
README.md |
Rakefile |
A superlight, standalone library to turn a div with data attributes into a Google Map.
Add a container to the page where you'd like the map. Mappyland uses data attributes to build the map.
markers
Required. Your records as json. See Serializing Records
options
Optional. Hash of Mappyland specific options.
Option name | Description |
---|---|
default_icon_path |
URL to default icon |
map-options
Optional. Hash that will be passed directly to the Google Map initializer.
<%= mappyland my_records_as_json, default_icon_path: asset_path('cool-marker.png'),
map_options: { minZoom: 3 } %>
Initialize it!
my_map = new Mappyland(document.getElementById('map-canvas'));
You're done! But, if you need to fiddle further:
my_map.map # The gMap object
my_map.markers # Array of gMap Markers
my_map.current_infowindow # Currently open infowindow, if any
my_map.bounds # Current gMap LatLngBounds of map
Mappyland expects a JSON array of objects with the following attributes
Attribute | Required? | Description |
---|---|---|
title |
Recommended | A title for the attribute |
latitude |
Required | Latitude of marker |
longitude |
Required | Longitude of marker |
icon_path |
Optional | Path to an icon to override default |
popup |
Optional | HTML content for the infoWindow |
ActiveModel::Serializers is easy and clean way to generate these.
Add this line to your application's Gemfile:
gem 'mappyland'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mappyland
Require mappyland in your application's javascript. This gem also includes libraries for clustering and spidering your markers. These features will automatically be enabled if their respective libraries are detected.
//= require mappyland
//= require marker_clusterer
//= require oms
The gem is available as open source under the terms of the MIT License.