From 01623fb4d13fd09ac04e872cc7e8b664d8bc2585 Mon Sep 17 00:00:00 2001 From: Simon Olsberg Date: Thu, 8 Jan 2015 20:48:13 -0500 Subject: [PATCH 1/3] Add geocode rake task to geocode locations in meetups.yml using the geocoder gem. Add markers for the geocoded meetup locations to the map on the meetups page. --- Gemfile | 1 + Gemfile.lock | 4 +- Rakefile | 32 ++++ config.rb | 14 ++ data/meetups.yml | 341 +++++++++++++++++++++++++--------------- source/meetups.html.erb | 31 ++-- 6 files changed, 285 insertions(+), 138 deletions(-) diff --git a/Gemfile b/Gemfile index e035c3e414..b9879c4b5b 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem "rails-assets-js-md5" gem "rails-assets-moment" gem "underscore-rails" gem "gmaps4rails" +gem "geocoder" group :development, :test do gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index 53a3369d04..d55b70f525 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,6 +65,7 @@ GEM execjs (2.2.2) ffi (1.9.6) ffi (1.9.6-x86-mingw32) + geocoder (1.2.6) gmaps4rails (2.1.2) haml (4.0.6) tilt @@ -214,6 +215,7 @@ DEPENDENCIES capybara coderay! ember-middleman + geocoder gmaps4rails highline listen @@ -231,4 +233,4 @@ DEPENDENCIES thin tzinfo-data underscore-rails - wdm (>= 0.1.0) \ No newline at end of file + wdm (>= 0.1.0) diff --git a/Rakefile b/Rakefile index 466deaccb5..fd92cec8bf 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,7 @@ require "bundler/setup" require 'yaml' +require 'geocoder' def git_initialize(repository) unless File.exist?(".git") @@ -89,6 +90,32 @@ def generate_ember_data_docs puts "Built #{repo_path} with SHA #{sha}" end +def geocode_meetups + output_path = 'meetups.yml' + puts "Geocoding records from #{output_path}... " + + data = YAML.load_file(File.expand_path("./data/#{output_path}")) + data.each_value do |groups| + groups.each do |group| + next if group.has_key?("lat") and group.has_key?("lat") + coord = Geocoder.coordinates(group["location"]) + if coord.nil? + puts "Unable to find coordinates for #{group["location"]}" + next + end + group["lat"] = coord[0] + group["lon"] = coord[1] + puts "Found coordinates for #{group["location"]}" + #throttle requests to API to avoid errors + sleep 0.1 + end + end + + File.open(File.expand_path("../data/#{output_path}", __FILE__), "w") do |f| + YAML.dump(data, f) + end +end + def build system "middleman build" end @@ -155,3 +182,8 @@ task :deploy do |t, args| system "git push origin master" unless ENV['NODEPLOY'] end end + +desc "Find coordinates for meetup locations" +task :geocode do + geocode_meetups +end diff --git a/config.rb b/config.rb index 6c18cd1131..fb7e5721f1 100644 --- a/config.rb +++ b/config.rb @@ -136,4 +136,18 @@ def load_example_files all_files end + + def markers_hash + markers = [] + data.meetups.each do |name, groups| + groups_with_coords = groups.reject{|g| g.lat.nil? || g.lon.nil?} + hash = Gmaps4rails.build_markers(groups_with_coords) do |group, marker| + marker.lat group.lat + marker.lng group.lon + marker.infowindow "

#{group.location}

