# 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: * `event_map.layout` is the name of the layout used by the controller ## 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. ### 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` here only 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: <r:title />

Make sure that `Radiant::Config['event_map.layout']` matches exactly the _name_ of this layout. ### javascript compatibility The map javascript is generated by the EventVenuesController using `app/views/event_venues/index.js.erb`. It provides a `build_map_and_markers` method and the minimal jQuery hook required to populate #map_canvas when the DOM loads. If you're not using jQuery you should find it straightforward to call `build_map_and_markers(div element)` from another script, and in that case you don't have to use our naming scheme either. ### Displaying a map on a normal radiant page If you omit the calendar attribute then all future events will be displayed. The map will be presented in a `div#map_canvas` to which your stylesheet will need to give dimensions (and any text styles you want to apply the location bubbles). At the moment you don't get any other control of displayed events, but soon the radius tag will support all the usual period specifications. ### 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-2010 Will at spanner.org. Released under the same terms as Radiant and/or Rails.