# Event Map Extension for Radiant
This extension adds mapping to the [event_calendar](http://github.com/radiant/radiant-event-calendar-extension). It will geocode your events automatically based on the address of the venue, or you can supply a postal code, UK postcode or grid reference for greater precision.
Events can be displayed on a google map and you can create links to bing or google maps that display the location of each event.
## Installation
Should be straightforward:
script/extension install event_map
or as a gem:
gem install radiant-event_map-extension
## Requirements
* [event_calendar](http://github.com/radiant/radiant-event-calendar-extension) extension
* [layouts](http://github.com/squaretalent/radiant-layouts-extension) or [share_layouts](http://github.com/radiant/radiant-share-layouts-extension) extension
* [geokit](http://geokit.rubyforge.org/) gem
## Configuration
There is one required config setting if you're using the full-page map controller:
* `event_map.layout` is the name of the layout used by the controller
If you're only using the `events:googlemap` radius tag then this isn't required.
## Basic Usage
### Linking to maps
We override the `url` method of EventVenue to return a map link if no other url is defined. The format of those links is determined by the link template stored in the config setting `event_map.link_format`. The markers :lat, :lng and :title will be replaced with the the correct value for each event venue.
There are also two shortcuts:
* 'google' is the default and equivalent to `http://maps.google.com/maps?q=:lat+:lng+(:title)` and will drop a pin on a google map.
* 'bing' is equivalent to `http://www.bing.com/maps/?v=2&cp=:lat~:lng&rtp=~pos.:lat_:lng_:title&lvl=15&sty=s&eo=0`, which will display a 1:25000 ordnance survey map (if you're in the UK) with a destination flag at your chosen point.
### Placing a map on one of your pages
For simple uses this radius tag might suffice:
For more searchability you need to use the full-page map controller.
### Displaying a map page
Create a layout that includes a `map_canvas` div and these page parts:
* `map_js` is required. It brings in the javascripts (and can be used in the header or at the end of the page as you prefer)
* `title` is the page title and can also be shown with `r:title`
* `faceting` gives the option to remove any date filters that have been applied. If you add the `taggable_events` extension it gets more useful.
Here's a starting point:
Make sure that `Radiant::Config['event_map.layout']` matches exactly the _name_ of this layout.
### custom markers
To display a different marker for (events in) each calendar, set `Radiant::Config['event_map.use_calendar_icons?']` to true and then create shadow and marker files at paths like these:
* /images/map_icons/slug.png
* /images/map_icons/slug_shadow.png
where 'slug' is the slug of each calendar. Basic pin and shadow images are included for you to modify and name appropriately.
If a venue has several events then the first will event will set the marker.
NB. we're not doing anything fancy here with offsets or masks: if you need that kind of detail then a bit more javascript is required.
### javascript compatibility
The map javascript is generated by the EventVenuesController using `app/views/event_venues/index.js.erb`. You should find that it automatically populates the map with or without jquery present.
### JSON interface
If you don't want to use the included scripts, you can skip that whole mechanism and work with the event data instead. EventVenuesController provides a simple JSON interface. Usually it's at /map and looks for addresses like this:
/map everything
/map/2010 events in 2010
/map/2010/12/ events in December 2010
/map/2010/12/12 events on 12 December 2010
If you're using `taggable_events` then we also inherit the tag-faceting interface here.
## Bugs and features
[Github issues](http://github.com/spanner/radiant-event_map-extension/issues) please, or for little things an email or github message is fine.
## Author & Copyright
Copyright 2008-2011 Will at spanner.org.
Released under the same terms as Radiant and/or Rails.