" + end + markers = markers.concat(hash) + end + markers + end end diff --git a/data/meetups.yml b/data/meetups.yml index e5711ce3b5..c3eee22899 100644 --- a/data/meetups.yml +++ b/data/meetups.yml @@ -1,123 +1,218 @@ -"North America": - - location: San Francisco, CA - url: http://www.meetup.com/Ember-SF/ - image: 07sanfrancisco.png - - location: New York, NY - url: http://www.meetup.com/EmberJS-NYC/ - image: 04newyork.png - - location: Chicago, IL - url: http://www.meetup.com/Chicago-Ember-js/ - image: 03chicago.png - - location: Boston, MA - url: http://www.meetup.com/Boston-Ember-js/ - image: 02boston.png - - location: Atlanta, GA - url: http://www.meetup.com/Ember-Atlanta-Meetup/ - image: 01atlanta.png - - location: Southern California, CA - url: http://www.meetup.com/Ember-SC/ - image: 05socal.png - - location: Philadelphia, PA - url: http://www.meetup.com/Emberjs-Philly/ - image: 06philadelphia.png - - location: Seattle, WA - url: http://www.meetup.com/Ember-js-Seattle-Meetup/ - image: 08seattle.png - - location: St. Louis, MO - url: http://www.meetup.com/STLEmber - - location: Austin, TX - url: http://www.meetup.com/Ember-ATX/ - image: 16austin.png - - location: Washington, DC - url: http://www.meetup.com/Ember-JS-DC/ - image: 19washington.png - - location: Salt Lake City, UT - url: http://www.meetup.com/EmberJS-SLC - - location: Cincinnati, OH - url: http://www.meetup.com/Embernati - - location: Minneapolis / St. Paul, MN - url: http://www.meetup.com/Ember-Twin-Cities - - location: Portland, OR - url: http://www.meetup.com/Ember-PDX/ - - location: Pittsburgh, PA - url: http://www.meetup.com/Ember-js-Pittsburgh/ - - location: Denver, CO - url: http://www.meetup.com/Ember-js-Denver/ - - location: Dallas, TX - url: http://www.meetup.com/Ember-Dallas - - location: Orlando, FL - url: http://www.meetup.com/Ember-js-Orlando/ - image: 01orlando.png - - location: Indianapolis, IN - url: http://www.meetup.com/Ember-js-Indianapolis/ - - location: Toronto, Canada - url: http://www.meetup.com/Toronto-Ember-JS-Meetup/ - image: 15toronto.png - - location: Ottawa, Canada - url: http://www.meetup.com/Ember-js-Ottawa/ - image: 13ottawa.png - - location: Vancouver, Canada - url: http://www.meetup.com/Vancouver-Ember-js/ - - location: San Juan, Puerto Rico - url: http://www.meetup.com/Ember-PR/ - image: 21puertorico.png - - location: Calgary, Canada - url: http://www.meetup.com/EmberJS-YYC/ - image: 23calgary.png -"South America": - - location: São Paulo, Brazil - url: http://www.meetup.com/Ember-js-Sao-Paulo/ - - location: Belo Horizonte, Brazil - url: http://www.meetup.com/Ember-BH/ - - location: Montevideo, Uruguay - url: http://www.meetup.com/ember-montevideo/ -"Europe": - - location: Paris, France - url: http://www.meetup.com/EmberJS-Paris/ - image: 14paris.png - - location: London, UK - url: http://emberlondon.com - image: 11london.png - - location: Dublin, Ireland - url: http://www.meetup.com/emberjsdublin/ - image: 10dublin.png - - location: Berlin, Germany - url: http://www.meetup.com/Ember-js-Berlin/ - image: 09berlin.png - - location: Munich, Germany - url: http://www.meetup.com/Ember-js-Munich/ - image: 12munich.png - - location: Göteborg, Sweden - url: http://www.meetup.com/ember-js-goteborg/ - image: 17goteborg.png - - location: Budapest, Hungary - url: http://www.meetup.com/ember-bp/ - - location: Oslo, Norway - url: http://www.meetup.com/Ember-js-Oslo/ - - location: Brussels, Belgium - url: http://www.meetup.com/Ember-js-Brussels/ - - location: Barcelona, Spain - url: http://www.meetup.com/Ember-js-Barcelona/ - image: 22barcelona.png - - location: Kyiv, Ukraine - url: http://ember-club.kiev.ua - - location: Zürich, Switzerland - url: http://www.meetup.com/Ember-js-Zurich/ - - location: Amsterdam, the Netherlands - url: http://www.meetup.com/Amsterdam-Ember-js/ -"Asia": - - location: Tel Aviv, Israel - url: http://www.meetup.com/Ember-IL/ - image: 20telaviv.png - - location: Bangalore, India - url: http://www.meetup.com/EmberJS-Bangalore/ - - location: Tokyo, Japan - url: http://emberjs.doorkeeper.jp/ -"Australia": - - location: Adelaide, Australia - url: http://www.meetup.com/Ember-js-Adelaide - - location: Melbourne, Australia - url: http://www.meetup.com/Ember-Melb-JS/ - image: 18melbourne.png - - location: Wellington, New Zealand - url: http://www.meetup.com/ember-js-wellington/ +--- +North America: +- location: San Francisco, CA + url: http://www.meetup.com/Ember-SF/ + image: 07sanfrancisco.png + lat: 37.7749295 + lon: -122.4194155 +- location: New York, NY + url: http://www.meetup.com/EmberJS-NYC/ + image: 04newyork.png + lat: 40.7127837 + lon: -74.0059413 +- location: Chicago, IL + url: http://www.meetup.com/Chicago-Ember-js/ + image: 03chicago.png + lat: 41.8781136 + lon: -87.6297982 +- location: Boston, MA + url: http://www.meetup.com/Boston-Ember-js/ + image: 02boston.png + lat: 42.3600825 + lon: -71.0588801 +- location: Atlanta, GA + url: http://www.meetup.com/Ember-Atlanta-Meetup/ + image: 01atlanta.png + lat: 33.7489954 + lon: -84.3879824 +- location: Southern California, CA + url: http://www.meetup.com/Ember-SC/ + image: 05socal.png + lat: 34.9592083 + lon: -116.419389 +- location: Philadelphia, PA + url: http://www.meetup.com/Emberjs-Philly/ + image: 06philadelphia.png + lat: 39.9525839 + lon: -75.1652215 +- location: Seattle, WA + url: http://www.meetup.com/Ember-js-Seattle-Meetup/ + image: 08seattle.png + lat: 47.6062095 + lon: -122.3320708 +- location: St. Louis, MO + url: http://www.meetup.com/STLEmber + lat: 38.6270025 + lon: -90.19940419999999 +- location: Austin, TX + url: http://www.meetup.com/Ember-ATX/ + image: 16austin.png + lat: 30.267153 + lon: -97.7430608 +- location: Washington, DC + url: http://www.meetup.com/Ember-JS-DC/ + image: 19washington.png + lat: 38.9071923 + lon: -77.0368707 +- location: Salt Lake City, UT + url: http://www.meetup.com/EmberJS-SLC + lat: 40.7607793 + lon: -111.8910474 +- location: Cincinnati, OH + url: http://www.meetup.com/Embernati + lat: 39.1031182 + lon: -84.5120196 +- location: Minneapolis / St. Paul, MN + url: http://www.meetup.com/Ember-Twin-Cities + lat: 44.9716692 + lon: -93.2806134 +- location: Portland, OR + url: http://www.meetup.com/Ember-PDX/ + lat: 45.5230622 + lon: -122.6764816 +- location: Pittsburgh, PA + url: http://www.meetup.com/Ember-js-Pittsburgh/ + lat: 40.44062479999999 + lon: -79.9958864 +- location: Denver, CO + url: http://www.meetup.com/Ember-js-Denver/ + lat: 39.7384357 + lon: -104.9848593 +- location: Dallas, TX + url: http://www.meetup.com/Ember-Dallas + lat: 32.7802618 + lon: -96.8009781 +- location: Orlando, FL + url: http://www.meetup.com/Ember-js-Orlando/ + image: 01orlando.png + lat: 28.5383355 + lon: -81.3792365 +- location: Indianapolis, IN + url: http://www.meetup.com/Ember-js-Indianapolis/ + lat: 39.768403 + lon: -86.158068 +- location: Toronto, Canada + url: http://www.meetup.com/Toronto-Ember-JS-Meetup/ + image: 15toronto.png + lat: 43.653226 + lon: -79.3831843 +- location: Ottawa, Canada + url: http://www.meetup.com/Ember-js-Ottawa/ + image: 13ottawa.png + lat: 45.4215296 + lon: -75.69719309999999 +- location: Vancouver, Canada + url: http://www.meetup.com/Vancouver-Ember-js/ + lat: 49.2827291 + lon: -123.1207375 +- location: San Juan, Puerto Rico + url: http://www.meetup.com/Ember-PR/ + image: 21puertorico.png + lat: 18.4663338 + lon: -66.1057217 +- location: Calgary, Canada + url: http://www.meetup.com/EmberJS-YYC/ + image: 23calgary.png + lat: 51.0486151 + lon: -114.0708459 +South America: +- location: São Paulo, Brazil + url: http://www.meetup.com/Ember-js-Sao-Paulo/ + lat: -23.5505199 + lon: -46.63330939999999 +- location: Belo Horizonte, Brazil + url: http://www.meetup.com/Ember-BH/ + lat: -19.9166813 + lon: -43.9344931 +- location: Montevideo, Uruguay + url: http://www.meetup.com/ember-montevideo/ + lat: -34.9011127 + lon: -56.16453139999999 +Europe: +- location: Paris, France + url: http://www.meetup.com/EmberJS-Paris/ + image: 14paris.png + lat: 48.856614 + lon: 2.3522219 +- location: London, UK + url: http://emberlondon.com + image: 11london.png + lat: 51.5073509 + lon: -0.1277583 +- location: Dublin, Ireland + url: http://www.meetup.com/emberjsdublin/ + image: 10dublin.png + lat: 53.3498053 + lon: -6.2603097 +- location: Berlin, Germany + url: http://www.meetup.com/Ember-js-Berlin/ + image: 09berlin.png + lat: 52.52000659999999 + lon: 13.404954 +- location: Munich, Germany + url: http://www.meetup.com/Ember-js-Munich/ + image: 12munich.png + lat: 48.1351253 + lon: 11.5819806 +- location: Göteborg, Sweden + url: http://www.meetup.com/ember-js-goteborg/ + image: 17goteborg.png + lat: 57.70887 + lon: 11.97456 +- location: Budapest, Hungary + url: http://www.meetup.com/ember-bp/ + lat: 47.497912 + lon: 19.040235 +- location: Oslo, Norway + url: http://www.meetup.com/Ember-js-Oslo/ + lat: 59.9138688 + lon: 10.7522454 +- location: Brussels, Belgium + url: http://www.meetup.com/Ember-js-Brussels/ + lat: 50.8503396 + lon: 4.3517103 +- location: Barcelona, Spain + url: http://www.meetup.com/Ember-js-Barcelona/ + image: 22barcelona.png + lat: 41.3850639 + lon: 2.1734035 +- location: Kyiv, Ukraine + url: http://ember-club.kiev.ua + lat: 50.4501 + lon: 30.5234 +- location: Zürich, Switzerland + url: http://www.meetup.com/Ember-js-Zurich/ + lat: 47.3686498 + lon: 8.539182499999999 +- location: Amsterdam, the Netherlands + url: http://www.meetup.com/Amsterdam-Ember-js/ + lat: 52.3702157 + lon: 4.895167900000001 +Asia: +- location: Tel Aviv, Israel + url: http://www.meetup.com/Ember-IL/ + image: 20telaviv.png + lat: 32.0852999 + lon: 34.78176759999999 +- location: Bangalore, India + url: http://www.meetup.com/EmberJS-Bangalore/ + lat: 12.9715987 + lon: 77.5945627 +- location: Tokyo, Japan + url: http://emberjs.doorkeeper.jp/ + lat: 35.7090259 + lon: 139.7319925 +Australia: +- location: Adelaide, Australia + url: http://www.meetup.com/Ember-js-Adelaide + lat: -34.92862119999999 + lon: 138.5999594 +- location: Melbourne, Australia + url: http://www.meetup.com/Ember-Melb-JS/ + image: 18melbourne.png + lat: -37.814107 + lon: 144.96328 +- location: Wellington, New Zealand + url: http://www.meetup.com/ember-js-wellington/ + lat: -41.2864603 + lon: 174.776236 diff --git a/source/meetups.html.erb b/source/meetups.html.erb index c67c0746b5..4847d5df76 100644 --- a/source/meetups.html.erb +++ b/source/meetups.html.erb @@ -74,20 +74,23 @@ title: "Meetups" style: google.maps.ZoomControlStyle.SMALL }, }, - internal: {id: 'map'}}, function(){ - var markers = handler.addMarkers([ - { - "lat": 33.7677129, - "lng": -84.420604, - "picture": { - "url": "/images/meetups/map-pin.png", - "width": 20, - "height": 28 - }, - "infowindow": "

