diff --git a/.travis.yml b/.travis.yml
index 608914bf..71477ad5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
rvm:
- - 2.0.0-p195
+ - 2.0.0
script:
- "rake db:migrate RAILS_ENV=test"
diff --git a/Gemfile b/Gemfile
index f8d64446..0ba8099d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -33,7 +33,7 @@ gem 'nokogiri'
gem 'oauth'
gem 'omniauth'
gem 'omniauth-evernote'
-gem 'paper_trail', github: 'airblade/paper_trail', branch: 'master'
+gem 'paper_trail', '>= 3.0.0.beta1'
gem 'pjax_rails'
gem 'rails-timeago'
gem 'safe_yaml'
@@ -54,7 +54,7 @@ gem 'wikipedia-client'
group :development do
gem 'better_errors'
gem 'binding_of_caller'
- gem 'capistrano'
+ gem 'capistrano', '2.15.5'
gem 'factory_girl_rails'
gem 'flog'
gem 'fuubar'
diff --git a/Gemfile.lock b/Gemfile.lock
index f13f1918..836cfe27 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -6,20 +6,12 @@ GIT
compass-rails (1.0.3)
compass (>= 0.12.2, < 0.14)
-GIT
- remote: git://github.com/airblade/paper_trail.git
- revision: 548577711801af19c31125a0559eeafea2bcd58b
- branch: master
- specs:
- paper_trail (3.0.0.beta1)
- activerecord (>= 3.0, < 5.0)
-
GIT
remote: git://github.com/norman/friendly_id.git
- revision: 495b5cd0b395a2eabb8b00bd244e589d99de105a
+ revision: 2764077e3af32a88114d68c75e20ef738e4fa829
branch: master
specs:
- friendly_id (5.0.0.rc3)
+ friendly_id (5.0.0)
activerecord (~> 4.0.0)
GIT
@@ -32,7 +24,7 @@ GIT
GIT
remote: https://github.com/sferik/twitter.git
- revision: a5aaf321fcdf40a576d3794aed5921322b87163a
+ revision: 035fe9eaffddca2c1c81b2a3b7c5775c80f762e6
specs:
twitter (5.0.0.rc.1)
buftok (~> 0.1.0)
@@ -91,10 +83,12 @@ GEM
buftok (0.1)
builder (3.1.4)
cancan (1.6.10)
- capistrano (3.0.0)
- i18n
- rake (>= 10.0.0)
- sshkit (>= 0.0.23)
+ capistrano (2.15.5)
+ highline
+ net-scp (>= 1.0.0)
+ net-sftp (>= 2.0.0)
+ net-ssh (>= 2.0.14)
+ net-ssh-gateway (>= 1.1.0)
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
@@ -176,9 +170,9 @@ GEM
ruby-progressbar (~> 1.0)
gmaps4rails (1.5.6)
god (0.13.3)
- guard (2.0.4)
+ guard (2.1.0)
formatador (>= 0.2.4)
- listen (~> 2.0)
+ listen (~> 2.1)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
@@ -192,9 +186,9 @@ GEM
em-websocket (~> 0.5)
guard (~> 2.0)
multi_json (~> 1.8)
- guard-rspec (3.1.0)
- guard (>= 1.8)
- rspec (~> 2.13)
+ guard-rspec (4.0.1)
+ guard (~> 2.0)
+ rspec (~> 2.14)
guard-rubocop (1.0.0)
guard (~> 2.0)
rubocop (~> 0.10)
@@ -206,6 +200,7 @@ GEM
guard (>= 1.1)
spork (>= 0.8.4)
hashie (2.0.5)
+ highline (1.6.20)
hike (1.2.3)
http (0.5.0)
http_parser.rb
@@ -227,7 +222,7 @@ GEM
addressable (~> 2.3)
libnotify (0.8.2)
ffi (>= 1.0.11)
- listen (2.0.4)
+ listen (2.1.1)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
@@ -243,12 +238,16 @@ GEM
subexec (~> 0.2.1)
mini_portile (0.5.1)
minitest (4.7.5)
- multi_json (1.8.1)
+ multi_json (1.8.2)
multi_xml (0.5.5)
multipart-post (1.2.0)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
+ net-sftp (2.1.2)
+ net-ssh (>= 2.6.5)
net-ssh (2.7.0)
+ net-ssh-gateway (1.2.0)
+ net-ssh (>= 2.6.5)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
oauth (0.4.7)
@@ -263,6 +262,8 @@ GEM
oauth
omniauth (~> 1.0)
orm_adapter (0.4.0)
+ paper_trail (3.0.0.beta1)
+ activerecord (>= 3.0, < 5.0)
parser (2.0.0)
ast (~> 1.1)
slop (~> 3.4, >= 3.4.5)
@@ -316,11 +317,11 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
- rspec-core (2.14.5)
+ rspec-core (2.14.6)
rspec-expectations (2.14.3)
diff-lcs (>= 1.1.3, < 2.0)
rspec-instafail (0.2.4)
- rspec-mocks (2.14.3)
+ rspec-mocks (2.14.4)
rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
@@ -337,8 +338,8 @@ GEM
sexp_processor (~> 4.1)
safe_yaml (0.9.7)
sass (3.2.12)
- sass-rails (4.0.0)
- railties (>= 4.0.0.beta, < 5.0)
+ sass-rails (4.0.1)
+ railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
settingslogic (2.0.9)
@@ -367,15 +368,11 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sprockets-rails (2.0.0)
+ sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
- sshkit (1.0.0)
- net-scp
- net-ssh
- term-ansicolor
subexec (0.2.3)
susy (1.0.9)
compass (>= 0.12.2)
@@ -409,7 +406,7 @@ GEM
vcr (2.6.0)
warden (1.2.3)
rack (>= 1.0)
- webmock (1.14.0)
+ webmock (1.15.0)
addressable (>= 2.2.7)
crack (>= 0.3.2)
whenever (0.8.4)
@@ -429,7 +426,7 @@ DEPENDENCIES
binding_of_caller
breadcrumbs_on_rails
cancan
- capistrano
+ capistrano (= 2.15.5)
capybara
coffee-rails
compass-h5bp
@@ -470,7 +467,7 @@ DEPENDENCIES
oauth
omniauth
omniauth-evernote
- paper_trail!
+ paper_trail (>= 3.0.0.beta1)
pg
pjax_rails
rails (= 4.0.0)
diff --git a/app/assets/javascripts/head_scripts.js b/app/assets/javascripts/head_scripts.js
new file mode 100644
index 00000000..0c1bb8aa
--- /dev/null
+++ b/app/assets/javascripts/head_scripts.js
@@ -0,0 +1,7 @@
+// This is a manifest for javascripts that need to be in the head section of your layouts.
+// Only modernizr and polyfills should be here. Anything else should delay initialization until after window.onload.
+//
+// modernizer.minimal or modernizer.dev or customise your own at http://modernizr.com/download
+//= require modernizr.minimal
+//= require gmaps4rails/gmaps4rails.base
+//= require gmaps4rails/gmaps4rails.googlemaps
diff --git a/app/assets/javascripts/nembrot.document.js.coffee b/app/assets/javascripts/nembrot.document.js.coffee
index 3c0b619e..adfd21e5 100644
--- a/app/assets/javascripts/nembrot.document.js.coffee
+++ b/app/assets/javascripts/nembrot.document.js.coffee
@@ -38,7 +38,7 @@ _place_annotations_do = () ->
annotations.each (i) ->
new_top = $('a[id=annotation-mark-' + (i + 1) + ']').offset().top
corrected_top = (if new_top <= minimum then minimum else new_top)
- minimum = new_top + $(this).outerHeight(true)
+ minimum = corrected_top + $(this).outerHeight(true)
$(this).offset top: corrected_top
maximum = $('#text').offset().top + $('#text').outerHeight(false)
@@ -58,6 +58,16 @@ _media_query = (media_query_string) ->
style = style.content.replace /"/g, ''
style is media_query_string
+reload_shares = () ->
+ FB.XFBML.parse()
+ gapi.plusone.go()
+ twttr.widgets.load()
+
+fix_facebook_dialog = () ->
+ $('.fb-like span').css('width', $('.fb-like').data('width'))
+ alert('innit')
+
+
# Document hooks ******************************************************************************************************
$ ->
@@ -65,6 +75,7 @@ $ ->
$(document).on 'pjax:end', ->
content_initializers()
+ content_initializers_reload_only()
$(window).on 'resize', ->
resize_initializers()
@@ -83,6 +94,9 @@ document_initializers = () ->
$(document).on 'mousedown', "a[href$='.pdf'], a[href$='.zip']", (event) ->
track_download(this.href.toString().replace(/^https?:\/\/([^\/?#]*)(.*$)/, '$2'), 'Download', this.text, event.which)
+ $(document).on 'click', '.fb-like', ->
+ fix_facebook_dialog()
+
content_initializers()
content_initializers = () ->
@@ -91,5 +105,8 @@ content_initializers = () ->
track_page_view()
resize_initializers()
+content_initializers_reload_only = () ->
+ reload_shares()
+
resize_initializers = () ->
place_annotations()
diff --git a/app/assets/javascripts/polyfills.js b/app/assets/javascripts/polyfills.js
deleted file mode 100644
index 7d7b7ab0..00000000
--- a/app/assets/javascripts/polyfills.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// This is a manifest for javascript polyfills that will be included
-// in the head section of your layouts.
-//
-// polyfill (n): a JavaScript shim that replicates the standard API for older browsers.
-//
-//
-// modernizer.minimal or modernizer.dev or customise your own at http://modernizr.com/download
-//= require modernizr.minimal
\ No newline at end of file
diff --git a/app/assets/stylesheets/themes/default.css.sass b/app/assets/stylesheets/themes/default.css.sass
index 90619cbb..8b28e422 100644
--- a/app/assets/stylesheets/themes/default.css.sass
+++ b/app/assets/stylesheets/themes/default.css.sass
@@ -251,6 +251,7 @@ footer
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
figure
+ +reset
&.image
img
clear: both
@@ -293,7 +294,7 @@ iframe
font:
size: $small-font-size + 1px
line-height: $line-height * 2/3
- text-align: left
+ text-align: left !important
text-indent: 0
ol
padding-left: $text-indent
@@ -316,20 +317,24 @@ iframe
.count
color: $count-color
-.notes, .citations
- li
- +body-font
- +clearfix
- display: block
- margin-bottom: $line-height
- h2
- display: inline
- font:
- family: $headline-font-family
- size: $body-font-size
- weight: normal
- &:last-child
- margin-bottom: 0
+.map_container
+ +reset
+ #map
+ +reset
+ background-color: $map-background-color
+ color: $map-font-color
+ img, object, embed
+ max-width: none
+ .infowindow
+ +blurb(3, 3)
+
+.notes li, .citations li, .map-infowindow
+ +body-font
+ +clearfix
+ display: block
+ margin-bottom: $line-height
+ &:last-child
+ margin-bottom: 0
article
.tags
@@ -371,37 +376,38 @@ blockquote
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#text
- +body-font
- p
- margin: 0
- text-indent: $text-indent
- &:first-of-type
- text-indent: 0
- a
- &[href*=http]:after
- display: none
- &[id*=annotation-mark]
- font-size: $small-font-size - 2px
- vertical-align: super
- blockquote
- +body-font-citation
- margin: ($line-height / 2) $text-indent
- section
- margin-bottom: $line-height
- h2
- color: $body-font-color
- display: block
+ .body, .annotations
+ +body-font
+ p
margin: 0
- font:
- family: $headline-font-family
- size: $body-font-size
- &.body section:first-of-type
- h2
+ text-indent: $text-indent
+ &:first-of-type
+ text-indent: 0
+ a
+ &[href*=http]:after
display: none
- &:last-of-type
- margin-bottom: 0
- p:first-of-type
- text-indent: 0
+ &[id*=annotation-mark]
+ font-size: $small-font-size - 2px
+ vertical-align: super
+ blockquote
+ +body-font-citation
+ margin: ($line-height / 2) $text-indent
+ section
+ margin-bottom: $line-height
+ h2
+ color: $body-font-color
+ display: block
+ margin: 0
+ font:
+ family: $headline-font-family
+ size: $body-font-size
+ &:first-of-type
+ h2
+ display: none
+ &:last-of-type
+ margin-bottom: 0
+ p:first-of-type
+ text-indent: 0
.notes
li
@@ -470,7 +476,7 @@ blockquote
.tags-map
#map
height: $line-height * 20
- margin-bottom: $line-height * 2/3
+ margin-bottom: $line-height
.statistics
clear: both
@@ -482,7 +488,7 @@ blockquote
&.cloud
+inline-block-list
-.tags-show
+.tags-show, .tags-map
h1:before
+icon-tag
color: $secondary-color
@@ -543,7 +549,7 @@ blockquote
.hello_world,
footer
margin: 0 auto $line-height auto
- overflow: hidden
+ // overflow: hidden
// +debug-bg
#main
@@ -557,6 +563,19 @@ blockquote
// We don't use horizontal list here because it cancels all margins
display: inline-block
margin-right: 5px
+ a[href*='twitter.com/intent']
+ background-color: #9ff
+ &:before
+ +icon-twitter
+ +icon-medium
+ &:after
+ // display: none
+ content: ''
+ .share
+ iframe
+ margin-bottom: 0
+ li.fb-like
+ overflow: visible
form
+span-columns(6)
@@ -619,11 +638,9 @@ blockquote
figcaption
display: none
.map_container
- position: relative
#map
- background-color: $map-background-color
- color: $map-font-color
height: $line-height * 6
+ margin-bottom: $line-height * 2/3
section#content
#text
@@ -645,7 +662,6 @@ blockquote
font:
size: $small-font-size + 1px
.side-annotations
- +span-columns(4)
ol
display: block
padding-left: 0
@@ -721,8 +737,7 @@ blockquote
+pass_media_query('screen-and-min-width-1024px')
iframe
- +span-columns(9)
- +suffix(3)
+ +span-columns(9, 9)
article
header
@@ -802,12 +817,9 @@ blockquote
+pass_media_query('screen-and-min-width-1200px')
#tools
- left: ($text-indent / 2)
+ bottom: $line-height
+ left: $text-indent
margin: 0
- position: absolute
- top: ($line-height / 2)
+ position: fixed
+ // top: $line-height * 6
width: $column-width * 3px
-
- // This file was generated by html5-rails
- // https://github.com/sporkd/html5-rails
- // Upgrade with: $ rails generate html5:install
diff --git a/app/assets/stylesheets/themes/mixins.default.css.sass b/app/assets/stylesheets/themes/mixins.default.css.sass
index 4318a085..e62dcc52 100644
--- a/app/assets/stylesheets/themes/mixins.default.css.sass
+++ b/app/assets/stylesheets/themes/mixins.default.css.sass
@@ -11,6 +11,12 @@
=blurb($lines: 3, $image-width: 0, $context: $total-columns)
+font-color
+ h2
+ display: inline
+ font:
+ family: $headline-font-family
+ size: $body-font-size
+ weight: normal
a
display: block
height: $line-height * $lines
@@ -32,6 +38,7 @@
img, iframe
height: auto
margin: 0
+ padding-right: 0
position: absolute
right: 0
width: columns($image-width, $context)
@@ -84,6 +91,19 @@
line-height: 0
visibility: hidden
+=reset
+ margin: 0
+ padding: 0
+ a
+ &:before
+ content: ''
+ margin: 0
+ padding: 0
+ &:after
+ content: ''
+ margin: 0
+ padding: 0
+
=rule-once($line-color: $furniture-color, $line-thickness: 1px, $line-top: 50%)
position: relative
z-index: 1
diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb
index 54c4b6c2..7c0f3a54 100644
--- a/app/controllers/notes_controller.rb
+++ b/app/controllers/notes_controller.rb
@@ -3,9 +3,26 @@ class NotesController < ApplicationController
add_breadcrumb I18n.t('notes.index.title'), :notes_path
def index
-
@notes = Note.publishable.listable.blurbable.load
@word_count = @notes.sum(:word_count)
+ @map = @notes.to_gmaps4rails
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @notes }
+ end
+ end
+
+ def map
+ @notes = Note.publishable.listable.load
+ @word_count = @notes.sum(:word_count)
+
+ @map = @notes.to_gmaps4rails do |note, marker|
+ marker.infowindow render_to_string(partial: '/notes/maps_infowindow', locals: { note: note})
+ marker.title note.title
+ end
+
+ add_breadcrumb I18n.t('map'), notes_map_path
respond_to do |format|
format.html
@@ -16,6 +33,10 @@ def index
def show
@note = Note.publishable.find(params[:id])
@tags = @note.tags
+ @map_notes = @note.to_gmaps4rails
+ @map_images = @note.resources.to_gmaps4rails
+
+ @map = (JSON.parse(@map_notes) + JSON.parse(@map_images)).to_json # REVIEW
add_breadcrumb I18n.t('notes.show.title', id: @note.id), note_path(@note)
# add_breadcrumb I18n.t('notes.versions.show.title', sequence: @note.versions.size),
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 4f2e7900..be25b226 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -17,7 +17,8 @@ def show
@tag = Tag.find_by_slug(params[:slug])
@notes = Note.publishable.listable.blurbable.tagged_with(@tag.name)
@citations = Note.publishable.citations.tagged_with(@tag.name)
- @tags = Note.publishable.tag_counts_on(:tags)
+ @word_count = @notes.sum(:word_count)
+ @map = @notes.to_gmaps4rails
add_breadcrumb @tag.name, tag_path(params[:slug])
@@ -26,7 +27,26 @@ def show
format.json { render :json => @notes }
end
rescue
- flash[:error] = I18n.t('tags.show.not_found', slug: 'nonexistent')
- redirect_to tags_path
+ flash[:error] = I18n.t('tags.show.not_found', slug: 'nonexistent')
+ redirect_to tags_path
+ end
+
+ def map
+ @tag = Tag.find_by_slug(params[:slug])
+ @notes = Note.publishable.listable.mappable.tagged_with(@tag.name)
+ @word_count = @notes.sum(:word_count)
+
+ @map = @notes.to_gmaps4rails do |note, marker|
+ marker.infowindow render_to_string(partial: '/notes/maps_infowindow', locals: { note: note})
+ marker.title note.title
+ end
+
+ add_breadcrumb @tag.name, tag_path(params[:slug])
+ add_breadcrumb I18n.t('map'), tag_map_path(params[:slug])
+
+ respond_to do |format|
+ format.html
+ format.json { render :json => @tag }
+ end
end
end
diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb
index 996b31a1..41ed72c6 100644
--- a/app/helpers/formatting_helper.rb
+++ b/app/helpers/formatting_helper.rb
@@ -90,7 +90,7 @@ def linkify(text, links, citation_style)
path: link_path(link),
accessed_at: (timeago_tag link.updated_at)))
# We replace links in the body copy (look-arounds prevent us catching urls inside anchor tags).
- text.gsub!(/(?!<=")(#{ link.url })(?!=")/,
+ text.gsub!(/(? *<\/p>$/, '') # Removes empty paragraphs # FIXME
- text = hyper_conform(text)
+ text = hyper_conform(text) if Settings.styling.hyper_conform
text = text.gsub(/ +/m, ' ') # FIXME
.gsub(/ ?\, ?p\./, 'p.') # Clean up page numbers (we don't always want this) # language-dependent
.gsub(/"/, "\u201C") # Assume any remaining quotes are opening quotes.
@@ -126,7 +126,7 @@ def clean_up(text, clean_up_dom = true)
def clean_up_via_dom(text, unwrap_p = false)
text = text.gsub(/ +/m, ' ')
- text = hyper_conform(text)
+ text = hyper_conform(text) if Settings.styling.hyper_conform
dom = Nokogiri::HTML(text)
dom.css('a, h2, header, p, section').find_all.each { |e| e.remove if e.content.blank? }
dom.css('h2 p, cite cite').find_all.each { |e| e.replace e.inner_html }
@@ -135,7 +135,7 @@ def clean_up_via_dom(text, unwrap_p = false)
t.content = smartify(t.content)
# t.content = hyper_conform(t.content)
end
- dom = indent_dom(dom) if Settings.html.pretty
+ dom = indent_dom(dom) if Settings.html.pretty_body
unwrap_from_paragraph_tag(dom) if unwrap_p
dom.css('body').children.to_html.html_safe
end
diff --git a/app/helpers/resources_helper.rb b/app/helpers/resources_helper.rb
index 8d75d725..96f8fafc 100644
--- a/app/helpers/resources_helper.rb
+++ b/app/helpers/resources_helper.rb
@@ -36,7 +36,7 @@ def cut_image_binary(local_file_name, format, aspect_x, aspect_y, width, snap, g
file_name_template = image_record.template_location(aspect_x, aspect_y)
file_name_out = image_record.cut_location(aspect_x, aspect_y, width, snap, gravity, effects)
- # Shorthand: small integers are taken to be number of columns rather than absolute width
+ # Shorthand: small integers are taken to be number of columns rather than absolute width
width = column_width(width) if width <= Settings.styling.total_columns
# The height is derived from the aspect ratio and width.
diff --git a/app/models/book.rb b/app/models/book.rb
index ed7b959c..1d962ce6 100644
--- a/app/models/book.rb
+++ b/app/models/book.rb
@@ -70,6 +70,7 @@ def author_or_editor
end
def author_sort
+ return nil if author.blank? && editor.blank?
(author.blank? ? editor : author).gsub(/([^ ]+?) ?([^ ]*)$/, '\\2, \\1')
end
diff --git a/app/models/note.rb b/app/models/note.rb
index 12aeaff3..efb7172a 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -12,6 +12,7 @@ class Note < ActiveRecord::Base
has_and_belongs_to_many :links
acts_as_taggable_on :tags, :instructions
+ acts_as_gmappable process_geocoding: false, check_process: false
has_paper_trail on: [:update],
only: [:title, :body],
@@ -29,6 +30,7 @@ class Note < ActiveRecord::Base
scope :blurbable, -> { where('word_count > ?', (Settings.notes.blurb_length / Settings.lang.average_word_length)) }
scope :citations, -> { where(is_citation: true) }
scope :listable, -> { where(listable: true, is_citation: false) }
+ scope :mappable, -> { where('latitude IS NOT ?', nil) }
scope :maxed_out, -> { where('attempts > ?', Settings.notes.attempts).order('updated_at') }
scope :need_syncdown, -> { where('dirty = ? AND attempts <= ?', true, Settings.notes.attempts).order('updated_at') }
scope :publishable, -> { where(active: true, hide: false) }
@@ -96,6 +98,10 @@ def fx
fx.empty? ? nil : fx
end
+ def gmaps4rails_title
+ title
+ end
+
private
def external_updated_is_latest?
diff --git a/app/models/resource.rb b/app/models/resource.rb
index c1ec564f..a02007ee 100644
--- a/app/models/resource.rb
+++ b/app/models/resource.rb
@@ -7,6 +7,8 @@ class Resource < ActiveRecord::Base
belongs_to :note
+ acts_as_gmappable process_geocoding: false, check_process: false
+
scope :attached_images, -> { where('mime LIKE ? AND dirty = ?', 'image%', false).where(attachment: nil) }
scope :attached_files, -> { where('mime = ? AND dirty = ?', 'application/pdf', false) }
scope :need_syncdown, -> { where('dirty = ? AND attempts <= ?', true, Settings.notes.attempts).order('updated_at') }
@@ -82,6 +84,10 @@ def blank_location
File.join(Rails.root, 'public', 'resources', 'cut', "blank.#{ file_ext }")
end
+ def gmaps4rails_title
+ caption
+ end
+
# private
def make_local_file_name
diff --git a/app/views/application/_async_share_scripts.html.slim b/app/views/application/_async_share_scripts.html.slim
new file mode 100644
index 00000000..e8360cbb
--- /dev/null
+++ b/app/views/application/_async_share_scripts.html.slim
@@ -0,0 +1,29 @@
+javascript:
+ !function(d, s, id){
+ var js,
+ fjs = d.getElementsByTagName(s)[0],
+ p = /^http:/.test(d.location) ? 'http' : 'https';
+
+ if(!d.getElementById(id)) {
+ js = d.createElement(s);
+ js.id = id;
+ js.src = p + '://platform.twitter.com/widgets.js';
+ fjs.parentNode.insertBefore(js,fjs);
+ }
+ }(document, 'script', 'twitter-wjs');
+
+ !function(d, s, id){
+ var js, fjs = d.getElementsByTagName(s)[0];
+ if(!d.getElementById(id)) {
+ js = d.createElement(s);
+ js.id = id;
+ js.src = "//connect.facebook.net/#{ I18n.locale.to_s }/all.js#xfbml=1&appId=#{ Settings.facebook_app_id }";
+ fjs.parentNode.insertBefore(js, fjs);
+ }
+ }(document, 'script', 'facebook-jssdk');
+
+ (function() {
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
+ po.src = 'https://apis.google.com/js/plusone.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
+ })();
diff --git a/app/views/application/_head.html.slim b/app/views/application/_head.html.slim
index ffb8288e..49799e74 100644
--- a/app/views/application/_head.html.slim
+++ b/app/views/application/_head.html.slim
@@ -6,10 +6,15 @@ head
meta name="viewport" content="width=device-width" initial-scale="1.0" maximum-scale="1.0"
+ - if Settings.facebook_app_id
+ meta property="fb:app_id" content="#{ Settings.facebook_app_id }"
+
= display_meta_tags
= csrf_meta_tag
= stylesheet_link_tag 'application'
- = javascript_include_tag 'polyfills'
+ = javascript_include_tag 'head_scripts'
+
+ script src="//maps.google.com/maps/api/js?v=3.5&sensor=false"
diff --git a/app/views/application/_user_tools.html.slim b/app/views/application/_user_tools.html.slim
index 4e287ef9..e34af32f 100644
--- a/app/views/application/_user_tools.html.slim
+++ b/app/views/application/_user_tools.html.slim
@@ -4,13 +4,28 @@ nav#tools
h6= t('tools.title')
ul
- - if user_signed_in?
- li
- = link_to_unless_current_or_wrap current_user.email, edit_user_registration_path
- = link_to '', destroy_user_session_path, method: :delete, title: t('users.sessions.delete.title')
- - if current_user.admin?
- li= link_to_unless_current_or_wrap t('books.admin.title_no_mode'), books_admin_path
- li= link_to_unless_current_or_wrap t('links.admin.title'), links_admin_path
- - else
- li= link_to_unless_current_or_wrap t('tools.sign_in'), new_user_session_path
+ - if Settings.share
+ li.share
+ ul
+ li.fb-like data-colorscheme='light' data-layout='button_count' data-action='like' data-show-faces='false' data-send='false' data-width='450px'
+
+ li= link_to 'Tweet', 'https://twitter.com/share', class: 'twitter-share-button', data: { via: Settings.twitter_user_name }
+
+ li
+ div.g-plusone data-size='medium'
+
+ - if user_signed_in? && current_user.admin?
+ li.admin
+ ul
+ li= link_to_unless_current_or_wrap t('books.admin.title_no_mode'), books_admin_path
+ li= link_to_unless_current_or_wrap t('links.admin.title'), links_admin_path
+
+ li.user
+ ul
+ - if user_signed_in?
+ li
+ = link_to_unless_current_or_wrap current_user.email, edit_user_registration_path
+ = link_to '', destroy_user_session_path, method: :delete, title: t('users.sessions.delete.title')
+ - else
+ li= link_to_unless_current_or_wrap t('tools.sign_in'), new_user_session_path
diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim
index 9a12cee8..79fcd898 100644
--- a/app/views/layouts/application.html.slim
+++ b/app/views/layouts/application.html.slim
@@ -23,3 +23,5 @@ html class="no-js" lang="#{ I18n.locale }"
= javascript_include_tag 'application'
= render 'google_analytics' unless Settings.google_analytics_key.blank?
+
+ = render 'async_share_scripts' if Settings.share
diff --git a/app/views/notes/_maps_infowindow.html.slim b/app/views/notes/_maps_infowindow.html.slim
new file mode 100644
index 00000000..f3105416
--- /dev/null
+++ b/app/views/notes/_maps_infowindow.html.slim
@@ -0,0 +1,11 @@
+- blurb_length = blurb_length || Settings.notes.blurb_length
+- headline, blurb = blurb(note.headline, note.clean_body, blurb_length)
+- image = note.resources.attached_images.first unless note.has_instruction?('hide_image')
+
+.infowindow
+ = link_to note_path(note), lang: lang_attr(note.lang), dir: dir_attr(note.lang) do
+ - if image
+ figure.image= image_tag(cut_image_binary_path(image, type: :thumbnail), alt: strip_tags(image.description))
+
+ h2 = blurbify(headline, note.books, note.links)
+ = blurbify(blurb, note.books, note.links)
diff --git a/app/views/notes/index.html.slim b/app/views/notes/index.html.slim
index 42f8394c..0a70ba9d 100644
--- a/app/views/notes/index.html.slim
+++ b/app/views/notes/index.html.slim
@@ -16,3 +16,4 @@ div class="#{ controller.controller_name }-#{ controller.action_name }"
aside.statistics
= t('.statistics', count: number_with_delimiter(@notes.size), word_count: number_with_delimiter(@word_count))
+ = t('.other_view_html', path: notes_map_path) unless @map.empty?
diff --git a/app/views/notes/map.html.slim b/app/views/notes/map.html.slim
new file mode 100644
index 00000000..1fd72c8c
--- /dev/null
+++ b/app/views/notes/map.html.slim
@@ -0,0 +1,19 @@
+- document_title = "#{ t('.title') } | #{ t('site.title') }"
+- set_meta_tags title: document_title,
+ description: '',
+ open_graph: { title: document_title },
+ noindex: true
+
+div class="#{ controller.controller_name }-#{ controller.action_name }"
+
+ nav = render_breadcrumbs builder: ::OrderedListBuilder
+
+ section
+
+ = render 'header', title: t('.title'), document_title: document_title
+
+ = render 'shared/map', map: @map
+
+ aside.statistics
+ = t('.statistics', count: number_with_delimiter(@notes.size), word_count: number_with_delimiter(@word_count))
+ = t('.other_view_html', path: notes_path)
diff --git a/app/views/notes/show.html.slim b/app/views/notes/show.html.slim
index a367ee67..4d1094bf 100644
--- a/app/views/notes/show.html.slim
+++ b/app/views/notes/show.html.slim
@@ -29,3 +29,5 @@ div class="#{ controller.controller_name }-#{ controller.action_name }"
/ REVIEW: Consider listing books and links here but avoid duplication from side-notes
= render 'versions_list', note: @note
+
+ = render 'shared/map', map: @map unless @map.empty?
diff --git a/app/views/shared/_map.html.slim b/app/views/shared/_map.html.slim
new file mode 100644
index 00000000..0acdf410
--- /dev/null
+++ b/app/views/shared/_map.html.slim
@@ -0,0 +1,13 @@
+figure= gmaps({last_map: false})
+
+javascript:
+ Gmaps.map = new Gmaps4RailsGoogle();
+ Gmaps.load_map = function() {
+ Gmaps.map.map_options.maxZoom = 15;
+ Gmaps.map.initialize();
+ Gmaps.map.markers = #{ raw map };
+ Gmaps.map.create_markers();
+ Gmaps.map.adjustMapToBounds();
+ Gmaps.map.callback();
+ };
+ Gmaps.loadMaps();
diff --git a/app/views/shared/_notes_list.html.slim b/app/views/shared/_notes_list.html.slim
index 869e0ef8..5d553d3c 100644
--- a/app/views/shared/_notes_list.html.slim
+++ b/app/views/shared/_notes_list.html.slim
@@ -8,7 +8,7 @@ section.notes
- blurb_length = blurb_length || Settings.notes.blurb_length
- headline, blurb = blurb(note.headline, note.clean_body, blurb_length)
- - image = note.resources.attached_images.first
+ - image = note.resources.attached_images.first unless note.has_instruction?('hide_image')
li
= link_to note_path(note), lang: lang_attr(note.lang), dir: dir_attr(note.lang) do
diff --git a/app/views/tags/map.html.slim b/app/views/tags/map.html.slim
new file mode 100644
index 00000000..db9646ab
--- /dev/null
+++ b/app/views/tags/map.html.slim
@@ -0,0 +1,18 @@
+- document_title = "#{ t('.title', name: @tag.name) } | #{ t('site.title') }"
+- set_meta_tags title: document_title,
+ description: '',
+ open_graph: { title: document_title }
+
+div class="#{ controller.controller_name }-#{ controller.action_name }"
+
+ nav = render_breadcrumbs builder: ::OrderedListBuilder
+
+ section
+
+ = render 'header', title: t('.title_short', name: @tag.name), document_title: document_title
+
+ = render 'shared/map', map: @map unless @map.empty?
+
+ aside.statistics
+ = t('.statistics', count: number_with_delimiter(@notes.size), word_count: number_with_delimiter(@word_count))
+ = t('.other_view_html', path: tag_path(@tag.slug))
diff --git a/app/views/tags/show.html.slim b/app/views/tags/show.html.slim
index ea352d4c..7e4d515e 100644
--- a/app/views/tags/show.html.slim
+++ b/app/views/tags/show.html.slim
@@ -13,4 +13,8 @@ div class="#{ controller.controller_name }-#{ controller.action_name }"
= render 'shared/notes_list', notes: @notes unless @notes.empty?
+ aside.statistics
+ = t('.statistics', count: number_with_delimiter(@notes.size), word_count: number_with_delimiter(@word_count))
+ = t('.other_view_html', path: tag_map_path(@tag.slug)) unless @map.empty?
+
= render 'citations/citations_list', citations: @citations, books: @books unless @citations.empty?
diff --git a/config/environments/production.rb b/config/environments/production.rb
index e61e8f3c..3c87a800 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -47,7 +47,7 @@
config.action_controller.asset_host = Settings.asset_host unless Settings.asset_host.blank?
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
- config.assets.precompile += %w( polyfills.js .svg .eot .woff .ttf )
+ config.assets.precompile += %w( head_scripts.js .svg .eot .woff .ttf )
# Add the fonts path
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
diff --git a/config/environments/staging.rb b/config/environments/staging.rb
index ef3c7192..9df9c5a7 100644
--- a/config/environments/staging.rb
+++ b/config/environments/staging.rb
@@ -47,7 +47,7 @@
config.action_controller.asset_host = Settings.asset_host unless Settings.asset_host.blank?
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
- config.assets.precompile += %w( polyfills.js .svg .eot .woff .ttf )
+ config.assets.precompile += %w( head_scripts.js .svg .eot .woff .ttf )
# Add the fonts path
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
diff --git a/config/locales/en.yml b/config/locales/en.yml
index e4b98943..b6fb4047 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,6 +1,7 @@
en:
back: 'Back'
+ map: 'Map'
auth:
success: "Your %{provider} key has been authenticated."
@@ -11,7 +12,7 @@ en:
email:
greeting: "Hi %{name}"
- signature: 'joegatt.net'
+ signature: 'nembrot.org'
site:
title: 'joegatt.net'
@@ -90,6 +91,11 @@ en:
index:
title: 'Notes'
statistics: "%{count} notes (%{word_count} words)."
+ other_view_html: " See map."
+ map:
+ title: 'Notes'
+ statistics: "%{count} mapped notes (%{word_count} words)."
+ other_view_html: " See list."
show:
title: "Note %{id}"
not_found: "Note %{id} is not available."
@@ -140,6 +146,14 @@ en:
title: "Tag: \"%{name}\""
title_short: "%{name}"
not_found: "Tag: %{slug} is not available."
+ statistics: "%{count} notes (%{word_count} words)."
+ other_view_html: " See map."
+ map:
+ title: 'Notes'
+ title_short: "%{name}"
+ not_found: "Tag: %{slug} is not available."
+ statistics: "%{count} mapped notes (%{word_count} words)."
+ other_view_html: " See list."
titlecase_exceptions:
articles: 'a an the'
diff --git a/config/services.settings.yml b/config/services.settings.yml
new file mode 100644
index 00000000..c3f64568
--- /dev/null
+++ b/config/services.settings.yml
@@ -0,0 +1,18 @@
+# All Nembrot settings go here except for secret strings
+
+defaults: &defaults
+ facebook_app_id: 142214389156795
+ google_analytics_key: 'UA-1346274-1'
+ twitter_user_name: nembrot
+
+development:
+ <<: *defaults
+
+test:
+ <<: *defaults
+
+staging:
+ <<: *defaults
+
+production:
+ <<: *defaults
diff --git a/config/settings.yml b/config/settings.yml
index 7012195b..7137f11c 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -2,19 +2,20 @@ defaults: &defaults
app_name: joegattnet_v3
version: 0.9
locale: en
+ share: true
admin:
name: Joe
- email: joe@joegatt.net
+ email: joe@nembrot.org
monitoring:
name: Joe
email: monitoring@joegatt.net
contact:
name: Joe
- email: joe@joegatt.net
+ email: joe@nembrot.org
mailer:
address: smtp.gmail.com
port: 587
- domain: mail.joegatt.net
+ domain: mail.nembrot.org
google_analytics_key: 'UA-1346274-1'
evernote:
server: https://sandbox.evernote.com
@@ -33,6 +34,7 @@ defaults: &defaults
required: ['__HOME']
html:
pretty: true
+ pretty_body: false
sort_attrs: true
tabsize: 2
format: html5
@@ -140,7 +142,7 @@ staging:
asset_host: http://a4.joegatt.org
evernote:
server: https://www.evernote.com
- notebooks: 85d8c66d-f0ee-4c56-acac-e30ab88ce0ce
+ notebooks: 2be62491-08b9-436a-b029-fb68a4b882bd
stream_binaries: false
synchronous: true
always_reset_on_create: true
@@ -154,7 +156,7 @@ production:
google_analytics_key: 'UA-16898823-1'
evernote:
server: https://www.evernote.com
- notebooks: 85d8c66d-f0ee-4c56-acac-e30ab88ce0ce
+ notebooks: 2be62491-08b9-436a-b029-fb68a4b882bd
stream_binaries: false
synchronous: false
always_reset_on_create: true
diff --git a/config/styling.settings.yml b/config/styling.settings.yml
index 65173a79..cc94a581 100644
--- a/config/styling.settings.yml
+++ b/config/styling.settings.yml
@@ -35,6 +35,7 @@ defaults: &defaults
headline_font_family: 'DejaVuSansCondensed, Arial, Helvetica, sans-serif'
headline_font_size: '36px'
headline_font_variant: 'condensed_book'
+ hyper_conform: false
insert_background_color: '#ffff45'
invalid_background_color: 'ff0'
line_height: 30
diff --git a/public/javascripts/gmaps4rails/gmaps4rails.base.js b/public/javascripts/gmaps4rails/gmaps4rails.base.js
new file mode 100644
index 00000000..a1e17a4b
--- /dev/null
+++ b/public/javascripts/gmaps4rails/gmaps4rails.base.js
@@ -0,0 +1,464 @@
+(function() {
+ var Gmaps;
+
+ Gmaps = {};
+
+ Gmaps.triggerOldOnload = function() {
+ if (typeof Gmaps.oldOnload === 'function') return Gmaps.oldOnload();
+ };
+
+ Gmaps.loadMaps = function() {
+ var key, load_function_name, searchLoadIncluded, value, _results;
+ _results = [];
+ for (key in Gmaps) {
+ value = Gmaps[key];
+ searchLoadIncluded = key.search(/load/);
+ if (searchLoadIncluded === -1) {
+ load_function_name = "load_" + key;
+ _results.push(Gmaps[load_function_name]());
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ window.Gmaps = Gmaps;
+
+ this.Gmaps4Rails = (function() {
+
+ function Gmaps4Rails() {
+ this.map = null;
+ this.serviceObject = null;
+ this.visibleInfoWindow = null;
+ this.userLocation = null;
+ this.geolocationFailure = function() {
+ return false;
+ };
+ this.callback = function() {
+ return false;
+ };
+ this.customClusterer = function() {
+ return false;
+ };
+ this.infobox = function() {
+ return false;
+ };
+ this.jsTemplate = false;
+ this.default_map_options = {
+ id: 'map',
+ draggable: true,
+ detect_location: false,
+ center_on_user: false,
+ center_latitude: 0,
+ center_longitude: 0,
+ zoom: 7,
+ maxZoom: null,
+ minZoom: null,
+ auto_adjust: true,
+ auto_zoom: true,
+ bounds: [],
+ raw: {}
+ };
+ this.default_markers_conf = {
+ title: "",
+ picture: "",
+ width: 22,
+ length: 32,
+ draggable: false,
+ do_clustering: false,
+ randomize: false,
+ max_random_distance: 100,
+ list_container: null,
+ offset: 0,
+ raw: {}
+ };
+ this.markers = [];
+ this.boundsObject = null;
+ this.polygons = [];
+ this.polylines = [];
+ this.circles = [];
+ this.markerClusterer = null;
+ this.markerImages = [];
+ this.polylines_conf = {
+ strokeColor: "#FF0000",
+ strokeOpacity: 1,
+ strokeWeight: 2,
+ clickable: false,
+ zIndex: null
+ };
+ }
+
+ Gmaps4Rails.prototype.initialize = function() {
+ this.serviceObject = this.createMap();
+ this.map = this.serviceObject;
+ if (this.map_options.detect_location === true || this.map_options.center_on_user === true) {
+ this.findUserLocation(this);
+ }
+ return this.resetSidebarContent();
+ };
+
+ Gmaps4Rails.prototype.findUserLocation = function(map_object) {
+ var positionFailure, positionSuccessful;
+ if (navigator.geolocation) {
+ positionSuccessful = function(position) {
+ map_object.userLocation = map_object.createLatLng(position.coords.latitude, position.coords.longitude);
+ if (map_object.map_options.center_on_user === true) {
+ return map_object.centerMapOnUser();
+ }
+ };
+ positionFailure = function() {
+ return map_object.geolocationFailure(true);
+ };
+ return navigator.geolocation.getCurrentPosition(positionSuccessful, positionFailure);
+ } else {
+ return map_object.geolocationFailure(false);
+ }
+ };
+
+ Gmaps4Rails.prototype.create_direction = function() {
+ var directionsDisplay, directionsService, request;
+ directionsDisplay = new google.maps.DirectionsRenderer();
+ directionsService = new google.maps.DirectionsService();
+ directionsDisplay.setMap(this.serviceObject);
+ if (this.direction_conf.display_panel) {
+ directionsDisplay.setPanel(document.getElementById(this.direction_conf.panel_id));
+ }
+ directionsDisplay.setOptions({
+ suppressMarkers: false,
+ suppressInfoWindows: false,
+ suppressPolylines: false
+ });
+ request = {
+ origin: this.direction_conf.origin,
+ destination: this.direction_conf.destination,
+ waypoints: this.direction_conf.waypoints,
+ optimizeWaypoints: this.direction_conf.optimizeWaypoints,
+ unitSystem: google.maps.DirectionsUnitSystem[this.direction_conf.unitSystem],
+ avoidHighways: this.direction_conf.avoidHighways,
+ avoidTolls: this.direction_conf.avoidTolls,
+ region: this.direction_conf.region,
+ travelMode: google.maps.DirectionsTravelMode[this.direction_conf.travelMode],
+ language: "en"
+ };
+ return directionsService.route(request, function(response, status) {
+ if (status === google.maps.DirectionsStatus.OK) {
+ return directionsDisplay.setDirections(response);
+ }
+ });
+ };
+
+ Gmaps4Rails.prototype.create_circles = function() {
+ var circle, _i, _len, _ref, _results;
+ _ref = this.circles;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ circle = _ref[_i];
+ _results.push(this.create_circle(circle));
+ }
+ return _results;
+ };
+
+ Gmaps4Rails.prototype.create_circle = function(circle) {
+ var newCircle;
+ if (circle === this.circles[0]) {
+ if (circle.strokeColor != null) {
+ this.circles_conf.strokeColor = circle.strokeColor;
+ }
+ if (circle.strokeOpacity != null) {
+ this.circles_conf.strokeOpacity = circle.strokeOpacity;
+ }
+ if (circle.strokeWeight != null) {
+ this.circles_conf.strokeWeight = circle.strokeWeight;
+ }
+ if (circle.fillColor != null) {
+ this.circles_conf.fillColor = circle.fillColor;
+ }
+ if (circle.fillOpacity != null) {
+ this.circles_conf.fillOpacity = circle.fillOpacity;
+ }
+ }
+ if ((circle.lat != null) && (circle.lng != null)) {
+ newCircle = new google.maps.Circle({
+ center: this.createLatLng(circle.lat, circle.lng),
+ strokeColor: circle.strokeColor || this.circles_conf.strokeColor,
+ strokeOpacity: circle.strokeOpacity || this.circles_conf.strokeOpacity,
+ strokeWeight: circle.strokeWeight || this.circles_conf.strokeWeight,
+ fillOpacity: circle.fillOpacity || this.circles_conf.fillOpacity,
+ fillColor: circle.fillColor || this.circles_conf.fillColor,
+ clickable: circle.clickable || this.circles_conf.clickable,
+ zIndex: circle.zIndex || this.circles_conf.zIndex,
+ radius: circle.radius
+ });
+ circle.serviceObject = newCircle;
+ return newCircle.setMap(this.serviceObject);
+ }
+ };
+
+ Gmaps4Rails.prototype.clear_circles = function() {
+ var circle, _i, _len, _ref, _results;
+ _ref = this.circles;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ circle = _ref[_i];
+ _results.push(this.clear_circle(circle));
+ }
+ return _results;
+ };
+
+ Gmaps4Rails.prototype.clear_circle = function(circle) {
+ return circle.serviceObject.setMap(null);
+ };
+
+ Gmaps4Rails.prototype.hide_circles = function() {
+ var circle, _i, _len, _ref, _results;
+ _ref = this.circles;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ circle = _ref[_i];
+ _results.push(this.hide_circle(circle));
+ }
+ return _results;
+ };
+
+ Gmaps4Rails.prototype.hide_circle = function(circle) {
+ return circle.serviceObject.setMap(null);
+ };
+
+ Gmaps4Rails.prototype.show_circles = function() {
+ var circle, _i, _len, _ref, _results;
+ _ref = this.circles;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ circle = _ref[_i];
+ _results.push(this.show_circle(this.circle));
+ }
+ return _results;
+ };
+
+ Gmaps4Rails.prototype.show_circle = function(circle) {
+ return circle.serviceObject.setMap(this.serviceObject);
+ };
+
+ Gmaps4Rails.prototype.create_polygons = function() {
+ var polygon, _i, _len, _ref, _results;
+ _ref = this.polygons;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ polygon = _ref[_i];
+ _results.push(this.create_polygon(polygon));
+ }
+ return _results;
+ };
+
+ Gmaps4Rails.prototype.create_polygon = function(polygon) {
+ var clickable, fillColor, fillOpacity, latlng, new_poly, point, polygon_coordinates, strokeColor, strokeOpacity, strokeWeight, _i, _len;
+ polygon_coordinates = [];
+ for (_i = 0, _len = polygon.length; _i < _len; _i++) {
+ point = polygon[_i];
+ latlng = this.createLatLng(point.lat, point.lng);
+ polygon_coordinates.push(latlng);
+ if (point === polygon[0]) {
+ strokeColor = point.strokeColor || this.polygons_conf.strokeColor;
+ strokeOpacity = point.strokeOpacity || this.polygons_conf.strokeOpacity;
+ strokeWeight = point.strokeWeight || this.polygons_conf.strokeWeight;
+ fillColor = point.fillColor || this.polygons_conf.fillColor;
+ fillOpacity = point.fillOpacity || this.polygons_conf.fillOpacity;
+ clickable = point.clickable || this.polygons_conf.clickable;
+ }
+ }
+ new_poly = new google.maps.Polygon({
+ paths: polygon_coordinates,
+ strokeColor: strokeColor,
+ strokeOpacity: strokeOpacity,
+ strokeWeight: strokeWeight,
+ fillColor: fillColor,
+ fillOpacity: fillOpacity,
+ clickable: clickable,
+ map: this.serviceObject
+ });
+ return polygon.serviceObject = new_poly;
+ };
+
+ Gmaps4Rails.prototype.create_markers = function() {
+ this.createServiceMarkersFromMarkers();
+ return this.clusterize();
+ };
+
+ Gmaps4Rails.prototype.createServiceMarkersFromMarkers = function() {
+ var Lat, LatLng, Lng, index, marker, _len, _ref;
+ _ref = this.markers;
+ for (index = 0, _len = _ref.length; index < _len; index++) {
+ marker = _ref[index];
+ if (!(this.markers[index].serviceObject != null)) {
+ Lat = this.markers[index].lat;
+ Lng = this.markers[index].lng;
+ if (this.markers_conf.randomize) {
+ LatLng = this.randomize(Lat, Lng);
+ Lat = LatLng[0];
+ Lng = LatLng[1];
+ }
+ this.markers[index].serviceObject = this.createMarker({
+ "marker_picture": this.markers[index].picture ? this.markers[index].picture : this.markers_conf.picture,
+ "marker_width": this.markers[index].width ? this.markers[index].width : this.markers_conf.width,
+ "marker_height": this.markers[index].height ? this.markers[index].height : this.markers_conf.length,
+ "marker_title": this.markers[index].title ? this.markers[index].title : null,
+ "marker_anchor": this.markers[index].marker_anchor ? this.markers[index].marker_anchor : null,
+ "shadow_anchor": this.markers[index].shadow_anchor ? this.markers[index].shadow_anchor : null,
+ "shadow_picture": this.markers[index].shadow_picture ? this.markers[index].shadow_picture : null,
+ "shadow_width": this.markers[index].shadow_width ? this.markers[index].shadow_width : null,
+ "shadow_height": this.markers[index].shadow_height ? this.markers[index].shadow_height : null,
+ "marker_draggable": this.markers[index].draggable ? this.markers[index].draggable : this.markers_conf.draggable,
+ "rich_marker": this.markers[index].rich_marker ? this.markers[index].rich_marker : null,
+ "zindex": this.markers[index].zindex ? this.markers[index].zindex : null,
+ "Lat": Lat,
+ "Lng": Lng,
+ "index": index
+ });
+ this.createInfoWindow(this.markers[index]);
+ this.createSidebar(this.markers[index]);
+ }
+ }
+ return this.markers_conf.offset = this.markers.length;
+ };
+
+ Gmaps4Rails.prototype.createImageAnchorPosition = function(anchorLocation) {
+ if (anchorLocation === null) {
+ return null;
+ } else {
+ return this.createPoint(anchorLocation[0], anchorLocation[1]);
+ }
+ };
+
+ Gmaps4Rails.prototype.replaceMarkers = function(new_markers) {
+ this.clearMarkers();
+ this.markers = new Array;
+ this.boundsObject = this.createLatLngBounds();
+ this.resetSidebarContent();
+ this.markers_conf.offset = 0;
+ return this.addMarkers(new_markers);
+ };
+
+ Gmaps4Rails.prototype.addMarkers = function(new_markers) {
+ this.markers = this.markers.concat(new_markers);
+ this.create_markers();
+ return this.adjustMapToBounds();
+ };
+
+ Gmaps4Rails.prototype.createSidebar = function(marker_container) {
+ var aSel, currentMap, html, li, ul;
+ if (this.markers_conf.list_container) {
+ ul = document.getElementById(this.markers_conf.list_container);
+ li = document.createElement('li');
+ aSel = document.createElement('a');
+ aSel.href = 'javascript:void(0);';
+ html = marker_container.sidebar != null ? marker_container.sidebar : "Marker";
+ aSel.innerHTML = html;
+ currentMap = this;
+ aSel.onclick = this.sidebar_element_handler(currentMap, marker_container.serviceObject, 'click');
+ li.appendChild(aSel);
+ return ul.appendChild(li);
+ }
+ };
+
+ Gmaps4Rails.prototype.sidebar_element_handler = function(currentMap, marker, eventType) {
+ return function() {
+ currentMap.map.panTo(marker.position);
+ return google.maps.event.trigger(marker, eventType);
+ };
+ };
+
+ Gmaps4Rails.prototype.resetSidebarContent = function() {
+ var ul;
+ if (this.markers_conf.list_container !== null) {
+ ul = document.getElementById(this.markers_conf.list_container);
+ return ul.innerHTML = "";
+ }
+ };
+
+ Gmaps4Rails.prototype.adjustMapToBounds = function() {
+ if (this.map_options.auto_adjust || this.map_options.bounds !== null) {
+ this.boundsObject = this.createLatLngBounds();
+ if (this.map_options.auto_adjust) {
+ this.extendBoundsWithMarkers();
+ this.updateBoundsWithPolylines();
+ this.updateBoundsWithPolygons();
+ this.updateBoundsWithCircles();
+ }
+ this.extendMapBounds();
+ return this.adaptMapToBounds();
+ }
+ };
+
+ Gmaps4Rails.prototype.replacePolylines = function(new_polylines) {
+ this.destroy_polylines();
+ this.polylines = new_polylines;
+ this.create_polylines();
+ return this.adjustMapToBounds();
+ };
+
+ Gmaps4Rails.prototype.destroy_polylines = function() {
+ var polyline, _i, _len, _ref;
+ _ref = this.polylines;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ polyline = _ref[_i];
+ polyline.serviceObject.setMap(null);
+ }
+ return this.polylines = [];
+ };
+
+ Gmaps4Rails.prototype.create_polylines = function() {
+ var polyline, _i, _len, _ref, _results;
+ _ref = this.polylines;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ polyline = _ref[_i];
+ _results.push(this.create_polyline(polyline));
+ }
+ return _results;
+ };
+
+ Gmaps4Rails.prototype.exists = function(var_name) {
+ return var_name !== "" && typeof var_name !== "undefined";
+ };
+
+ Gmaps4Rails.prototype.randomize = function(Lat0, Lng0) {
+ var Lat, Lng, dx, dy;
+ dx = this.markers_conf.max_random_distance * this.random();
+ dy = this.markers_conf.max_random_distance * this.random();
+ Lat = parseFloat(Lat0) + (180 / Math.PI) * (dy / 6378137);
+ Lng = parseFloat(Lng0) + (90 / Math.PI) * (dx / 6378137) / Math.cos(Lat0);
+ return [Lat, Lng];
+ };
+
+ Gmaps4Rails.prototype.mergeObjectWithDefault = function(object1, object2) {
+ var copy_object1, key, value;
+ copy_object1 = {};
+ for (key in object1) {
+ value = object1[key];
+ copy_object1[key] = value;
+ }
+ for (key in object2) {
+ value = object2[key];
+ if (copy_object1[key] == null) copy_object1[key] = value;
+ }
+ return copy_object1;
+ };
+
+ Gmaps4Rails.prototype.mergeWithDefault = function(objectName) {
+ var default_object, object;
+ default_object = this["default_" + objectName];
+ object = this[objectName];
+ this[objectName] = this.mergeObjectWithDefault(object, default_object);
+ return true;
+ };
+
+ Gmaps4Rails.prototype.random = function() {
+ return Math.random() * 2 - 1;
+ };
+
+ return Gmaps4Rails;
+
+ })();
+
+}).call(this);
diff --git a/public/javascripts/gmaps4rails/gmaps4rails.bing.js b/public/javascripts/gmaps4rails/gmaps4rails.bing.js
new file mode 100644
index 00000000..10df8a9d
--- /dev/null
+++ b/public/javascripts/gmaps4rails/gmaps4rails.bing.js
@@ -0,0 +1,226 @@
+(function() {
+ var __hasProp = Object.prototype.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+
+ this.Gmaps4RailsBing = (function(_super) {
+
+ __extends(Gmaps4RailsBing, _super);
+
+ function Gmaps4RailsBing() {
+ Gmaps4RailsBing.__super__.constructor.apply(this, arguments);
+ this.map_options = {
+ type: "road"
+ };
+ this.markers_conf = {
+ infobox: "description"
+ };
+ this.mergeWithDefault("map_options");
+ this.mergeWithDefault("markers_conf");
+ }
+
+ Gmaps4RailsBing.prototype.getMapType = function() {
+ switch (this.map_options.type) {
+ case "road":
+ return Microsoft.Maps.MapTypeId.road;
+ case "aerial":
+ return Microsoft.Maps.MapTypeId.aerial;
+ case "auto":
+ return Microsoft.Maps.MapTypeId.auto;
+ case "birdseye":
+ return Microsoft.Maps.MapTypeId.birdseye;
+ case "collinsBart":
+ return Microsoft.Maps.MapTypeId.collinsBart;
+ case "mercator":
+ return Microsoft.Maps.MapTypeId.mercator;
+ case "ordnanceSurvey":
+ return Microsoft.Maps.MapTypeId.ordnanceSurvey;
+ default:
+ return Microsoft.Maps.MapTypeId.auto;
+ }
+ };
+
+ Gmaps4RailsBing.prototype.createPoint = function(lat, lng) {
+ return new Microsoft.Maps.Point(lat, lng);
+ };
+
+ Gmaps4RailsBing.prototype.createLatLng = function(lat, lng) {
+ return new Microsoft.Maps.Location(lat, lng);
+ };
+
+ Gmaps4RailsBing.prototype.createLatLngBounds = function() {};
+
+ Gmaps4RailsBing.prototype.createMap = function() {
+ return new Microsoft.Maps.Map(document.getElementById(this.map_options.id), {
+ credentials: this.map_options.provider_key,
+ mapTypeId: this.getMapType(),
+ center: this.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude),
+ zoom: this.map_options.zoom
+ });
+ };
+
+ Gmaps4RailsBing.prototype.createSize = function(width, height) {
+ return new google.maps.Size(width, height);
+ };
+
+ Gmaps4RailsBing.prototype.createMarker = function(args) {
+ var marker, markerLatLng;
+ markerLatLng = this.createLatLng(args.Lat, args.Lng);
+ marker;
+ if (args.marker_picture === "") {
+ marker = new Microsoft.Maps.Pushpin(this.createLatLng(args.Lat, args.Lng), {
+ draggable: args.marker_draggable,
+ anchor: this.createImageAnchorPosition(args.Lat, args.Lng),
+ text: args.marker_title
+ });
+ } else {
+ marker = new Microsoft.Maps.Pushpin(this.createLatLng(args.Lat, args.Lng), {
+ draggable: args.marker_draggable,
+ anchor: this.createImageAnchorPosition(args.Lat, args.Lng),
+ icon: args.marker_picture,
+ height: args.marker_height,
+ text: args.marker_title,
+ width: args.marker_width
+ });
+ }
+ this.addToMap(marker);
+ return marker;
+ };
+
+ Gmaps4RailsBing.prototype.clearMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.clearMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsBing.prototype.clearMarker = function(marker) {
+ return this.removeFromMap(marker.serviceObject);
+ };
+
+ Gmaps4RailsBing.prototype.showMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.showMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsBing.prototype.showMarker = function(marker) {
+ return marker.serviceObject.setOptions({
+ visible: true
+ });
+ };
+
+ Gmaps4RailsBing.prototype.hideMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.hideMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsBing.prototype.hideMarker = function(marker) {
+ return marker.serviceObject.setOptions({
+ visible: false
+ });
+ };
+
+ Gmaps4RailsBing.prototype.extendBoundsWithMarkers = function() {
+ var locationsArray, marker, _i, _len, _ref;
+ locationsArray = [];
+ _ref = this.markers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ locationsArray.push(marker.serviceObject.getLocation());
+ }
+ return this.boundsObject = Microsoft.Maps.LocationRect.fromLocations(locationsArray);
+ };
+
+ Gmaps4RailsBing.prototype.createClusterer = function(markers_array) {};
+
+ Gmaps4RailsBing.prototype.clearClusterer = function() {};
+
+ Gmaps4RailsBing.prototype.clusterize = function() {};
+
+ Gmaps4RailsBing.prototype.createInfoWindow = function(marker_container) {
+ var currentMap;
+ if (marker_container.description != null) {
+ if (this.markers_conf.infobox === "description") {
+ marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), {
+ description: marker_container.description,
+ visible: false,
+ showCloseButton: true
+ });
+ } else {
+ marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), {
+ htmlContent: marker_container.description,
+ visible: false
+ });
+ }
+ currentMap = this;
+ Microsoft.Maps.Events.addHandler(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.info_window));
+ return this.addToMap(marker_container.info_window);
+ }
+ };
+
+ Gmaps4RailsBing.prototype.openInfoWindow = function(currentMap, infoWindow) {
+ return function() {
+ if (currentMap.visibleInfoWindow) {
+ currentMap.visibleInfoWindow.setOptions({
+ visible: false
+ });
+ }
+ infoWindow.setOptions({
+ visible: true
+ });
+ return currentMap.visibleInfoWindow = infoWindow;
+ };
+ };
+
+ Gmaps4RailsBing.prototype.fitBounds = function() {
+ return this.serviceObject.setView({
+ bounds: this.boundsObject
+ });
+ };
+
+ Gmaps4RailsBing.prototype.addToMap = function(object) {
+ return this.serviceObject.entities.push(object);
+ };
+
+ Gmaps4RailsBing.prototype.removeFromMap = function(object) {
+ return this.serviceObject.entities.remove(object);
+ };
+
+ Gmaps4RailsBing.prototype.centerMapOnUser = function() {
+ return this.serviceObject.setView({
+ center: this.userLocation
+ });
+ };
+
+ Gmaps4RailsBing.prototype.updateBoundsWithPolylines = function() {};
+
+ Gmaps4RailsBing.prototype.updateBoundsWithPolygons = function() {};
+
+ Gmaps4RailsBing.prototype.updateBoundsWithCircles = function() {};
+
+ Gmaps4RailsBing.prototype.extendMapBounds = function() {};
+
+ Gmaps4RailsBing.prototype.adaptMapToBounds = function() {
+ return this.fitBounds();
+ };
+
+ return Gmaps4RailsBing;
+
+ })(Gmaps4Rails);
+
+}).call(this);
diff --git a/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js b/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js
new file mode 100644
index 00000000..a7d848a8
--- /dev/null
+++ b/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js
@@ -0,0 +1,430 @@
+(function() {
+ var __hasProp = Object.prototype.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+
+ this.Gmaps4RailsGoogle = (function(_super) {
+
+ __extends(Gmaps4RailsGoogle, _super);
+
+ function Gmaps4RailsGoogle() {
+ Gmaps4RailsGoogle.__super__.constructor.apply(this, arguments);
+ this.map_options = {
+ disableDefaultUI: false,
+ disableDoubleClickZoom: false,
+ type: "ROADMAP"
+ };
+ this.markers_conf = {
+ clusterer_gridSize: 50,
+ clusterer_maxZoom: 5,
+ custom_cluster_pictures: null,
+ custom_infowindow_class: null
+ };
+ this.mergeWithDefault("map_options");
+ this.mergeWithDefault("markers_conf");
+ this.kml_options = {
+ clickable: true,
+ preserveViewport: false,
+ suppressInfoWindows: false
+ };
+ this.polygons_conf = {
+ strokeColor: "#FFAA00",
+ strokeOpacity: 0.8,
+ strokeWeight: 2,
+ fillColor: "#000000",
+ fillOpacity: 0.35,
+ clickable: false
+ };
+ this.circles_conf = {
+ fillColor: "#00AAFF",
+ fillOpacity: 0.35,
+ strokeColor: "#FFAA00",
+ strokeOpacity: 0.8,
+ strokeWeight: 2,
+ clickable: false,
+ zIndex: null
+ };
+ this.direction_conf = {
+ panel_id: null,
+ display_panel: false,
+ origin: null,
+ destination: null,
+ waypoints: [],
+ optimizeWaypoints: false,
+ unitSystem: "METRIC",
+ avoidHighways: false,
+ avoidTolls: false,
+ region: null,
+ travelMode: "DRIVING"
+ };
+ }
+
+ Gmaps4RailsGoogle.prototype.createPoint = function(lat, lng) {
+ return new google.maps.Point(lat, lng);
+ };
+
+ Gmaps4RailsGoogle.prototype.createLatLng = function(lat, lng) {
+ return new google.maps.LatLng(lat, lng);
+ };
+
+ Gmaps4RailsGoogle.prototype.createLatLngBounds = function() {
+ return new google.maps.LatLngBounds();
+ };
+
+ Gmaps4RailsGoogle.prototype.createMap = function() {
+ var defaultOptions, mergedOptions;
+ defaultOptions = {
+ maxZoom: this.map_options.maxZoom,
+ minZoom: this.map_options.minZoom,
+ zoom: this.map_options.zoom,
+ center: this.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude),
+ mapTypeId: google.maps.MapTypeId[this.map_options.type],
+ mapTypeControl: this.map_options.mapTypeControl,
+ disableDefaultUI: this.map_options.disableDefaultUI,
+ disableDoubleClickZoom: this.map_options.disableDoubleClickZoom,
+ draggable: this.map_options.draggable
+ };
+ mergedOptions = this.mergeObjectWithDefault(this.map_options.raw, defaultOptions);
+ return new google.maps.Map(document.getElementById(this.map_options.id), mergedOptions);
+ };
+
+ Gmaps4RailsGoogle.prototype.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
+ return new google.maps.MarkerImage(markerPicture, markerSize, origin, anchor, scaledSize);
+ };
+
+ Gmaps4RailsGoogle.prototype.createSize = function(width, height) {
+ return new google.maps.Size(width, height);
+ };
+
+ Gmaps4RailsGoogle.prototype.createMarker = function(args) {
+ var defaultOptions, imageAnchorPosition, markerImage, markerLatLng, mergedOptions, shadowAnchorPosition, shadowImage;
+ markerLatLng = this.createLatLng(args.Lat, args.Lng);
+ if (args.marker_picture === "" && args.rich_marker === null) {
+ defaultOptions = {
+ position: markerLatLng,
+ map: this.serviceObject,
+ title: args.marker_title,
+ draggable: args.marker_draggable,
+ zIndex: args.zindex
+ };
+ mergedOptions = this.mergeObjectWithDefault(this.markers_conf.raw, defaultOptions);
+ return new google.maps.Marker(mergedOptions);
+ }
+ if (args.rich_marker !== null) {
+ return new RichMarker({
+ position: markerLatLng,
+ map: this.serviceObject,
+ draggable: args.marker_draggable,
+ content: args.rich_marker,
+ flat: args.marker_anchor === null ? false : args.marker_anchor[1],
+ anchor: args.marker_anchor === null ? 0 : args.marker_anchor[0],
+ zIndex: args.zindex
+ });
+ }
+ imageAnchorPosition = this.createImageAnchorPosition(args.marker_anchor);
+ shadowAnchorPosition = this.createImageAnchorPosition(args.shadow_anchor);
+ markerImage = this.createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition);
+ shadowImage = this.createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition);
+ defaultOptions = {
+ position: markerLatLng,
+ map: this.serviceObject,
+ icon: markerImage,
+ title: args.marker_title,
+ draggable: args.marker_draggable,
+ shadow: shadowImage,
+ zIndex: args.zindex
+ };
+ mergedOptions = this.mergeObjectWithDefault(this.markers_conf.raw, defaultOptions);
+ return new google.maps.Marker(mergedOptions);
+ };
+
+ Gmaps4RailsGoogle.prototype.includeMarkerImage = function(arr, obj) {
+ var index, object, _len;
+ for (index = 0, _len = arr.length; index < _len; index++) {
+ object = arr[index];
+ if (object.url === obj) return index;
+ }
+ return false;
+ };
+
+ Gmaps4RailsGoogle.prototype.createOrRetrieveImage = function(currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition) {
+ var markerImage, test_image_index;
+ if (currentMarkerPicture === "" || currentMarkerPicture === null) {
+ return null;
+ }
+ test_image_index = this.includeMarkerImage(this.markerImages, currentMarkerPicture);
+ switch (test_image_index) {
+ case false:
+ markerImage = this.createMarkerImage(currentMarkerPicture, this.createSize(markerWidth, markerHeight), null, imageAnchorPosition, null);
+ this.markerImages.push(markerImage);
+ return markerImage;
+ break;
+ default:
+ if (typeof test_image_index === 'number') {
+ return this.markerImages[test_image_index];
+ }
+ return false;
+ }
+ };
+
+ Gmaps4RailsGoogle.prototype.clearMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.clearMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.showMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.showMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.hideMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.hideMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.clearMarker = function(marker) {
+ return marker.serviceObject.setMap(null);
+ };
+
+ Gmaps4RailsGoogle.prototype.showMarker = function(marker) {
+ return marker.serviceObject.setVisible(true);
+ };
+
+ Gmaps4RailsGoogle.prototype.hideMarker = function(marker) {
+ return marker.serviceObject.setVisible(false);
+ };
+
+ Gmaps4RailsGoogle.prototype.extendBoundsWithMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.boundsObject.extend(marker.serviceObject.position));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.createClusterer = function(markers_array) {
+ return new MarkerClusterer(this.serviceObject, markers_array, {
+ maxZoom: this.markers_conf.clusterer_maxZoom,
+ gridSize: this.markers_conf.clusterer_gridSize,
+ styles: this.customClusterer()
+ });
+ };
+
+ Gmaps4RailsGoogle.prototype.clearClusterer = function() {
+ return this.markerClusterer.clearMarkers();
+ };
+
+ Gmaps4RailsGoogle.prototype.clusterize = function() {
+ var marker, markers_array, _i, _len, _ref;
+ if (this.markers_conf.do_clustering === true) {
+ if (this.markerClusterer !== null) this.clearClusterer();
+ markers_array = new Array;
+ _ref = this.markers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ markers_array.push(marker.serviceObject);
+ }
+ return this.markerClusterer = this.createClusterer(markers_array);
+ }
+ };
+
+ Gmaps4RailsGoogle.prototype.createInfoWindow = function(marker_container) {
+ var boxText, currentMap;
+ if (typeof this.jsTemplate === "function" || (marker_container.description != null)) {
+ if (typeof this.jsTemplate === "function") {
+ marker_container.description = this.jsTemplate(marker_container);
+ }
+ if (this.markers_conf.custom_infowindow_class !== null) {
+ boxText = document.createElement("div");
+ boxText.setAttribute("class", this.markers_conf.custom_infowindow_class);
+ boxText.innerHTML = marker_container.description;
+ marker_container.infowindow = new InfoBox(this.infobox(boxText));
+ currentMap = this;
+ return google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject));
+ } else {
+ marker_container.infowindow = new google.maps.InfoWindow({
+ content: marker_container.description
+ });
+ currentMap = this;
+ return google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject));
+ }
+ }
+ };
+
+ Gmaps4RailsGoogle.prototype.openInfoWindow = function(currentMap, infoWindow, marker) {
+ return function() {
+ if (currentMap.visibleInfoWindow !== null) {
+ currentMap.visibleInfoWindow.close();
+ }
+ infoWindow.open(currentMap.serviceObject, marker);
+ return currentMap.visibleInfoWindow = infoWindow;
+ };
+ };
+
+ Gmaps4RailsGoogle.prototype.createKmlLayer = function(kml) {
+ var kml_options;
+ kml_options = kml.options || {};
+ kml_options = this.mergeObjectWithDefault(kml_options, this.kml_options);
+ kml = new google.maps.KmlLayer(kml.url, kml_options);
+ kml.setMap(this.serviceObject);
+ return kml;
+ };
+
+ Gmaps4RailsGoogle.prototype.create_polyline = function(polyline) {
+ var clickable, decoded_array, element, latlng, new_poly, point, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
+ polyline_coordinates = [];
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
+ element = polyline[_i];
+ if (element.coded_array != null) {
+ decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array);
+ for (_j = 0, _len2 = decoded_array.length; _j < _len2; _j++) {
+ point = decoded_array[_j];
+ polyline_coordinates.push(point);
+ }
+ } else {
+ if (element === polyline[0]) {
+ strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
+ strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
+ strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
+ clickable = element.clickable || this.polylines_conf.clickable;
+ zIndex = element.zIndex || this.polylines_conf.zIndex;
+ }
+ if ((element.lat != null) && (element.lng != null)) {
+ latlng = this.createLatLng(element.lat, element.lng);
+ polyline_coordinates.push(latlng);
+ }
+ }
+ }
+ new_poly = new google.maps.Polyline({
+ path: polyline_coordinates,
+ strokeColor: strokeColor,
+ strokeOpacity: strokeOpacity,
+ strokeWeight: strokeWeight,
+ clickable: clickable,
+ zIndex: zIndex
+ });
+ polyline.serviceObject = new_poly;
+ return new_poly.setMap(this.serviceObject);
+ };
+
+ Gmaps4RailsGoogle.prototype.updateBoundsWithPolylines = function() {
+ var point, polyline, polyline_points, _i, _len, _ref, _results;
+ _ref = this.polylines;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ polyline = _ref[_i];
+ polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray();
+ _results.push((function() {
+ var _j, _len2, _results2;
+ _results2 = [];
+ for (_j = 0, _len2 = polyline_points.length; _j < _len2; _j++) {
+ point = polyline_points[_j];
+ _results2.push(this.boundsObject.extend(point));
+ }
+ return _results2;
+ }).call(this));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.create_kml = function() {
+ var kml, _i, _len, _ref, _results;
+ _ref = this.kml;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ kml = _ref[_i];
+ _results.push(kml.serviceObject = this.createKmlLayer(kml));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.fitBounds = function() {
+ if (!this.boundsObject.isEmpty()) {
+ return this.serviceObject.fitBounds(this.boundsObject);
+ }
+ };
+
+ Gmaps4RailsGoogle.prototype.centerMapOnUser = function() {
+ return this.serviceObject.setCenter(this.userLocation);
+ };
+
+ Gmaps4RailsGoogle.prototype.updateBoundsWithPolygons = function() {
+ var point, polygon, polygon_points, _i, _len, _ref, _results;
+ _ref = this.polygons;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ polygon = _ref[_i];
+ polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray();
+ _results.push((function() {
+ var _j, _len2, _results2;
+ _results2 = [];
+ for (_j = 0, _len2 = polygon_points.length; _j < _len2; _j++) {
+ point = polygon_points[_j];
+ _results2.push(this.boundsObject.extend(point));
+ }
+ return _results2;
+ }).call(this));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.updateBoundsWithCircles = function() {
+ var circle, _i, _len, _ref, _results;
+ _ref = this.circles;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ circle = _ref[_i];
+ this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
+ _results.push(this.boundsObject.extend(circle.serviceObject.getBounds().getSouthWest()));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.extendMapBounds = function() {
+ var bound, _i, _len, _ref, _results;
+ _ref = this.map_options.bounds;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ bound = _ref[_i];
+ _results.push(this.boundsObject.extend(this.createLatLng(bound.lat, bound.lng)));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsGoogle.prototype.adaptMapToBounds = function() {
+ var map_center;
+ if (!this.map_options.auto_zoom) {
+ map_center = this.boundsObject.getCenter();
+ this.map_options.center_latitude = map_center.lat();
+ this.map_options.center_longitude = map_center.lng();
+ return this.serviceObject.setCenter(map_center);
+ } else {
+ return this.fitBounds();
+ }
+ };
+
+ return Gmaps4RailsGoogle;
+
+ })(Gmaps4Rails);
+
+}).call(this);
diff --git a/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js b/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js
new file mode 100644
index 00000000..a7d9d9c6
--- /dev/null
+++ b/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js
@@ -0,0 +1,178 @@
+(function() {
+ var __hasProp = Object.prototype.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+
+ this.Gmaps4RailsMapquest = (function(_super) {
+
+ __extends(Gmaps4RailsMapquest, _super);
+
+ function Gmaps4RailsMapquest() {
+ Gmaps4RailsMapquest.__super__.constructor.apply(this, arguments);
+ this.map_options = {
+ type: "map"
+ };
+ this.markers_conf = {};
+ this.mergeWithDefault("markers_conf");
+ this.mergeWithDefault("map_options");
+ }
+
+ Gmaps4RailsMapquest.prototype.createPoint = function(lat, lng) {
+ return new MQA.Poi({
+ lat: lat,
+ lng: lng
+ });
+ };
+
+ Gmaps4RailsMapquest.prototype.createLatLng = function(lat, lng) {
+ return {
+ lat: lat,
+ lng: lng
+ };
+ };
+
+ Gmaps4RailsMapquest.prototype.createLatLngBounds = function() {};
+
+ Gmaps4RailsMapquest.prototype.createMap = function() {
+ var map;
+ map = new MQA.TileMap(document.getElementById(this.map_options.id), this.map_options.zoom, {
+ lat: this.map_options.center_latitude,
+ lng: this.map_options.center_longitude
+ }, this.map_options.type);
+ MQA.withModule('zoomcontrol3', (function() {
+ return map.addControl(new MQA.LargeZoomControl3(), new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT));
+ }));
+ return map;
+ };
+
+ Gmaps4RailsMapquest.prototype.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {};
+
+ Gmaps4RailsMapquest.prototype.createMarker = function(args) {
+ var icon, marker;
+ marker = new MQA.Poi({
+ lat: args.Lat,
+ lng: args.Lng
+ });
+ if (args.marker_picture !== "") {
+ icon = new MQA.Icon(args.marker_picture, args.marker_height, args.marker_width);
+ marker.setIcon(icon);
+ if (args.marker_anchor !== null) {
+ marker.setBias({
+ x: args.marker_anchor[0],
+ y: args.marker_anchor[1]
+ });
+ }
+ }
+ if (args.shadow_picture !== "") {
+ icon = new MQA.Icon(args.shadow_picture, args.shadow_height, args.shadow_width);
+ marker.setShadow(icon);
+ if (args.shadow_anchor !== null) {
+ marker.setShadowOffset({
+ x: args.shadow_anchor[0],
+ y: args.shadow_anchor[1]
+ });
+ }
+ }
+ this.addToMap(marker);
+ return marker;
+ };
+
+ Gmaps4RailsMapquest.prototype.clearMarkers = function() {
+ var marker, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = markers.length; _i < _len; _i++) {
+ marker = markers[_i];
+ _results.push(this.clearMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsMapquest.prototype.showMarkers = function() {
+ var marker, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = markers.length; _i < _len; _i++) {
+ marker = markers[_i];
+ _results.push(this.showMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsMapquest.prototype.hideMarkers = function() {
+ var marker, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = markers.length; _i < _len; _i++) {
+ marker = markers[_i];
+ _results.push(this.hideMarker(marker));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsMapquest.prototype.clearMarker = function(marker) {
+ return this.removeFromMap(marker.serviceObject);
+ };
+
+ Gmaps4RailsMapquest.prototype.showMarker = function(marker) {};
+
+ Gmaps4RailsMapquest.prototype.hideMarker = function(marker) {};
+
+ Gmaps4RailsMapquest.prototype.extendBoundsWithMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ if (this.markers.length >= 2) {
+ this.boundsObject = new MQA.RectLL(this.markers[0].serviceObject.latLng, this.markers[1].serviceObject.latLng);
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.boundsObject.extend(marker.serviceObject.latLng));
+ }
+ return _results;
+ }
+ };
+
+ Gmaps4RailsMapquest.prototype.createClusterer = function(markers_array) {};
+
+ Gmaps4RailsMapquest.prototype.clearClusterer = function() {};
+
+ Gmaps4RailsMapquest.prototype.clusterize = function() {};
+
+ Gmaps4RailsMapquest.prototype.createInfoWindow = function(marker_container) {
+ return marker_container.serviceObject.setInfoTitleHTML(marker_container.description);
+ };
+
+ Gmaps4RailsMapquest.prototype.fitBounds = function() {
+ if (this.markers.length >= 2) {
+ this.serviceObject.zoomToRect(this.boundsObject);
+ }
+ if (this.markers.length === 1) {
+ return this.serviceObject.setCenter(this.markers[0].serviceObject.latLng);
+ }
+ };
+
+ Gmaps4RailsMapquest.prototype.centerMapOnUser = function() {
+ return this.serviceObject.setCenter(this.userLocation);
+ };
+
+ Gmaps4RailsMapquest.prototype.addToMap = function(object) {
+ return this.serviceObject.addShape(object);
+ };
+
+ Gmaps4RailsMapquest.prototype.removeFromMap = function(object) {
+ return this.serviceObject.removeShape(object);
+ };
+
+ Gmaps4RailsMapquest.prototype.updateBoundsWithPolylines = function() {};
+
+ Gmaps4RailsMapquest.prototype.updateBoundsWithPolygons = function() {};
+
+ Gmaps4RailsMapquest.prototype.updateBoundsWithCircles = function() {};
+
+ Gmaps4RailsMapquest.prototype.extendMapBounds = function() {};
+
+ Gmaps4RailsMapquest.prototype.adaptMapToBounds = function() {
+ return this.fitBounds();
+ };
+
+ return Gmaps4RailsMapquest;
+
+ })(Gmaps4Rails);
+
+}).call(this);
diff --git a/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js b/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js
new file mode 100644
index 00000000..06205363
--- /dev/null
+++ b/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js
@@ -0,0 +1,265 @@
+(function() {
+ var __hasProp = Object.prototype.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+
+ this.Gmaps4RailsOpenlayers = (function(_super) {
+
+ __extends(Gmaps4RailsOpenlayers, _super);
+
+ function Gmaps4RailsOpenlayers() {
+ Gmaps4RailsOpenlayers.__super__.constructor.apply(this, arguments);
+ this.map_options = {};
+ this.mergeWithDefault("map_options");
+ this.markers_conf = {};
+ this.mergeWithDefault("markers_conf");
+ this.openMarkers = null;
+ this.markersLayer = null;
+ this.markersControl = null;
+ this.polylinesLayer = null;
+ }
+
+ Gmaps4RailsOpenlayers.prototype.createPoint = function(lat, lng) {};
+
+ Gmaps4RailsOpenlayers.prototype.createLatLng = function(lat, lng) {
+ return new OpenLayers.LonLat(lng, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createAnchor = function(offset) {
+ if (offset === null) return null;
+ return new OpenLayers.Pixel(offset[0], offset[1]);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createSize = function(width, height) {
+ return new OpenLayers.Size(width, height);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createLatLngBounds = function() {
+ return new OpenLayers.Bounds();
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createMap = function() {
+ var map;
+ map = new OpenLayers.Map(this.map_options.id);
+ map.addLayer(new OpenLayers.Layer.OSM());
+ map.setCenter(this.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude), this.map_options.zoom);
+ return map;
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createMarker = function(args) {
+ var marker, style_mark;
+ style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
+ style_mark.fillOpacity = 1;
+ if (this.markersLayer === null) {
+ this.markersLayer = new OpenLayers.Layer.Vector("Markers", null);
+ this.serviceObject.addLayer(this.markersLayer);
+ this.markersLayer.events.register("featureselected", this.markersLayer, this.onFeatureSelect);
+ this.markersLayer.events.register("featureunselected", this.markersLayer, this.onFeatureUnselect);
+ this.markersControl = new OpenLayers.Control.SelectFeature(this.markersLayer);
+ this.serviceObject.addControl(this.markersControl);
+ this.markersControl.activate();
+ }
+ if (args.marker_picture === "") {
+ style_mark.graphicHeight = 30;
+ style_mark.externalGraphic = "http://openlayers.org/dev/img/marker-blue.png";
+ } else {
+ style_mark.graphicWidth = args.marker_width;
+ style_mark.graphicHeight = args.marker_height;
+ style_mark.externalGraphic = args.marker_picture;
+ if (args.marker_anchor !== null) {
+ style_mark.graphicXOffset = args.marker_anchor[0];
+ style_mark.graphicYOffset = args.marker_anchor[1];
+ }
+ if (args.shadow_picture !== "") {
+ style_mark.backgroundGraphic = args.shadow_picture;
+ style_mark.backgroundWidth = args.shadow_width;
+ style_mark.backgroundHeight = args.shadow_height;
+ if (args.shadow_anchor !== null) {
+ style_mark.backgroundXOffset = args.shadow_anchor[0];
+ style_mark.backgroundYOffset = args.shadow_anchor[1];
+ }
+ }
+ }
+ style_mark.graphicTitle = args.title;
+ marker = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(args.Lng, args.Lat), null, style_mark);
+ marker.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+ this.markersLayer.addFeatures([marker]);
+ return marker;
+ };
+
+ Gmaps4RailsOpenlayers.prototype.clearMarkers = function() {
+ this.clearMarkersLayerIfExists();
+ this.markersLayer = null;
+ return this.boundsObject = new OpenLayers.Bounds();
+ };
+
+ Gmaps4RailsOpenlayers.prototype.clearMarkersLayerIfExists = function() {
+ if (this.markersLayer !== null && this.serviceObject.getLayer(this.markersLayer.id) !== null) {
+ return this.serviceObject.removeLayer(this.markersLayer);
+ }
+ };
+
+ Gmaps4RailsOpenlayers.prototype.extendBoundsWithMarkers = function() {
+ var marker, _i, _len, _ref, _results;
+ console.log("here");
+ _ref = this.markers;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ _results.push(this.boundsObject.extend(this.createLatLng(marker.lat, marker.lng)));
+ }
+ return _results;
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createClusterer = function(markers_array) {
+ var clusters, funcs, options, strategy, style;
+ options = {
+ pointRadius: "${radius}",
+ fillColor: "#ffcc66",
+ fillOpacity: 0.8,
+ strokeColor: "#cc6633",
+ strokeWidth: "${width}",
+ strokeOpacity: 0.8
+ };
+ funcs = {
+ context: {
+ width: function(feature) {
+ var _ref;
+ return (_ref = feature.cluster) != null ? _ref : {
+ 2: 1
+ };
+ },
+ radius: function(feature) {
+ var pix;
+ pix = 2;
+ if (feature.cluster) pix = Math.min(feature.attributes.count, 7) + 2;
+ return pix;
+ }
+ }
+ };
+ style = new OpenLayers.Style(options, funcs);
+ strategy = new OpenLayers.Strategy.Cluster();
+ clusters = new OpenLayers.Layer.Vector("Clusters", {
+ strategies: [strategy],
+ styleMap: new OpenLayers.StyleMap({
+ "default": style,
+ "select": {
+ fillColor: "#8aeeef",
+ strokeColor: "#32a8a9"
+ }
+ })
+ });
+ this.clearMarkersLayerIfExists();
+ this.serviceObject.addLayer(clusters);
+ clusters.addFeatures(markers_array);
+ return clusters;
+ };
+
+ Gmaps4RailsOpenlayers.prototype.clusterize = function() {
+ var marker, markers_array, _i, _len, _ref;
+ if (this.markers_conf.do_clustering === true) {
+ if (this.markerClusterer !== null) this.clearClusterer();
+ markers_array = new Array;
+ _ref = this.markers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ marker = _ref[_i];
+ markers_array.push(marker.serviceObject);
+ }
+ return this.markerClusterer = this.createClusterer(markers_array);
+ }
+ };
+
+ Gmaps4RailsOpenlayers.prototype.clearClusterer = function() {
+ return this.serviceObject.removeLayer(this.markerClusterer);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.createInfoWindow = function(marker_container) {
+ if (marker_container.description != null) {
+ return marker_container.serviceObject.infoWindow = marker_container.description;
+ }
+ };
+
+ Gmaps4RailsOpenlayers.prototype.onPopupClose = function(evt) {
+ return this.markersControl.unselect(this.feature);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.onFeatureSelect = function(evt) {
+ var feature, popup;
+ feature = evt.feature;
+ popup = new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(300, 200), feature.infoWindow, null, true, this.onPopupClose);
+ feature.popup = popup;
+ popup.feature = feature;
+ return this.map.addPopup(popup);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.onFeatureUnselect = function(evt) {
+ var feature;
+ feature = evt.feature;
+ if (feature.popup) {
+ this.map.removePopup(feature.popup);
+ feature.popup.destroy();
+ return feature.popup = null;
+ }
+ };
+
+ Gmaps4RailsOpenlayers.prototype.create_polyline = function(polyline) {
+ var clickable, element, latlng, line_points, line_style, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _len;
+ if (this.polylinesLayer === null) {
+ this.polylinesLayer = new OpenLayers.Layer.Vector("Polylines", null);
+ this.serviceObject.addLayer(this.polylinesLayer);
+ this.polylinesLayer.events.register("featureselected", this.polylinesLayer, this.onFeatureSelect);
+ this.polylinesLayer.events.register("featureunselected", this.polylinesLayer, this.onFeatureUnselect);
+ this.polylinesControl = new OpenLayers.Control.DrawFeature(this.polylinesLayer, OpenLayers.Handler.Path);
+ this.serviceObject.addControl(this.polylinesControl);
+ }
+ polyline_coordinates = [];
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
+ element = polyline[_i];
+ if (element === polyline[0]) {
+ strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
+ strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
+ strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
+ clickable = element.clickable || this.polylines_conf.clickable;
+ zIndex = element.zIndex || this.polylines_conf.zIndex;
+ }
+ if ((element.lat != null) && (element.lng != null)) {
+ latlng = new OpenLayers.Geometry.Point(element.lng, element.lat);
+ polyline_coordinates.push(latlng);
+ }
+ }
+ line_points = new OpenLayers.Geometry.LineString(polyline_coordinates);
+ line_style = {
+ strokeColor: strokeColor,
+ strokeOpacity: strokeOpacity,
+ strokeWidth: strokeWeight
+ };
+ polyline = new OpenLayers.Feature.Vector(line_points, null, line_style);
+ polyline.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+ this.polylinesLayer.addFeatures([polyline]);
+ return polyline;
+ };
+
+ Gmaps4RailsOpenlayers.prototype.updateBoundsWithPolylines = function() {};
+
+ Gmaps4RailsOpenlayers.prototype.updateBoundsWithPolygons = function() {};
+
+ Gmaps4RailsOpenlayers.prototype.updateBoundsWithCircles = function() {};
+
+ Gmaps4RailsOpenlayers.prototype.fitBounds = function() {
+ return this.serviceObject.zoomToExtent(this.boundsObject, true);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.centerMapOnUser = function() {
+ return this.serviceObject.setCenter(this.userLocation);
+ };
+
+ Gmaps4RailsOpenlayers.prototype.extendMapBounds = function() {};
+
+ Gmaps4RailsOpenlayers.prototype.adaptMapToBounds = function() {
+ return this.fitBounds();
+ };
+
+ return Gmaps4RailsOpenlayers;
+
+ })(Gmaps4Rails);
+
+}).call(this);
diff --git a/public/stylesheets/gmaps4rails.css b/public/stylesheets/gmaps4rails.css
new file mode 100644
index 00000000..987bd8aa
--- /dev/null
+++ b/public/stylesheets/gmaps4rails.css
@@ -0,0 +1,24 @@
+.map_container {
+ padding: 6px;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ccc #ccc #999 #ccc;
+ -webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
+ -moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
+ box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
+ width: 800px;
+}
+
+.gmaps4rails_map {
+ width: 800px;
+ height: 400px;
+}
+
+.bing_map {
+ position: absolute;
+ top: 20;
+ left: 10;
+ width: 400px;
+ height: 400px;
+ border:#555555 2px solid;
+}
\ No newline at end of file
diff --git a/vendor/tidy.xsl b/vendor/tidy.xsl
index 01e26391..5adab2dc 100644
--- a/vendor/tidy.xsl
+++ b/vendor/tidy.xsl
@@ -15,13 +15,6 @@
-
-
-
-
-
-
-
@@ -31,17 +24,17 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
+
-
+