Atlanta, GA

William Metz
Organizer
Chris McCuller
Organizer
Shane Ballman
Organizer
" - }, - ]); + internal: { + id: 'map' + } + }, function(){ + markers = handler.addMarkers(<%= markers_hash.to_json %>); handler.bounds.extendWith(markers); - handler.fitMapToBounds(); + // handler.fitMapToBounds(); + if(navigator.geolocation){ + navigator.geolocation.getCurrentPosition(function(position){ + var pos = new google.maps.LatLng(position.coords.latitude, + position.coords.longitude); + handler.map.centerOn(pos); + handler.map.serviceObject.setZoom(8); + }, handler.fitMapToBounds.bind(handler)); + } + else { + handler.fitMapToBounds(); + } }); \ No newline at end of file From c4af5e36569be0ff996343790672682d2ec4906c Mon Sep 17 00:00:00 2001 From: Simon Olsberg Date: Thu, 8 Jan 2015 20:48:13 -0500 Subject: [PATCH 2/3] Add geocode rake task to geocode locations in meetups.yml using the geocoder gem. Add markers for the geocoded meetup locations to the map on the meetups page. --- Gemfile | 1 + Gemfile.lock | 4 +- Rakefile | 32 +++ config.rb | 14 ++ data/meetups.yml | 383 +++++++++++++++++++----------- source/javascripts/meetups.js | 24 -- source/javascripts/meetups.js.erb | 24 ++ source/meetups.html.erb | 1 - 8 files changed, 312 insertions(+), 171 deletions(-) delete mode 100644 source/javascripts/meetups.js create mode 100644 source/javascripts/meetups.js.erb diff --git a/Gemfile b/Gemfile index e035c3e414..b9879c4b5b 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem "rails-assets-js-md5" gem "rails-assets-moment" gem "underscore-rails" gem "gmaps4rails" +gem "geocoder" group :development, :test do gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index 53a3369d04..d55b70f525 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,6 +65,7 @@ GEM execjs (2.2.2) ffi (1.9.6) ffi (1.9.6-x86-mingw32) + geocoder (1.2.6) gmaps4rails (2.1.2) haml (4.0.6) tilt @@ -214,6 +215,7 @@ DEPENDENCIES capybara coderay! ember-middleman + geocoder gmaps4rails highline listen @@ -231,4 +233,4 @@ DEPENDENCIES thin tzinfo-data underscore-rails - wdm (>= 0.1.0) \ No newline at end of file + wdm (>= 0.1.0) diff --git a/Rakefile b/Rakefile index 466deaccb5..b3f4fc9ebb 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,7 @@ require "bundler/setup" require 'yaml' +require 'geocoder' def git_initialize(repository) unless File.exist?(".git") @@ -89,6 +90,32 @@ def generate_ember_data_docs puts "Built #{repo_path} with SHA #{sha}" end +def geocode_meetups + output_path = 'meetups.yml' + puts "Geocoding records from #{output_path}... " + + data = YAML.load_file(File.expand_path("./data/#{output_path}")) + data["locations"].each_value do |groups| + groups.each do |group| + next if group.has_key?("lat") and group.has_key?("lat") + coord = Geocoder.coordinates(group["location"]) + if coord.nil? + puts "Unable to find coordinates for #{group["location"]}" + next + end + group["lat"] = coord[0] + group["lon"] = coord[1] + puts "Found coordinates for #{group["location"]}" + #throttle requests to API to avoid errors + sleep 0.1 + end + end + + File.open(File.expand_path("../data/#{output_path}", __FILE__), "w") do |f| + YAML.dump(data, f) + end +end + def build system "middleman build" end @@ -155,3 +182,8 @@ task :deploy do |t, args| system "git push origin master" unless ENV['NODEPLOY'] end end + +desc "Find coordinates for meetup locations" +task :geocode do + geocode_meetups +end diff --git a/config.rb b/config.rb index 6c18cd1131..4db35c8c50 100644 --- a/config.rb +++ b/config.rb @@ -136,4 +136,18 @@ def load_example_files all_files end + + def markers_hash + markers = [] + data.meetups["locations"].each do |name, groups| + groups_with_coords = groups.reject{|g| g.lat.nil? || g.lon.nil?} + hash = Gmaps4rails.build_markers(groups_with_coords) do |group, marker| + marker.lat group.lat + marker.lng group.lon + marker.infowindow "

#{group.location}

" + end + markers = markers.concat(hash) + end + markers + end end diff --git a/data/meetups.yml b/data/meetups.yml index 1f182f050b..d8c872a40c 100644 --- a/data/meetups.yml +++ b/data/meetups.yml @@ -1,3 +1,4 @@ +--- google_map: options: internal: @@ -5,150 +6,242 @@ google_map: provider: streetViewControl: false panControl: false - zoomControlOptions: + zoomControlOptions: styles: - - featureType: road - elementType: geometry - stylers: - - lightness: 100 - - visibility: simplified - - featureType: road - elementType: labels - stylers: - - visibility: off - - featureType: poi - stylers: - - visibility: off - - featureType: poi - elementType: labels.text - stylers: - - visibility: off - - featureType: transit - stylers: - - visibility: off - + - featureType: road + elementType: geometry + stylers: + - lightness: 100 + - visibility: simplified + - featureType: road + elementType: labels + stylers: + - visibility: false + - featureType: poi + stylers: + - visibility: false + - featureType: poi + elementType: labels.text + stylers: + - visibility: false + - featureType: transit + stylers: + - visibility: false locations: - "North America": - - location: San Francisco, CA - url: http://www.meetup.com/Ember-SF/ - image: 07sanfrancisco.png - - location: New York, NY - url: http://www.meetup.com/EmberJS-NYC/ - image: 04newyork.png - - location: Chicago, IL - url: http://www.meetup.com/Chicago-Ember-js/ - image: 03chicago.png - - location: Boston, MA - url: http://www.meetup.com/Boston-Ember-js/ - image: 02boston.png - - location: Atlanta, GA - url: http://www.meetup.com/Ember-Atlanta-Meetup/ - image: 01atlanta.png - - location: Southern California, CA - url: http://www.meetup.com/Ember-SC/ - image: 05socal.png - - location: Philadelphia, PA - url: http://www.meetup.com/Emberjs-Philly/ - image: 06philadelphia.png - - location: Seattle, WA - url: http://www.meetup.com/Ember-js-Seattle-Meetup/ - image: 08seattle.png - - location: St. Louis, MO - url: http://www.meetup.com/STLEmber - - location: Austin, TX - url: http://www.meetup.com/Ember-ATX/ - image: 16austin.png - - location: Washington, DC - url: http://www.meetup.com/Ember-JS-DC/ - image: 19washington.png - - location: Salt Lake City, UT - url: http://www.meetup.com/EmberJS-SLC - - location: Cincinnati, OH - url: http://www.meetup.com/Embernati - - location: Minneapolis / St. Paul, MN - url: http://www.meetup.com/Ember-Twin-Cities - - location: Portland, OR - url: http://www.meetup.com/Ember-PDX/ - - location: Pittsburgh, PA - url: http://www.meetup.com/Ember-js-Pittsburgh/ - - location: Denver, CO - url: http://www.meetup.com/Ember-js-Denver/ - - location: Dallas, TX - url: http://www.meetup.com/Ember-Dallas - - location: Orlando, FL - url: http://www.meetup.com/Ember-js-Orlando/ - image: 01orlando.png - - location: Indianapolis, IN - url: http://www.meetup.com/Ember-js-Indianapolis/ - - location: Toronto, Canada - url: http://www.meetup.com/Toronto-Ember-JS-Meetup/ - image: 15toronto.png - - location: Ottawa, Canada - url: http://www.meetup.com/Ember-js-Ottawa/ - image: 13ottawa.png - - location: Vancouver, Canada - url: http://www.meetup.com/Vancouver-Ember-js/ - - location: San Juan, Puerto Rico - url: http://www.meetup.com/Ember-PR/ - image: 21puertorico.png - - location: Calgary, Canada - url: http://www.meetup.com/EmberJS-YYC/ - image: 23calgary.png - "South America": - - location: São Paulo, Brazil - url: http://www.meetup.com/Ember-js-Sao-Paulo/ - - location: Belo Horizonte, Brazil - url: http://www.meetup.com/Ember-BH/ - - location: Montevideo, Uruguay - url: http://www.meetup.com/ember-montevideo/ - "Europe": - - location: Paris, France - url: http://www.meetup.com/EmberJS-Paris/ - image: 14paris.png - - location: London, UK - url: http://emberlondon.com - image: 11london.png - - location: Dublin, Ireland - url: http://www.meetup.com/emberjsdublin/ - image: 10dublin.png - - location: Berlin, Germany - url: http://www.meetup.com/Ember-js-Berlin/ - image: 09berlin.png - - location: Munich, Germany - url: http://www.meetup.com/Ember-js-Munich/ - image: 12munich.png - - location: Göteborg, Sweden - url: http://www.meetup.com/ember-js-goteborg/ - image: 17goteborg.png - - location: Budapest, Hungary - url: http://www.meetup.com/ember-bp/ - - location: Oslo, Norway - url: http://www.meetup.com/Ember-js-Oslo/ - - location: Brussels, Belgium - url: http://www.meetup.com/Ember-js-Brussels/ - - location: Barcelona, Spain - url: http://www.meetup.com/Ember-js-Barcelona/ - image: 22barcelona.png - - location: Kyiv, Ukraine - url: http://ember-club.kiev.ua - - location: Zürich, Switzerland - url: http://www.meetup.com/Ember-js-Zurich/ - - location: Amsterdam, the Netherlands - url: http://www.meetup.com/Amsterdam-Ember-js/ - "Asia": - - location: Tel Aviv, Israel - url: http://www.meetup.com/Ember-IL/ - image: 20telaviv.png - - location: Bangalore, India - url: http://www.meetup.com/EmberJS-Bangalore/ - - location: Tokyo, Japan - url: http://emberjs.doorkeeper.jp/ - "Australia": - - location: Adelaide, Australia - url: http://www.meetup.com/Ember-js-Adelaide - - location: Melbourne, Australia - url: http://www.meetup.com/Ember-Melb-JS/ - image: 18melbourne.png - - location: Wellington, New Zealand - url: http://www.meetup.com/ember-js-wellington/ - + North America: + - location: San Francisco, CA + url: http://www.meetup.com/Ember-SF/ + image: 07sanfrancisco.png + lat: 37.7749295 + lon: -122.4194155 + - location: New York, NY + url: http://www.meetup.com/EmberJS-NYC/ + image: 04newyork.png + lat: 40.7127837 + lon: -74.0059413 + - location: Chicago, IL + url: http://www.meetup.com/Chicago-Ember-js/ + image: 03chicago.png + lat: 41.8781136 + lon: -87.6297982 + - location: Boston, MA + url: http://www.meetup.com/Boston-Ember-js/ + image: 02boston.png + lat: 42.3600825 + lon: -71.0588801 + - location: Atlanta, GA + url: http://www.meetup.com/Ember-Atlanta-Meetup/ + image: 01atlanta.png + lat: 33.7489954 + lon: -84.3879824 + - location: Southern California, CA + url: http://www.meetup.com/Ember-SC/ + image: 05socal.png + lat: 34.9592083 + lon: -116.419389 + - location: Philadelphia, PA + url: http://www.meetup.com/Emberjs-Philly/ + image: 06philadelphia.png + lat: 39.9525839 + lon: -75.1652215 + - location: Seattle, WA + url: http://www.meetup.com/Ember-js-Seattle-Meetup/ + image: 08seattle.png + lat: 47.6062095 + lon: -122.3320708 + - location: St. Louis, MO + url: http://www.meetup.com/STLEmber + lat: 38.6270025 + lon: -90.19940419999999 + - location: Austin, TX + url: http://www.meetup.com/Ember-ATX/ + image: 16austin.png + lat: 30.267153 + lon: -97.7430608 + - location: Washington, DC + url: http://www.meetup.com/Ember-JS-DC/ + image: 19washington.png + lat: 38.9071923 + lon: -77.0368707 + - location: Salt Lake City, UT + url: http://www.meetup.com/EmberJS-SLC + lat: 40.7607793 + lon: -111.8910474 + - location: Cincinnati, OH + url: http://www.meetup.com/Embernati + lat: 39.1031182 + lon: -84.5120196 + - location: Minneapolis / St. Paul, MN + url: http://www.meetup.com/Ember-Twin-Cities + lat: 44.9716692 + lon: -93.2806134 + - location: Portland, OR + url: http://www.meetup.com/Ember-PDX/ + lat: 45.5230622 + lon: -122.6764816 + - location: Pittsburgh, PA + url: http://www.meetup.com/Ember-js-Pittsburgh/ + lat: 40.44062479999999 + lon: -79.9958864 + - location: Denver, CO + url: http://www.meetup.com/Ember-js-Denver/ + lat: 39.7384357 + lon: -104.9848593 + - location: Dallas, TX + url: http://www.meetup.com/Ember-Dallas + lat: 32.7802618 + lon: -96.8009781 + - location: Orlando, FL + url: http://www.meetup.com/Ember-js-Orlando/ + image: 01orlando.png + lat: 28.5383355 + lon: -81.3792365 + - location: Indianapolis, IN + url: http://www.meetup.com/Ember-js-Indianapolis/ + lat: 39.768403 + lon: -86.158068 + - location: Toronto, Canada + url: http://www.meetup.com/Toronto-Ember-JS-Meetup/ + image: 15toronto.png + lat: 43.653226 + lon: -79.3831843 + - location: Ottawa, Canada + url: http://www.meetup.com/Ember-js-Ottawa/ + image: 13ottawa.png + lat: 45.4215296 + lon: -75.69719309999999 + - location: Vancouver, Canada + url: http://www.meetup.com/Vancouver-Ember-js/ + lat: 49.2827291 + lon: -123.1207375 + - location: San Juan, Puerto Rico + url: http://www.meetup.com/Ember-PR/ + image: 21puertorico.png + lat: 18.4663338 + lon: -66.1057217 + - location: Calgary, Canada + url: http://www.meetup.com/EmberJS-YYC/ + image: 23calgary.png + lat: 51.0486151 + lon: -114.0708459 + South America: + - location: São Paulo, Brazil + url: http://www.meetup.com/Ember-js-Sao-Paulo/ + lat: -23.5505199 + lon: -46.63330939999999 + - location: Belo Horizonte, Brazil + url: http://www.meetup.com/Ember-BH/ + lat: -19.9166813 + lon: -43.9344931 + - location: Montevideo, Uruguay + url: http://www.meetup.com/ember-montevideo/ + lat: -34.9011127 + lon: -56.16453139999999 + Europe: + - location: Paris, France + url: http://www.meetup.com/EmberJS-Paris/ + image: 14paris.png + lat: 48.856614 + lon: 2.3522219 + - location: London, UK + url: http://emberlondon.com + image: 11london.png + lat: 51.5073509 + lon: -0.1277583 + - location: Dublin, Ireland + url: http://www.meetup.com/emberjsdublin/ + image: 10dublin.png + lat: 53.3498053 + lon: -6.2603097 + - location: Berlin, Germany + url: http://www.meetup.com/Ember-js-Berlin/ + image: 09berlin.png + lat: 52.52000659999999 + lon: 13.404954 + - location: Munich, Germany + url: http://www.meetup.com/Ember-js-Munich/ + image: 12munich.png + lat: 48.1351253 + lon: 11.5819806 + - location: Göteborg, Sweden + url: http://www.meetup.com/ember-js-goteborg/ + image: 17goteborg.png + lat: 57.70887 + lon: 11.97456 + - location: Budapest, Hungary + url: http://www.meetup.com/ember-bp/ + lat: 47.497912 + lon: 19.040235 + - location: Oslo, Norway + url: http://www.meetup.com/Ember-js-Oslo/ + lat: 59.9138688 + lon: 10.7522454 + - location: Brussels, Belgium + url: http://www.meetup.com/Ember-js-Brussels/ + lat: 50.8503396 + lon: 4.3517103 + - location: Barcelona, Spain + url: http://www.meetup.com/Ember-js-Barcelona/ + image: 22barcelona.png + lat: 41.3850639 + lon: 2.1734035 + - location: Kyiv, Ukraine + url: http://ember-club.kiev.ua + lat: 50.4501 + lon: 30.5234 + - location: Zürich, Switzerland + url: http://www.meetup.com/Ember-js-Zurich/ + lat: 47.3686498 + lon: 8.539182499999999 + - location: Amsterdam, the Netherlands + url: http://www.meetup.com/Amsterdam-Ember-js/ + lat: 52.3702157 + lon: 4.895167900000001 + Asia: + - location: Tel Aviv, Israel + url: http://www.meetup.com/Ember-IL/ + image: 20telaviv.png + lat: 32.0852999 + lon: 34.78176759999999 + - location: Bangalore, India + url: http://www.meetup.com/EmberJS-Bangalore/ + lat: 12.9715987 + lon: 77.5945627 + - location: Tokyo, Japan + url: http://emberjs.doorkeeper.jp/ + lat: 35.7090259 + lon: 139.7319925 + Australia: + - location: Adelaide, Australia + url: http://www.meetup.com/Ember-js-Adelaide + lat: -34.92862119999999 + lon: 138.5999594 + - location: Melbourne, Australia + url: http://www.meetup.com/Ember-Melb-JS/ + image: 18melbourne.png + lat: -37.814107 + lon: 144.96328 + - location: Wellington, New Zealand + url: http://www.meetup.com/ember-js-wellington/ + lat: -41.2864603 + lon: 174.776236 diff --git a/source/javascripts/meetups.js b/source/javascripts/meetups.js deleted file mode 100644 index 9bbb03e305..0000000000 --- a/source/javascripts/meetups.js +++ /dev/null @@ -1,24 +0,0 @@ -(function() { - var handler = Gmaps.build('Google'), - mapOptions = $('meta[name=mapOptions]').attr('content'); - - mapOptions = JSON.parse(mapOptions); - mapOptions.provider.zoomControlOptions = google.maps.ZoomControlStyle.SMALL; - - handler.buildMap(mapOptions, function(){ - var markers = handler.addMarkers([ - { - "lat": 33.7677129, - "lng": -84.420604, - "picture": { - "url": "/images/meetups/map-pin.png", - "width": 20, - "height": 28 - }, - "infowindow": "

Atlanta, GA

William Metz
Organizer
Chris McCuller
Organizer
Shane Ballman
Organizer
" - }, - ]); - handler.bounds.extendWith(markers); - handler.fitMapToBounds(); - }); -})(); diff --git a/source/javascripts/meetups.js.erb b/source/javascripts/meetups.js.erb new file mode 100644 index 0000000000..c7daab365c --- /dev/null +++ b/source/javascripts/meetups.js.erb @@ -0,0 +1,24 @@ +(function() { + var handler = Gmaps.build('Google'), + mapOptions = $('meta[name=mapOptions]').attr('content'); + + mapOptions = JSON.parse(mapOptions); + mapOptions.provider.zoomControlOptions = google.maps.ZoomControlStyle.SMALL; + + handler.buildMap(mapOptions, function(){ + var markers = handler.addMarkers(<%= markers_hash.to_json %>); + handler.bounds.extendWith(markers); + + if(navigator.geolocation){ + navigator.geolocation.getCurrentPosition(function(position){ + var pos = new google.maps.LatLng(position.coords.latitude, + position.coords.longitude); + handler.map.centerOn(pos); + handler.map.serviceObject.setZoom(8); + }, handler.fitMapToBounds.bind(handler)); + } + else { + handler.fitMapToBounds(); + } + }); +})(); diff --git a/source/meetups.html.erb b/source/meetups.html.erb index 6ffbe7d1de..eb923132cf 100644 --- a/source/meetups.html.erb +++ b/source/meetups.html.erb @@ -33,4 +33,3 @@ title: "Meetups" - From 53bd9edb02185f8d6ca90e165668866d060e54c9 Mon Sep 17 00:00:00 2001 From: Simon Olsberg Date: Sat, 10 Jan 2015 09:47:00 -0500 Subject: [PATCH 3/3] Geocoded locations are now written by the rake task to a json file which is directly loaded by the javascript at runtime to build the markers --- Rakefile | 32 +-- config.rb | 14 -- data/meetups.yml | 382 ++++++++++++------------------ source/data/meetup_locations.json | 1 + source/javascripts/meetups.js | 36 +++ source/javascripts/meetups.js.erb | 24 -- 6 files changed, 198 insertions(+), 291 deletions(-) create mode 100644 source/data/meetup_locations.json create mode 100644 source/javascripts/meetups.js delete mode 100644 source/javascripts/meetups.js.erb diff --git a/Rakefile b/Rakefile index b3f4fc9ebb..95405cc595 100644 --- a/Rakefile +++ b/Rakefile @@ -64,7 +64,6 @@ def generate_ember_docs end def generate_ember_data_docs - output_path = 'data_api.yml' repo_path = ember_data_path sha = ENV['EMBER_DATA_SHA'] @@ -95,25 +94,26 @@ def geocode_meetups puts "Geocoding records from #{output_path}... " data = YAML.load_file(File.expand_path("./data/#{output_path}")) - data["locations"].each_value do |groups| - groups.each do |group| - next if group.has_key?("lat") and group.has_key?("lat") - coord = Geocoder.coordinates(group["location"]) - if coord.nil? - puts "Unable to find coordinates for #{group["location"]}" - next - end - group["lat"] = coord[0] - group["lon"] = coord[1] - puts "Found coordinates for #{group["location"]}" - #throttle requests to API to avoid errors - sleep 0.1 + meetups = data["locations"].values.flatten + meetups.each do |meetup| + coord = Geocoder.coordinates(meetup["location"]) + if coord.nil? + puts "Unable to find coordinates for #{meetup["location"]}" + next end + meetup["lat"] = coord[0] + meetup["lon"] = coord[1] + puts "Found coordinates for #{meetup["location"]}" + #throttle requests to API to avoid errors + sleep 0.1 end - File.open(File.expand_path("../data/#{output_path}", __FILE__), "w") do |f| - YAML.dump(data, f) + File.open(File.expand_path("../source/data/meetup_locations.json", __FILE__),"w") do |f| + f.write(meetups.to_json) end + # File.open(File.expand_path("../data/#{output_path}", __FILE__), "w") do |f| + # YAML.dump(data, f) + # end end def build diff --git a/config.rb b/config.rb index 4db35c8c50..6c18cd1131 100644 --- a/config.rb +++ b/config.rb @@ -136,18 +136,4 @@ def load_example_files all_files end - - def markers_hash - markers = [] - data.meetups["locations"].each do |name, groups| - groups_with_coords = groups.reject{|g| g.lat.nil? || g.lon.nil?} - hash = Gmaps4rails.build_markers(groups_with_coords) do |group, marker| - marker.lat group.lat - marker.lng group.lon - marker.infowindow "

#{group.location}

" - end - markers = markers.concat(hash) - end - markers - end end diff --git a/data/meetups.yml b/data/meetups.yml index d8a2809165..1f182f050b 100644 --- a/data/meetups.yml +++ b/data/meetups.yml @@ -5,242 +5,150 @@ google_map: provider: streetViewControl: false panControl: false - zoomControlOptions: + zoomControlOptions: styles: - - featureType: road - elementType: geometry - stylers: - - lightness: 100 - - visibility: simplified - - featureType: road - elementType: labels - stylers: - - visibility: false - - featureType: poi - stylers: - - visibility: false - - featureType: poi - elementType: labels.text - stylers: - - visibility: false - - featureType: transit - stylers: - - visibility: false + - featureType: road + elementType: geometry + stylers: + - lightness: 100 + - visibility: simplified + - featureType: road + elementType: labels + stylers: + - visibility: off + - featureType: poi + stylers: + - visibility: off + - featureType: poi + elementType: labels.text + stylers: + - visibility: off + - featureType: transit + stylers: + - visibility: off + locations: - North America: - - location: San Francisco, CA - url: http://www.meetup.com/Ember-SF/ - image: 07sanfrancisco.png - lat: 37.7749295 - lon: -122.4194155 - - location: New York, NY - url: http://www.meetup.com/EmberJS-NYC/ - image: 04newyork.png - lat: 40.7127837 - lon: -74.0059413 - - location: Chicago, IL - url: http://www.meetup.com/Chicago-Ember-js/ - image: 03chicago.png - lat: 41.8781136 - lon: -87.6297982 - - location: Boston, MA - url: http://www.meetup.com/Boston-Ember-js/ - image: 02boston.png - lat: 42.3600825 - lon: -71.0588801 - - location: Atlanta, GA - url: http://www.meetup.com/Ember-Atlanta-Meetup/ - image: 01atlanta.png - lat: 33.7489954 - lon: -84.3879824 - - location: Southern California, CA - url: http://www.meetup.com/Ember-SC/ - image: 05socal.png - lat: 34.9592083 - lon: -116.419389 - - location: Philadelphia, PA - url: http://www.meetup.com/Emberjs-Philly/ - image: 06philadelphia.png - lat: 39.9525839 - lon: -75.1652215 - - location: Seattle, WA - url: http://www.meetup.com/Ember-js-Seattle-Meetup/ - image: 08seattle.png - lat: 47.6062095 - lon: -122.3320708 - - location: St. Louis, MO - url: http://www.meetup.com/STLEmber - lat: 38.6270025 - lon: -90.19940419999999 - - location: Austin, TX - url: http://www.meetup.com/Ember-ATX/ - image: 16austin.png - lat: 30.267153 - lon: -97.7430608 - - location: Washington, DC - url: http://www.meetup.com/Ember-JS-DC/ - image: 19washington.png - lat: 38.9071923 - lon: -77.0368707 - - location: Salt Lake City, UT - url: http://www.meetup.com/EmberJS-SLC - lat: 40.7607793 - lon: -111.8910474 - - location: Cincinnati, OH - url: http://www.meetup.com/Embernati - lat: 39.1031182 - lon: -84.5120196 - - location: Minneapolis / St. Paul, MN - url: http://www.meetup.com/Ember-Twin-Cities - lat: 44.9716692 - lon: -93.2806134 - - location: Portland, OR - url: http://www.meetup.com/Ember-PDX/ - lat: 45.5230622 - lon: -122.6764816 - - location: Pittsburgh, PA - url: http://www.meetup.com/Ember-js-Pittsburgh/ - lat: 40.44062479999999 - lon: -79.9958864 - - location: Denver, CO - url: http://www.meetup.com/Ember-js-Denver/ - lat: 39.7384357 - lon: -104.9848593 - - location: Dallas, TX - url: http://www.meetup.com/Ember-Dallas - lat: 32.7802618 - lon: -96.8009781 - - location: Orlando, FL - url: http://www.meetup.com/Ember-js-Orlando/ - image: 01orlando.png - lat: 28.5383355 - lon: -81.3792365 - - location: Indianapolis, IN - url: http://www.meetup.com/Ember-js-Indianapolis/ - lat: 39.768403 - lon: -86.158068 - - location: Toronto, Canada - url: http://www.meetup.com/Toronto-Ember-JS-Meetup/ - image: 15toronto.png - lat: 43.653226 - lon: -79.3831843 - - location: Ottawa, Canada - url: http://www.meetup.com/Ember-js-Ottawa/ - image: 13ottawa.png - lat: 45.4215296 - lon: -75.69719309999999 - - location: Vancouver, Canada - url: http://www.meetup.com/Vancouver-Ember-js/ - lat: 49.2827291 - lon: -123.1207375 - - location: San Juan, Puerto Rico - url: http://www.meetup.com/Ember-PR/ - image: 21puertorico.png - lat: 18.4663338 - lon: -66.1057217 - - location: Calgary, Canada - url: http://www.meetup.com/EmberJS-YYC/ - image: 23calgary.png - lat: 51.0486151 - lon: -114.0708459 - South America: - - location: São Paulo, Brazil - url: http://www.meetup.com/Ember-js-Sao-Paulo/ - lat: -23.5505199 - lon: -46.63330939999999 - - location: Belo Horizonte, Brazil - url: http://www.meetup.com/Ember-BH/ - lat: -19.9166813 - lon: -43.9344931 - - location: Montevideo, Uruguay - url: http://www.meetup.com/ember-montevideo/ - lat: -34.9011127 - lon: -56.16453139999999 - Europe: - - location: Paris, France - url: http://www.meetup.com/EmberJS-Paris/ - image: 14paris.png - lat: 48.856614 - lon: 2.3522219 - - location: London, UK - url: http://emberlondon.com - image: 11london.png - lat: 51.5073509 - lon: -0.1277583 - - location: Dublin, Ireland - url: http://www.meetup.com/emberjsdublin/ - image: 10dublin.png - lat: 53.3498053 - lon: -6.2603097 - - location: Berlin, Germany - url: http://www.meetup.com/Ember-js-Berlin/ - image: 09berlin.png - lat: 52.52000659999999 - lon: 13.404954 - - location: Munich, Germany - url: http://www.meetup.com/Ember-js-Munich/ - image: 12munich.png - lat: 48.1351253 - lon: 11.5819806 - - location: Göteborg, Sweden - url: http://www.meetup.com/ember-js-goteborg/ - image: 17goteborg.png - lat: 57.70887 - lon: 11.97456 - - location: Budapest, Hungary - url: http://www.meetup.com/ember-bp/ - lat: 47.497912 - lon: 19.040235 - - location: Oslo, Norway - url: http://www.meetup.com/Ember-js-Oslo/ - lat: 59.9138688 - lon: 10.7522454 - - location: Brussels, Belgium - url: http://www.meetup.com/Ember-js-Brussels/ - lat: 50.8503396 - lon: 4.3517103 - - location: Barcelona, Spain - url: http://www.meetup.com/Ember-js-Barcelona/ - image: 22barcelona.png - lat: 41.3850639 - lon: 2.1734035 - - location: Kyiv, Ukraine - url: http://ember-club.kiev.ua - lat: 50.4501 - lon: 30.5234 - - location: Zürich, Switzerland - url: http://www.meetup.com/Ember-js-Zurich/ - lat: 47.3686498 - lon: 8.539182499999999 - - location: Amsterdam, the Netherlands - url: http://www.meetup.com/Amsterdam-Ember-js/ - lat: 52.3702157 - lon: 4.895167900000001 - Asia: - - location: Tel Aviv, Israel - url: http://www.meetup.com/Ember-IL/ - image: 20telaviv.png - lat: 32.0852999 - lon: 34.78176759999999 - - location: Bangalore, India - url: http://www.meetup.com/EmberJS-Bangalore/ - lat: 12.9715987 - lon: 77.5945627 - - location: Tokyo, Japan - url: http://emberjs.doorkeeper.jp/ - lat: 35.7090259 - lon: 139.7319925 - Australia: - - location: Adelaide, Australia - url: http://www.meetup.com/Ember-js-Adelaide - lat: -34.92862119999999 - lon: 138.5999594 - - location: Melbourne, Australia - url: http://www.meetup.com/Ember-Melb-JS/ - image: 18melbourne.png - lat: -37.814107 - lon: 144.96328 - - location: Wellington, New Zealand - url: http://www.meetup.com/ember-js-wellington/ - lat: -41.2864603 - lon: 174.776236 + "North America": + - location: San Francisco, CA + url: http://www.meetup.com/Ember-SF/ + image: 07sanfrancisco.png + - location: New York, NY + url: http://www.meetup.com/EmberJS-NYC/ + image: 04newyork.png + - location: Chicago, IL + url: http://www.meetup.com/Chicago-Ember-js/ + image: 03chicago.png + - location: Boston, MA + url: http://www.meetup.com/Boston-Ember-js/ + image: 02boston.png + - location: Atlanta, GA + url: http://www.meetup.com/Ember-Atlanta-Meetup/ + image: 01atlanta.png + - location: Southern California, CA + url: http://www.meetup.com/Ember-SC/ + image: 05socal.png + - location: Philadelphia, PA + url: http://www.meetup.com/Emberjs-Philly/ + image: 06philadelphia.png + - location: Seattle, WA + url: http://www.meetup.com/Ember-js-Seattle-Meetup/ + image: 08seattle.png + - location: St. Louis, MO + url: http://www.meetup.com/STLEmber + - location: Austin, TX + url: http://www.meetup.com/Ember-ATX/ + image: 16austin.png + - location: Washington, DC + url: http://www.meetup.com/Ember-JS-DC/ + image: 19washington.png + - location: Salt Lake City, UT + url: http://www.meetup.com/EmberJS-SLC + - location: Cincinnati, OH + url: http://www.meetup.com/Embernati + - location: Minneapolis / St. Paul, MN + url: http://www.meetup.com/Ember-Twin-Cities + - location: Portland, OR + url: http://www.meetup.com/Ember-PDX/ + - location: Pittsburgh, PA + url: http://www.meetup.com/Ember-js-Pittsburgh/ + - location: Denver, CO + url: http://www.meetup.com/Ember-js-Denver/ + - location: Dallas, TX + url: http://www.meetup.com/Ember-Dallas + - location: Orlando, FL + url: http://www.meetup.com/Ember-js-Orlando/ + image: 01orlando.png + - location: Indianapolis, IN + url: http://www.meetup.com/Ember-js-Indianapolis/ + - location: Toronto, Canada + url: http://www.meetup.com/Toronto-Ember-JS-Meetup/ + image: 15toronto.png + - location: Ottawa, Canada + url: http://www.meetup.com/Ember-js-Ottawa/ + image: 13ottawa.png + - location: Vancouver, Canada + url: http://www.meetup.com/Vancouver-Ember-js/ + - location: San Juan, Puerto Rico + url: http://www.meetup.com/Ember-PR/ + image: 21puertorico.png + - location: Calgary, Canada + url: http://www.meetup.com/EmberJS-YYC/ + image: 23calgary.png + "South America": + - location: São Paulo, Brazil + url: http://www.meetup.com/Ember-js-Sao-Paulo/ + - location: Belo Horizonte, Brazil + url: http://www.meetup.com/Ember-BH/ + - location: Montevideo, Uruguay + url: http://www.meetup.com/ember-montevideo/ + "Europe": + - location: Paris, France + url: http://www.meetup.com/EmberJS-Paris/ + image: 14paris.png + - location: London, UK + url: http://emberlondon.com + image: 11london.png + - location: Dublin, Ireland + url: http://www.meetup.com/emberjsdublin/ + image: 10dublin.png + - location: Berlin, Germany + url: http://www.meetup.com/Ember-js-Berlin/ + image: 09berlin.png + - location: Munich, Germany + url: http://www.meetup.com/Ember-js-Munich/ + image: 12munich.png + - location: Göteborg, Sweden + url: http://www.meetup.com/ember-js-goteborg/ + image: 17goteborg.png + - location: Budapest, Hungary + url: http://www.meetup.com/ember-bp/ + - location: Oslo, Norway + url: http://www.meetup.com/Ember-js-Oslo/ + - location: Brussels, Belgium + url: http://www.meetup.com/Ember-js-Brussels/ + - location: Barcelona, Spain + url: http://www.meetup.com/Ember-js-Barcelona/ + image: 22barcelona.png + - location: Kyiv, Ukraine + url: http://ember-club.kiev.ua + - location: Zürich, Switzerland + url: http://www.meetup.com/Ember-js-Zurich/ + - location: Amsterdam, the Netherlands + url: http://www.meetup.com/Amsterdam-Ember-js/ + "Asia": + - location: Tel Aviv, Israel + url: http://www.meetup.com/Ember-IL/ + image: 20telaviv.png + - location: Bangalore, India + url: http://www.meetup.com/EmberJS-Bangalore/ + - location: Tokyo, Japan + url: http://emberjs.doorkeeper.jp/ + "Australia": + - location: Adelaide, Australia + url: http://www.meetup.com/Ember-js-Adelaide + - location: Melbourne, Australia + url: http://www.meetup.com/Ember-Melb-JS/ + image: 18melbourne.png + - location: Wellington, New Zealand + url: http://www.meetup.com/ember-js-wellington/ + diff --git a/source/data/meetup_locations.json b/source/data/meetup_locations.json new file mode 100644 index 0000000000..959bd7a61b --- /dev/null +++ b/source/data/meetup_locations.json @@ -0,0 +1 @@ +[{"location":"San Francisco, CA","url":"http://www.meetup.com/Ember-SF/","image":"07sanfrancisco.png","lat":37.7749295,"lon":-122.4194155},{"location":"New York, NY","url":"http://www.meetup.com/EmberJS-NYC/","image":"04newyork.png","lat":40.7127837,"lon":-74.0059413},{"location":"Chicago, IL","url":"http://www.meetup.com/Chicago-Ember-js/","image":"03chicago.png","lat":41.8781136,"lon":-87.6297982},{"location":"Boston, MA","url":"http://www.meetup.com/Boston-Ember-js/","image":"02boston.png","lat":42.3600825,"lon":-71.0588801},{"location":"Atlanta, GA","url":"http://www.meetup.com/Ember-Atlanta-Meetup/","image":"01atlanta.png","lat":33.7489954,"lon":-84.3879824},{"location":"Southern California, CA","url":"http://www.meetup.com/Ember-SC/","image":"05socal.png","lat":34.9592083,"lon":-116.419389},{"location":"Philadelphia, PA","url":"http://www.meetup.com/Emberjs-Philly/","image":"06philadelphia.png","lat":39.9525839,"lon":-75.1652215},{"location":"Seattle, WA","url":"http://www.meetup.com/Ember-js-Seattle-Meetup/","image":"08seattle.png","lat":47.6062095,"lon":-122.3320708},{"location":"St. Louis, MO","url":"http://www.meetup.com/STLEmber","lat":38.6270025,"lon":-90.19940419999999},{"location":"Austin, TX","url":"http://www.meetup.com/Ember-ATX/","image":"16austin.png","lat":30.267153,"lon":-97.7430608},{"location":"Washington, DC","url":"http://www.meetup.com/Ember-JS-DC/","image":"19washington.png","lat":38.9071923,"lon":-77.0368707},{"location":"Salt Lake City, UT","url":"http://www.meetup.com/EmberJS-SLC","lat":40.7607793,"lon":-111.8910474},{"location":"Cincinnati, OH","url":"http://www.meetup.com/Embernati","lat":39.1031182,"lon":-84.5120196},{"location":"Minneapolis / St. Paul, MN","url":"http://www.meetup.com/Ember-Twin-Cities","lat":44.9716692,"lon":-93.2806134},{"location":"Portland, OR","url":"http://www.meetup.com/Ember-PDX/","lat":45.5230622,"lon":-122.6764816},{"location":"Pittsburgh, PA","url":"http://www.meetup.com/Ember-js-Pittsburgh/","lat":40.44062479999999,"lon":-79.9958864},{"location":"Denver, CO","url":"http://www.meetup.com/Ember-js-Denver/","lat":39.7392358,"lon":-104.990251},{"location":"Dallas, TX","url":"http://www.meetup.com/Ember-Dallas","lat":32.7766642,"lon":-96.79698789999999},{"location":"Orlando, FL","url":"http://www.meetup.com/Ember-js-Orlando/","image":"01orlando.png","lat":28.5383355,"lon":-81.3792365},{"location":"Indianapolis, IN","url":"http://www.meetup.com/Ember-js-Indianapolis/","lat":39.768403,"lon":-86.158068},{"location":"Toronto, Canada","url":"http://www.meetup.com/Toronto-Ember-JS-Meetup/","image":"15toronto.png","lat":43.653226,"lon":-79.3831843},{"location":"Ottawa, Canada","url":"http://www.meetup.com/Ember-js-Ottawa/","image":"13ottawa.png","lat":45.4215296,"lon":-75.69719309999999},{"location":"Vancouver, Canada","url":"http://www.meetup.com/Vancouver-Ember-js/","lat":49.2827291,"lon":-123.1207375},{"location":"San Juan, Puerto Rico","url":"http://www.meetup.com/Ember-PR/","image":"21puertorico.png","lat":18.4663338,"lon":-66.1057217},{"location":"Calgary, Canada","url":"http://www.meetup.com/EmberJS-YYC/","image":"23calgary.png","lat":51.0486151,"lon":-114.0708459},{"location":"São Paulo, Brazil","url":"http://www.meetup.com/Ember-js-Sao-Paulo/","lat":-23.5505199,"lon":-46.63330939999999},{"location":"Belo Horizonte, Brazil","url":"http://www.meetup.com/Ember-BH/","lat":-19.9166813,"lon":-43.9344931},{"location":"Montevideo, Uruguay","url":"http://www.meetup.com/ember-montevideo/","lat":-34.9011127,"lon":-56.16453139999999},{"location":"Paris, France","url":"http://www.meetup.com/EmberJS-Paris/","image":"14paris.png","lat":48.856614,"lon":2.3522219},{"location":"London, UK","url":"http://emberlondon.com","image":"11london.png","lat":51.5073509,"lon":-0.1277583},{"location":"Dublin, Ireland","url":"http://www.meetup.com/emberjsdublin/","image":"10dublin.png","lat":53.3498053,"lon":-6.2603097},{"location":"Berlin, Germany","url":"http://www.meetup.com/Ember-js-Berlin/","image":"09berlin.png","lat":52.52000659999999,"lon":13.404954},{"location":"Munich, Germany","url":"http://www.meetup.com/Ember-js-Munich/","image":"12munich.png","lat":48.1351253,"lon":11.5819806},{"location":"Göteborg, Sweden","url":"http://www.meetup.com/ember-js-goteborg/","image":"17goteborg.png","lat":57.70887,"lon":11.97456},{"location":"Budapest, Hungary","url":"http://www.meetup.com/ember-bp/","lat":47.497912,"lon":19.040235},{"location":"Oslo, Norway","url":"http://www.meetup.com/Ember-js-Oslo/","lat":59.9138688,"lon":10.7522454},{"location":"Brussels, Belgium","url":"http://www.meetup.com/Ember-js-Brussels/","lat":50.8503396,"lon":4.3517103},{"location":"Barcelona, Spain","url":"http://www.meetup.com/Ember-js-Barcelona/","image":"22barcelona.png","lat":41.3850639,"lon":2.1734035},{"location":"Kyiv, Ukraine","url":"http://ember-club.kiev.ua","lat":50.4501,"lon":30.5234},{"location":"Zürich, Switzerland","url":"http://www.meetup.com/Ember-js-Zurich/","lat":47.3686498,"lon":8.539182499999999},{"location":"Amsterdam, the Netherlands","url":"http://www.meetup.com/Amsterdam-Ember-js/","lat":52.3702157,"lon":4.895167900000001},{"location":"Tel Aviv, Israel","url":"http://www.meetup.com/Ember-IL/","image":"20telaviv.png","lat":32.0852999,"lon":34.78176759999999},{"location":"Bangalore, India","url":"http://www.meetup.com/EmberJS-Bangalore/","lat":12.9715987,"lon":77.5945627},{"location":"Tokyo, Japan","url":"http://emberjs.doorkeeper.jp/","lat":35.7090259,"lon":139.7319925},{"location":"Adelaide, Australia","url":"http://www.meetup.com/Ember-js-Adelaide","lat":-34.92862119999999,"lon":138.5999594},{"location":"Melbourne, Australia","url":"http://www.meetup.com/Ember-Melb-JS/","image":"18melbourne.png","lat":-37.814107,"lon":144.96328},{"location":"Wellington, New Zealand","url":"http://www.meetup.com/ember-js-wellington/","lat":-41.2864603,"lon":174.776236}] \ No newline at end of file diff --git a/source/javascripts/meetups.js b/source/javascripts/meetups.js new file mode 100644 index 0000000000..178f287404 --- /dev/null +++ b/source/javascripts/meetups.js @@ -0,0 +1,36 @@ +(function() { + var handler = Gmaps.build('Google'), + mapOptions = $('meta[name=mapOptions]').attr('content'); + + var infowindow_template = _.template("

<%=location%>

" + + "
"); + + mapOptions = JSON.parse(mapOptions); + mapOptions.provider.zoomControlOptions = google.maps.ZoomControlStyle.SMALL; + + $.getJSON("/data/meetup_locations.json", function( meetups ) { + handler.buildMap(mapOptions, function(){ + var marker_data = _.map(meetups, function(meetup){ + return { + "lat": meetup["lat"], + "lng": meetup["lon"], + "infowindow": infowindow_template(meetup) + }; + }); + var markers = handler.addMarkers(marker_data); + handler.bounds.extendWith(markers); + + if(navigator.geolocation){ + navigator.geolocation.getCurrentPosition(function(position){ + var pos = new google.maps.LatLng(position.coords.latitude, + position.coords.longitude); + handler.map.centerOn(pos); + handler.map.serviceObject.setZoom(8); + }, handler.fitMapToBounds.bind(handler)); + } + else { + handler.fitMapToBounds(); + } + }); + }); +})(); diff --git a/source/javascripts/meetups.js.erb b/source/javascripts/meetups.js.erb deleted file mode 100644 index c7daab365c..0000000000 --- a/source/javascripts/meetups.js.erb +++ /dev/null @@ -1,24 +0,0 @@ -(function() { - var handler = Gmaps.build('Google'), - mapOptions = $('meta[name=mapOptions]').attr('content'); - - mapOptions = JSON.parse(mapOptions); - mapOptions.provider.zoomControlOptions = google.maps.ZoomControlStyle.SMALL; - - handler.buildMap(mapOptions, function(){ - var markers = handler.addMarkers(<%= markers_hash.to_json %>); - handler.bounds.extendWith(markers); - - if(navigator.geolocation){ - navigator.geolocation.getCurrentPosition(function(position){ - var pos = new google.maps.LatLng(position.coords.latitude, - position.coords.longitude); - handler.map.centerOn(pos); - handler.map.serviceObject.setZoom(8); - }, handler.fitMapToBounds.bind(handler)); - } - else { - handler.fitMapToBounds(); - } - }); -})();