gmaps4rails 1.5.8 → 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/.gitignore +12 -0
  2. data/.travis.yml +9 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +149 -0
  5. data/Guardfile.old +24 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +129 -0
  8. data/Rakefile +4 -0
  9. data/app/views/gmaps4rails/_gmaps4rails.html.erb +20 -0
  10. data/gmaps4rails.gemspec +38 -0
  11. data/lib/generators/gmaps4rails/install_generator.rb +43 -0
  12. data/lib/generators/templates/README +2 -0
  13. data/lib/gmaps4rails.rb +26 -0
  14. data/lib/gmaps4rails/acts_as_gmappable.rb +54 -0
  15. data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +40 -0
  16. data/lib/gmaps4rails/api_wrappers/direction.rb +87 -0
  17. data/lib/gmaps4rails/api_wrappers/geocoder.rb +54 -0
  18. data/lib/gmaps4rails/api_wrappers/places.rb +74 -0
  19. data/lib/gmaps4rails/base.rb +126 -0
  20. data/lib/gmaps4rails/extensions/enumerable.rb +14 -0
  21. data/lib/gmaps4rails/extensions/hash.rb +9 -0
  22. data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +33 -0
  23. data/lib/gmaps4rails/js_builder.rb +154 -0
  24. data/lib/gmaps4rails/json_builder.rb +140 -0
  25. data/lib/gmaps4rails/model_handler.rb +101 -0
  26. data/lib/gmaps4rails/version.rb +3 -0
  27. data/lib/gmaps4rails/view_helper.rb +172 -0
  28. data/lib/tasks/jasmine.rake +8 -0
  29. data/public/javascripts/gmaps4rails/all.js +2144 -0
  30. data/public/javascripts/gmaps4rails/base.js +792 -0
  31. data/public/javascripts/gmaps4rails/google.js +556 -0
  32. data/public/javascripts/gmaps4rails/openlayers.js +377 -0
  33. data/public/stylesheets/gmaps4rails.css +24 -0
  34. data/spec/dummy/.gitignore +3 -0
  35. data/spec/dummy/.rspec +1 -0
  36. data/spec/dummy/README.rdoc +261 -0
  37. data/spec/dummy/Rakefile +7 -0
  38. data/spec/dummy/app/assets/javascripts/application.js +18 -0
  39. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  40. data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +24 -0
  41. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  42. data/spec/dummy/app/controllers/users_controller.rb +105 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/mailers/.gitkeep +0 -0
  45. data/spec/dummy/app/models/.gitkeep +0 -0
  46. data/spec/dummy/app/models/place.rb +16 -0
  47. data/spec/dummy/app/models/user.rb +12 -0
  48. data/spec/dummy/app/views/layouts/application.html.erb +17 -0
  49. data/spec/dummy/app/views/users/_form.html.erb +37 -0
  50. data/spec/dummy/app/views/users/edit.html.erb +6 -0
  51. data/spec/dummy/app/views/users/index.html.erb +268 -0
  52. data/spec/dummy/app/views/users/new.html.erb +5 -0
  53. data/spec/dummy/app/views/users/show.html.erb +30 -0
  54. data/spec/dummy/config.ru +4 -0
  55. data/spec/dummy/config/application.rb +62 -0
  56. data/spec/dummy/config/boot.rb +10 -0
  57. data/spec/dummy/config/database.yml +25 -0
  58. data/spec/dummy/config/environment.rb +5 -0
  59. data/spec/dummy/config/environments/development.rb +37 -0
  60. data/spec/dummy/config/environments/production.rb +67 -0
  61. data/spec/dummy/config/environments/test.rb +37 -0
  62. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/dummy/config/initializers/gmaps4rails.rb +1 -0
  64. data/spec/dummy/config/initializers/inflections.rb +15 -0
  65. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  66. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  67. data/spec/dummy/config/initializers/session_store.rb +8 -0
  68. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  69. data/spec/dummy/config/locales/en.yml +5 -0
  70. data/spec/dummy/config/routes.rb +60 -0
  71. data/spec/dummy/db/migrate/20120408170155_create_users.rb +16 -0
  72. data/spec/dummy/db/schema.rb +29 -0
  73. data/spec/dummy/lib/assets/.gitkeep +0 -0
  74. data/spec/dummy/log/.gitkeep +0 -0
  75. data/spec/dummy/public/404.html +26 -0
  76. data/spec/dummy/public/422.html +26 -0
  77. data/spec/dummy/public/500.html +25 -0
  78. data/spec/dummy/public/favicon.ico +0 -0
  79. data/spec/dummy/public/javascripts/Player.js +22 -0
  80. data/spec/dummy/public/javascripts/Song.js +7 -0
  81. data/spec/dummy/public/logo.png +0 -0
  82. data/spec/dummy/script/rails +6 -0
  83. data/spec/factories/place_factory.rb +16 -0
  84. data/spec/factories/user_factory.rb +23 -0
  85. data/spec/fixtures/google_direction_valid.json +65 -0
  86. data/spec/fixtures/google_geocoding_toulon_france.json +58 -0
  87. data/spec/fixtures/google_places_valid.json +45 -0
  88. data/spec/fixtures/google_wrong_geocoding.json +4 -0
  89. data/spec/launchers/all_but_requests.rb +0 -0
  90. data/spec/launchers/all_specs.rb +0 -0
  91. data/spec/launchers/requests.rb +0 -0
  92. data/spec/lib/base_spec.rb +59 -0
  93. data/spec/lib/direction_spec.rb +53 -0
  94. data/spec/lib/geocoder_spec.rb +46 -0
  95. data/spec/lib/js_builder_spec.rb +134 -0
  96. data/spec/lib/json_builder_spec.rb +232 -0
  97. data/spec/lib/places_spec.rb +25 -0
  98. data/spec/models/place_spec.rb +39 -0
  99. data/spec/models/user_spec.rb +187 -0
  100. data/spec/spec_helper.rb +38 -0
  101. data/spec/support/geocoding.rb +40 -0
  102. data/spec/support/matchers.rb +73 -0
  103. data/todo +0 -0
  104. data/vendor/assets/javascripts/gmaps4rails/all.js +1 -0
  105. data/vendor/assets/javascripts/gmaps4rails/base.coffee +1 -0
  106. data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +43 -0
  107. data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +7 -0
  108. data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +13 -0
  109. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +15 -0
  110. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +15 -0
  111. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +27 -0
  112. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +15 -0
  113. data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +124 -0
  114. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +29 -0
  115. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +5 -0
  116. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +76 -0
  117. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +29 -0
  118. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +29 -0
  119. data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +12 -0
  120. data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +8 -0
  121. data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +62 -0
  122. data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +24 -0
  123. data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +11 -0
  124. data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +11 -0
  125. data/vendor/assets/javascripts/gmaps4rails/bing.coffee +1 -0
  126. data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +29 -0
  127. data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +63 -0
  128. data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +78 -0
  129. data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +20 -0
  130. data/vendor/assets/javascripts/gmaps4rails/google.coffee +1 -0
  131. data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +47 -0
  132. data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +38 -0
  133. data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +16 -0
  134. data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +71 -0
  135. data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +114 -0
  136. data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +38 -0
  137. data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +49 -0
  138. data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +27 -0
  139. data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +1 -0
  140. data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +138 -0
  141. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +49 -0
  142. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +68 -0
  143. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +39 -0
  144. data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +19 -0
  145. metadata +378 -14
  146. checksums.yaml +0 -7
@@ -0,0 +1,3 @@
1
+ module Gmaps4rails
2
+ VERSION = "2.0.0.pre"
3
+ end
@@ -0,0 +1,172 @@
1
+ module Gmaps4rails
2
+
3
+ class ViewHelper
4
+
5
+ OPENLAYERS = "http://www.openlayers.org/api/OpenLayers.js"
6
+ MAPQUEST = "http://www.mapquestapi.com/sdk/js/v7.0.s/mqa.toolkit.js"
7
+ BING = "http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"
8
+ GOOGLE = "//maps.google.com/maps/api/js?v=3.9"
9
+ GOOGLE_EXT = "//google-maps-utility-library-v3.googlecode.com/svn/"
10
+
11
+ # options is the hash passed to the 'gmaps' helper
12
+ # looks like:
13
+ #{
14
+ # :map_options => hash,
15
+ # :markers => { :data => json, :options => hash },
16
+ # :polylines => { :data => json, :options => hash },
17
+ # :polygons => { :data => json, :options => hash },
18
+ # :circles => { :data => json, :options => hash },
19
+ # :direction => { :data => hash, :options => hash },
20
+ # :kml => { :data => json, :options => hash }
21
+ #}
22
+ # should be with only symbol keys or with indifferent access
23
+ def initialize(options = {})
24
+ @options = options
25
+ @js_array = Array.new
26
+ end
27
+
28
+ # outputs an array containing the path to all required js files
29
+ # this list is deduced from the options passed
30
+ def js_dependencies_array
31
+ if scripts != :none
32
+ get_vendor_scripts
33
+ get_gem_scripts
34
+ end
35
+ @js_array
36
+ end
37
+
38
+ # outputs an object containing the basic information to fill the map's dom attributes
39
+ def dom_attributes
40
+ ::OpenStruct.new({
41
+ :map_id => map_id,
42
+ :map_class => map_class,
43
+ :container_class => container_class,
44
+ :provider => map_provider
45
+ })
46
+ end
47
+
48
+ # gem's script aren't taken into account when asset pipeline is enabled:
49
+ # I assume they'll be within
50
+ def get_gem_scripts
51
+ unless gmaps4rails_pipeline_enabled?
52
+ @js_array << '/javascripts/gmaps4rails/gmaps4rails.base.js' unless scripts == :api
53
+ @js_array << case map_provider
54
+ when "openlayers" then '/javascripts/gmaps4rails/gmaps4rails.openlayers.js'
55
+ when "mapquest" then '/javascripts/gmaps4rails/gmaps4rails.mapquest.js'
56
+ when "bing" then '/javascripts/gmaps4rails/gmaps4rails.bing.js'
57
+ else '/javascripts/gmaps4rails/gmaps4rails.googlemaps.js'
58
+ end
59
+ end
60
+ end
61
+
62
+ # vendor_scripts are the js libraries from the map providers
63
+ def get_vendor_scripts
64
+ case map_provider
65
+ when "openlayers" then @js_array << OPENLAYERS
66
+ when "mapquest" then @js_array << "#{MAPQUEST}?key=#{provider_key}"
67
+ when "bing" then @js_array << BING
68
+ else #case googlemaps which is the default
69
+ @js_array << "#{GOOGLE}&sensor=false&client=#{client}&key=#{provider_key}&libraries=geometry#{google_libraries}&#{google_map_i18n}"
70
+ @js_array << "#{GOOGLE_EXT}tags/infobox/1.1.9/src/infobox_packed.js" if custom_infowindow_class
71
+ @js_array << "#{GOOGLE_EXT}tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js" if do_clustering
72
+ @js_array << "#{GOOGLE_EXT}trunk/richmarker/src/richmarker-compiled.js" if rich_marker
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ def gmaps4rails_pipeline_enabled?
79
+ Gmaps4rails.pipeline_enabled?
80
+ end
81
+
82
+ def map_options
83
+ @map_options ||= @options[:map_options]
84
+ end
85
+
86
+ def marker_options
87
+ @marker_options ||= @options[:markers].try(:[],:options)
88
+ end
89
+
90
+ #
91
+ def map_provider
92
+ @map_provider ||= map_options.try(:[], :provider)
93
+ end
94
+
95
+ # the scripts option can have the following values
96
+ # - :api => only the js related to the map api is inserted
97
+ # - :none => no javascript inserted
98
+ # - anything else => base javascript + map api javascript inserted
99
+ def scripts
100
+ @scripts ||= @options[:scripts].try(:to_sym)
101
+ end
102
+
103
+ # could be one of the following:
104
+ # - "openlayers"
105
+ # - "mapquest"
106
+ # - "bing"
107
+ # - anything else which would default to googlemaps
108
+ def provider_key
109
+ map_options.try(:[], :provider_key)
110
+ end
111
+
112
+ # when custom_infowindow_class is added in the marker_options,
113
+ #it means user wants to use the InfoBox googlemap's plugin
114
+ def custom_infowindow_class
115
+ marker_options.try(:[], :custom_infowindow_class)
116
+ end
117
+
118
+ # do_clustering tells whether or not the js marker clustering library should be loaded
119
+ def do_clustering
120
+ marker_options.try(:[], :do_clustering)
121
+ end
122
+
123
+ # libraries should be an array of string containing the additional js library the user
124
+ # wants from google.
125
+ # Ex: [ "places" ]
126
+ def google_libraries
127
+ libraries_array = map_options.try(:[], :libraries)
128
+ return "" if libraries_array.nil?
129
+ "," + libraries_array.join(",")
130
+ end
131
+
132
+ # google maps could be "i18n"ed
133
+ def google_map_i18n
134
+ "language=#{language}&hl=#{hl}&region=#{region}"
135
+ end
136
+
137
+ def language
138
+ map_options.try(:[], :language)
139
+ end
140
+
141
+ def hl
142
+ map_options.try(:[], :hl)
143
+ end
144
+
145
+ def region
146
+ map_options.try(:[], :region)
147
+ end
148
+
149
+ def rich_marker
150
+ marker_options.try(:[], :rich_marker)
151
+ end
152
+
153
+ def client
154
+ map_options.try(:[], :client)
155
+ end
156
+
157
+ def map_id
158
+ map_options.try(:[], :id) || Gmaps4rails::JsBuilder::DEFAULT_MAP_ID
159
+ end
160
+
161
+ def map_class
162
+ default_class = map_options.try(:[], :provider) == "bing" ? "bing_map" : "gmaps4rails_map"
163
+ map_options.try(:[], :class) || default_class
164
+ end
165
+
166
+ def container_class
167
+ map_options.try(:[], :container_class) || "map_container"
168
+ end
169
+
170
+ end
171
+
172
+ end
@@ -0,0 +1,8 @@
1
+ # begin
2
+ # require 'jasmine'
3
+ # load 'jasmine/tasks/jasmine.rake'
4
+ # rescue LoadError
5
+ # task :jasmine do
6
+ # abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
7
+ # end
8
+ # end
@@ -0,0 +1,2144 @@
1
+ (function() {
2
+ var moduleKeywords,
3
+ __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
4
+
5
+ moduleKeywords = ['extended', 'included'];
6
+
7
+ this.Gmaps4Rails = {};
8
+
9
+ this.Gmaps4Rails.Common = (function() {
10
+
11
+ function Common() {}
12
+
13
+ Common.extend = function(obj) {
14
+ var key, value, _ref;
15
+ for (key in obj) {
16
+ value = obj[key];
17
+ if (__indexOf.call(moduleKeywords, key) < 0) this[key] = value;
18
+ }
19
+ if ((_ref = obj.extended) != null) _ref.apply(this);
20
+ return this;
21
+ };
22
+
23
+ Common.include = function(obj) {
24
+ var key, value, _ref;
25
+ for (key in obj) {
26
+ value = obj[key];
27
+ if (__indexOf.call(moduleKeywords, key) < 0) this.prototype[key] = value;
28
+ }
29
+ if ((_ref = obj.included) != null) _ref.apply(this);
30
+ return this;
31
+ };
32
+
33
+ Common.prototype.exists = function(var_name) {
34
+ return var_name !== "" && typeof var_name !== "undefined";
35
+ };
36
+
37
+ Common.prototype.mergeObjects = function(object, defaultObject) {
38
+ return this.constructor.mergeObjects(object, defaultObject);
39
+ };
40
+
41
+ Common.mergeObjects = function(object, defaultObject) {
42
+ var copy_object, key, value;
43
+ copy_object = {};
44
+ for (key in object) {
45
+ value = object[key];
46
+ copy_object[key] = value;
47
+ }
48
+ for (key in defaultObject) {
49
+ value = defaultObject[key];
50
+ if (copy_object[key] == null) copy_object[key] = value;
51
+ }
52
+ return copy_object;
53
+ };
54
+
55
+ Common.mergeWith = function(object) {
56
+ var key, value, _results;
57
+ _results = [];
58
+ for (key in object) {
59
+ value = object[key];
60
+ if (this[key] == null) {
61
+ _results.push(this[key] = value);
62
+ } else {
63
+ _results.push(void 0);
64
+ }
65
+ }
66
+ return _results;
67
+ };
68
+
69
+ Common.prototype.random = function() {
70
+ return Math.random() * 2 - 1;
71
+ };
72
+
73
+ return Common;
74
+
75
+ })();
76
+
77
+ }).call(this);
78
+ (function() {
79
+
80
+ this.Gmaps4Rails.Configuration = {
81
+ setConf: function() {
82
+ if (this.CONF) {
83
+ return this.mergeObjects(this.CONF, this.DEFAULT_CONF);
84
+ } else {
85
+ return this.DEFAULT_CONF;
86
+ }
87
+ }
88
+ };
89
+
90
+ }).call(this);
91
+ (function() {
92
+
93
+ this.Gmaps = {
94
+ triggerOldOnload: function() {
95
+ if (typeof window.Gmaps.oldOnload === 'function') {
96
+ return window.Gmaps.oldOnload();
97
+ }
98
+ },
99
+ loadMaps: function() {
100
+ var key, value, _ref, _results;
101
+ _ref = window.Gmaps;
102
+ _results = [];
103
+ for (key in _ref) {
104
+ value = _ref[key];
105
+ if (/^load_/.test(key)) {
106
+ _results.push(window.Gmaps[key]());
107
+ } else {
108
+ _results.push(void 0);
109
+ }
110
+ }
111
+ return _results;
112
+ }
113
+ };
114
+
115
+ }).call(this);
116
+ (function() {
117
+
118
+ this.Gmaps4Rails.Circle = {};
119
+
120
+ this.Gmaps4Rails.Circle.Class = {
121
+ DEFAULT_CONF: {
122
+ fillColor: "#00AAFF",
123
+ fillOpacity: 0.35,
124
+ strokeColor: "#FFAA00",
125
+ strokeOpacity: 0.8,
126
+ strokeWeight: 2,
127
+ clickable: false,
128
+ zIndex: null
129
+ }
130
+ };
131
+
132
+ }).call(this);
133
+ (function() {
134
+
135
+ this.Gmaps4Rails.Kml = {};
136
+
137
+ this.Gmaps4Rails.Kml.Instance = {
138
+ DEFAULT_CONF: {
139
+ clickable: true,
140
+ preserveViewport: false,
141
+ suppressInfoWindows: false
142
+ }
143
+ };
144
+
145
+ }).call(this);
146
+ (function() {
147
+
148
+ this.Gmaps4Rails.Map = {
149
+ DEFAULT_CONF: {
150
+ id: 'map',
151
+ draggable: true,
152
+ detect_location: false,
153
+ center_on_user: false,
154
+ center_latitude: 0,
155
+ center_longitude: 0,
156
+ zoom: 7,
157
+ maxZoom: null,
158
+ minZoom: null,
159
+ auto_adjust: true,
160
+ auto_zoom: true,
161
+ bounds: [],
162
+ raw: {}
163
+ },
164
+ adjustToBounds: function() {
165
+ this.boundsObject = this.createLatLngBounds();
166
+ this.extendBoundsWithMarkers();
167
+ this.extendBoundsWithPolylines();
168
+ this.extendBoundsWithPolygons();
169
+ this.extendBoundsWithCircles();
170
+ this.extendBoundsWithLatLng();
171
+ return this.adaptToBounds();
172
+ },
173
+ extendBoundsWithMarkers: function() {
174
+ var marker, _i, _len, _ref, _results;
175
+ _ref = this.controller.markers;
176
+ _results = [];
177
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
178
+ marker = _ref[_i];
179
+ if (marker.isVisible()) {
180
+ _results.push(this.extendBoundsWithMarker(marker));
181
+ } else {
182
+ _results.push(void 0);
183
+ }
184
+ }
185
+ return _results;
186
+ },
187
+ extendBoundsWithPolylines: function() {
188
+ var polyline, _i, _len, _ref, _results;
189
+ _ref = this.controller.polylines;
190
+ _results = [];
191
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
192
+ polyline = _ref[_i];
193
+ _results.push(this.extendBoundsWithPolyline(polyline));
194
+ }
195
+ return _results;
196
+ },
197
+ extendBoundsWithPolygons: function() {
198
+ var polygon, _i, _len, _ref, _results;
199
+ _ref = this.controller.polygons;
200
+ _results = [];
201
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
202
+ polygon = _ref[_i];
203
+ _results.push(this.extendBoundsWithPolygon(polygon));
204
+ }
205
+ return _results;
206
+ },
207
+ extendBoundsWithCircles: function() {
208
+ var circle, _i, _len, _ref, _results;
209
+ _ref = this.controller.circles;
210
+ _results = [];
211
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
212
+ circle = _ref[_i];
213
+ _results.push(this.extendBoundsWithCircle(circle));
214
+ }
215
+ return _results;
216
+ },
217
+ extendBoundsWithLatLng: function() {
218
+ var bound, _i, _len, _ref, _results;
219
+ _ref = this.options.bounds;
220
+ _results = [];
221
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
222
+ bound = _ref[_i];
223
+ _results.push(this.extendBound(bound));
224
+ }
225
+ return _results;
226
+ },
227
+ autoAdjustRequested: function() {
228
+ return this.options.auto_adjust || this.options.bounds.length > 0;
229
+ }
230
+ };
231
+
232
+ }).call(this);
233
+ (function() {
234
+
235
+ this.Gmaps4Rails.Marker = {};
236
+
237
+ this.Gmaps4Rails.Marker.Class = {
238
+ DEFAULT_CONF: {
239
+ title: null,
240
+ picture: null,
241
+ width: 22,
242
+ length: 32,
243
+ draggable: false,
244
+ do_clustering: false,
245
+ randomize: false,
246
+ max_random_distance: 100,
247
+ list_container: null,
248
+ offset: 0,
249
+ raw: {}
250
+ }
251
+ };
252
+
253
+ this.Gmaps4Rails.Marker.Instance = {
254
+ getMap: function() {
255
+ return this.controller.getMapObject();
256
+ }
257
+ };
258
+
259
+ }).call(this);
260
+ (function() {
261
+
262
+ this.Gmaps4Rails.Polygon = {};
263
+
264
+ this.Gmaps4Rails.Polygon.Class = {
265
+ DEFAULT_CONF: {
266
+ strokeColor: "#FFAA00",
267
+ strokeOpacity: 0.8,
268
+ strokeWeight: 2,
269
+ fillColor: "#000000",
270
+ fillOpacity: 0.35,
271
+ clickable: false
272
+ }
273
+ };
274
+
275
+ }).call(this);
276
+ (function() {
277
+
278
+ this.Gmaps4Rails.Polyline = {};
279
+
280
+ this.Gmaps4Rails.Polyline.Class = {
281
+ DEFAULT_CONF: {
282
+ strokeColor: "#FF0000",
283
+ strokeOpacity: 1,
284
+ strokeWeight: 2,
285
+ clickable: false,
286
+ zIndex: null
287
+ }
288
+ };
289
+
290
+ }).call(this);
291
+ (function() {
292
+
293
+ this.Gmaps4Rails.CircleController = {
294
+ addCircles: function(circleData) {
295
+ var circleArgs, _i, _len, _results;
296
+ _results = [];
297
+ for (_i = 0, _len = circleData.length; _i < _len; _i++) {
298
+ circleArgs = circleData[_i];
299
+ _results.push(this.circles.push(this.createCircle(circleArgs)));
300
+ }
301
+ return _results;
302
+ },
303
+ replaceCircles: function(circleData) {
304
+ this.clearCircles();
305
+ this.addCircles(circleData);
306
+ return this.adjustMapToBounds();
307
+ },
308
+ clearCircles: function() {
309
+ var circle, _i, _len, _ref;
310
+ _ref = this.circles;
311
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
312
+ circle = _ref[_i];
313
+ circle.clear();
314
+ }
315
+ return this.circles = [];
316
+ },
317
+ showCircles: function() {
318
+ var circle, _i, _len, _ref, _results;
319
+ _ref = this.circles;
320
+ _results = [];
321
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
322
+ circle = _ref[_i];
323
+ _results.push(circle.show());
324
+ }
325
+ return _results;
326
+ },
327
+ hideCircles: function() {
328
+ var circle, _i, _len, _ref, _results;
329
+ _ref = this.circles;
330
+ _results = [];
331
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
332
+ circle = _ref[_i];
333
+ _results.push(circle.hide());
334
+ }
335
+ return _results;
336
+ }
337
+ };
338
+
339
+ }).call(this);
340
+ (function() {
341
+
342
+ this.Gmaps4Rails.KmlController = {
343
+ addKml: function(kmlData) {
344
+ var kml, _i, _len, _results;
345
+ _results = [];
346
+ for (_i = 0, _len = kmlData.length; _i < _len; _i++) {
347
+ kml = kmlData[_i];
348
+ _results.push(this.kmls.push(this.createKml(kml)));
349
+ }
350
+ return _results;
351
+ }
352
+ };
353
+
354
+ }).call(this);
355
+ (function() {
356
+
357
+ this.Gmaps4Rails.MarkerController = {
358
+ addMarkers: function(markersData) {
359
+ var index, lat, latLng, lng, markerData, newMarker, _len;
360
+ if (this.markerClusterer != null) this.clearClusterer();
361
+ for (index = 0, _len = markersData.length; index < _len; index++) {
362
+ markerData = markersData[index];
363
+ lat = markerData.lat;
364
+ lng = markerData.lng;
365
+ if (this.markers_conf.randomize) {
366
+ latLng = this.randomize(lat, lng);
367
+ lat = latLng[0];
368
+ lng = latLng[1];
369
+ }
370
+ newMarker = this.createMarker({
371
+ "marker_picture": markerData.picture ? markerData.picture : this.markers_conf.picture,
372
+ "marker_width": markerData.width ? markerData.width : this.markers_conf.width,
373
+ "marker_height": markerData.height ? markerData.height : this.markers_conf.length,
374
+ "marker_title": markerData.title ? markerData.title : null,
375
+ "marker_anchor": markerData.marker_anchor ? markerData.marker_anchor : null,
376
+ "shadow_anchor": markerData.shadow_anchor ? markerData.shadow_anchor : null,
377
+ "shadow_picture": markerData.shadow_picture ? markerData.shadow_picture : null,
378
+ "shadow_width": markerData.shadow_width ? markerData.shadow_width : null,
379
+ "shadow_height": markerData.shadow_height ? markerData.shadow_height : null,
380
+ "marker_draggable": markerData.draggable ? markerData.draggable : this.markers_conf.draggable,
381
+ "rich_marker": markerData.rich_marker ? markerData.rich_marker : null,
382
+ "zindex": markerData.zindex ? markerData.zindex : null,
383
+ "lat": lat,
384
+ "lng": lng,
385
+ "index": index
386
+ });
387
+ Gmaps4Rails.Common.mergeWith.call(newMarker, markerData);
388
+ newMarker.createInfoWindow();
389
+ this.markers.push(newMarker);
390
+ }
391
+ return this.clusterize();
392
+ },
393
+ replaceMarkers: function(new_markers) {
394
+ this.clearMarkers();
395
+ this.markers = [];
396
+ this.boundsObject = this.createLatLngBounds();
397
+ return this.addMarkers(new_markers);
398
+ },
399
+ clearMarkers: function() {
400
+ var marker, _i, _len, _ref;
401
+ if (this.markerClusterer != null) this.clearClusterer();
402
+ _ref = this.markers;
403
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
404
+ marker = _ref[_i];
405
+ marker.clear();
406
+ }
407
+ return this.markers = [];
408
+ },
409
+ showMarkers: function() {
410
+ var marker, _i, _len, _ref, _results;
411
+ _ref = this.markers;
412
+ _results = [];
413
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
414
+ marker = _ref[_i];
415
+ _results.push(marker.show());
416
+ }
417
+ return _results;
418
+ },
419
+ hideMarkers: function() {
420
+ var marker, _i, _len, _ref, _results;
421
+ _ref = this.markers;
422
+ _results = [];
423
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
424
+ marker = _ref[_i];
425
+ _results.push(marker.hide());
426
+ }
427
+ return _results;
428
+ },
429
+ randomize: function(Lat0, Lng0) {
430
+ var Lat, Lng, dx, dy;
431
+ dx = this.markers_conf.max_random_distance * this.random();
432
+ dy = this.markers_conf.max_random_distance * this.random();
433
+ Lat = parseFloat(Lat0) + (180 / Math.PI) * (dy / 6378137);
434
+ Lng = parseFloat(Lng0) + (90 / Math.PI) * (dx / 6378137) / Math.cos(Lat0);
435
+ return [Lat, Lng];
436
+ }
437
+ };
438
+
439
+ }).call(this);
440
+ (function() {
441
+
442
+ this.Gmaps4Rails.PolygonController = {
443
+ addPolygons: function(polygonData) {
444
+ var polygonArgs, _i, _len, _results;
445
+ _results = [];
446
+ for (_i = 0, _len = polygonData.length; _i < _len; _i++) {
447
+ polygonArgs = polygonData[_i];
448
+ _results.push(this.polygons.push(this.createPolygon(polygonArgs)));
449
+ }
450
+ return _results;
451
+ },
452
+ replacePolygons: function(polylineData) {
453
+ this.clearPolygons();
454
+ this.addPolygons(polylineData);
455
+ return this.adjustMapToBounds();
456
+ },
457
+ clearPolygons: function() {
458
+ var polygon, _i, _len, _ref;
459
+ _ref = this.polygons;
460
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
461
+ polygon = _ref[_i];
462
+ polygon.clear();
463
+ }
464
+ return this.polygons = [];
465
+ },
466
+ showPolygons: function() {
467
+ var polygon, _i, _len, _ref, _results;
468
+ _ref = this.polygons;
469
+ _results = [];
470
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
471
+ polygon = _ref[_i];
472
+ _results.push(polygon.show());
473
+ }
474
+ return _results;
475
+ },
476
+ hidePolygons: function() {
477
+ var polygon, _i, _len, _ref, _results;
478
+ _ref = this.polygons;
479
+ _results = [];
480
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
481
+ polygon = _ref[_i];
482
+ _results.push(polygon.hide());
483
+ }
484
+ return _results;
485
+ }
486
+ };
487
+
488
+ }).call(this);
489
+ (function() {
490
+
491
+ this.Gmaps4Rails.PolylineController = {
492
+ replacePolylines: function(polylineData) {
493
+ this.clearPolylines();
494
+ this.addPolylines(polylineData);
495
+ return this.adjustMapToBounds();
496
+ },
497
+ clearPolylines: function() {
498
+ var polyline, _i, _len, _ref;
499
+ _ref = this.polylines;
500
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
501
+ polyline = _ref[_i];
502
+ polyline.clear();
503
+ }
504
+ return this.polylines = [];
505
+ },
506
+ addPolylines: function(polylineData) {
507
+ var polylineArgs, _i, _len, _results;
508
+ _results = [];
509
+ for (_i = 0, _len = polylineData.length; _i < _len; _i++) {
510
+ polylineArgs = polylineData[_i];
511
+ _results.push(this.polylines.push(this.createPolyline(polylineArgs)));
512
+ }
513
+ return _results;
514
+ },
515
+ showPolylines: function() {
516
+ var polyline, _i, _len, _ref, _results;
517
+ _ref = this.polylines;
518
+ _results = [];
519
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
520
+ polyline = _ref[_i];
521
+ _results.push(polyline.show());
522
+ }
523
+ return _results;
524
+ },
525
+ hidePolylines: function() {
526
+ var polyline, _i, _len, _ref, _results;
527
+ _ref = this.polylines;
528
+ _results = [];
529
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
530
+ polyline = _ref[_i];
531
+ _results.push(polyline.hide());
532
+ }
533
+ return _results;
534
+ }
535
+ };
536
+
537
+ }).call(this);
538
+ (function() {
539
+
540
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
541
+
542
+ Gmaps4Rails.Interfaces.Basic = {
543
+ clear: function() {
544
+ throw "clear should be implemented";
545
+ },
546
+ show: function() {
547
+ throw "show should be implemented";
548
+ },
549
+ hide: function() {
550
+ throw "hide should be implemented";
551
+ },
552
+ isVisible: function() {
553
+ throw "hide should be implemented";
554
+ }
555
+ };
556
+
557
+ }).call(this);
558
+ (function() {
559
+
560
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
561
+
562
+ Gmaps4Rails.Interfaces.Controller = {
563
+ getModule: function() {
564
+ throw "getModule should be implemented in controller";
565
+ },
566
+ createClusterer: function(markers_array) {
567
+ throw "createClusterer should be implemented in controller";
568
+ },
569
+ clearClusterer: function() {
570
+ throw "clearClusterer should be implemented in controller";
571
+ }
572
+ };
573
+
574
+ }).call(this);
575
+ (function() {
576
+
577
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
578
+
579
+ Gmaps4Rails.Interfaces.Map = {
580
+ extendBoundsWithMarker: function(marker) {
581
+ throw "extendBoundsWithMarker should be implemented in controller";
582
+ },
583
+ extendBoundsWithPolyline: function(polyline) {
584
+ throw "extendBoundsWithPolyline should be implemented in controller";
585
+ },
586
+ extendBoundsWithPolygon: function(polygon) {
587
+ throw "extendBoundsWithPolygon should be implemented in controller";
588
+ },
589
+ extendBoundsWithCircle: function(circle) {
590
+ throw "extendBoundsWithCircle should be implemented in controller";
591
+ },
592
+ extendBound: function(bound) {
593
+ throw "extendBound should be implemented in controller";
594
+ },
595
+ adaptToBounds: function() {
596
+ throw "adaptToBounds should be implemented in controller";
597
+ },
598
+ fitBounds: function() {
599
+ throw "fitBounds should be implemented in controller";
600
+ },
601
+ centerMapOnUser: function(position) {
602
+ throw "centerMapOnUser should be implemented in controller";
603
+ }
604
+ };
605
+
606
+ }).call(this);
607
+ (function() {
608
+
609
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
610
+
611
+ Gmaps4Rails.Interfaces.Marker = {
612
+ createInfoWindow: function() {
613
+ throw "createInfoWindow should be implemented in marker";
614
+ },
615
+ clear: function() {
616
+ throw "clear should be implemented in marker";
617
+ },
618
+ show: function() {
619
+ throw "show should be implemented in marker";
620
+ },
621
+ hide: function() {
622
+ throw "hide should be implemented in marker";
623
+ }
624
+ };
625
+
626
+ }).call(this);
627
+ (function() {
628
+ var __hasProp = Object.prototype.hasOwnProperty,
629
+ __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; };
630
+
631
+ this.Gmaps4Rails.BaseController = (function(_super) {
632
+
633
+ __extends(BaseController, _super);
634
+
635
+ BaseController.include(Gmaps4Rails.MarkerController);
636
+
637
+ BaseController.include(Gmaps4Rails.PolylineController);
638
+
639
+ BaseController.include(Gmaps4Rails.PolygonController);
640
+
641
+ BaseController.include(Gmaps4Rails.CircleController);
642
+
643
+ BaseController.include(Gmaps4Rails.KmlController);
644
+
645
+ BaseController.include(Gmaps4Rails.Interfaces.Controller);
646
+
647
+ BaseController.prototype.visibleInfoWindow = null;
648
+
649
+ BaseController.prototype.userLocation = null;
650
+
651
+ BaseController.prototype.afterMapInitialization = function() {
652
+ return false;
653
+ };
654
+
655
+ BaseController.prototype.geolocationSuccess = function() {
656
+ return false;
657
+ };
658
+
659
+ BaseController.prototype.geolocationFailure = function() {
660
+ return false;
661
+ };
662
+
663
+ BaseController.prototype.callback = function() {
664
+ return false;
665
+ };
666
+
667
+ BaseController.prototype.customClusterer = function() {
668
+ return false;
669
+ };
670
+
671
+ BaseController.prototype.infobox = function() {
672
+ return false;
673
+ };
674
+
675
+ BaseController.prototype.jsTemplate = false;
676
+
677
+ BaseController.prototype.map_options = {};
678
+
679
+ BaseController.prototype.markers = [];
680
+
681
+ BaseController.prototype.boundsObject = null;
682
+
683
+ BaseController.prototype.polygons = [];
684
+
685
+ BaseController.prototype.polylines = [];
686
+
687
+ BaseController.prototype.circles = [];
688
+
689
+ BaseController.prototype.markerClusterer = null;
690
+
691
+ BaseController.prototype.markerImages = [];
692
+
693
+ BaseController.prototype.kmls = [];
694
+
695
+ BaseController.prototype.rootModule = null;
696
+
697
+ function BaseController() {
698
+ this.rootModule = this.getModule();
699
+ if (this.rootModule.Marker != null) {
700
+ this.markers_conf = this.rootModule.Marker.setConf();
701
+ }
702
+ if (this.rootModule.Polyline != null) {
703
+ this.polylines_conf = this.rootModule.Polyline.setConf();
704
+ }
705
+ if (this.rootModule.Polygon != null) {
706
+ this.polygons_conf = this.rootModule.Polygon.setConf();
707
+ }
708
+ if (this.rootModule.Circle != null) {
709
+ this.circles_conf = this.rootModule.Circle.setConf();
710
+ }
711
+ }
712
+
713
+ BaseController.prototype.createMap = function() {
714
+ return new this.rootModule.Map(this.map_options, this);
715
+ };
716
+
717
+ BaseController.prototype.createMarker = function(args) {
718
+ return new this.rootModule.Marker(args, this);
719
+ };
720
+
721
+ BaseController.prototype.createPolyline = function(args) {
722
+ return new this.rootModule.Polyline(args, this);
723
+ };
724
+
725
+ BaseController.prototype.createPolygon = function(args) {
726
+ return new this.rootModule.Polygon(args, this);
727
+ };
728
+
729
+ BaseController.prototype.createCircle = function(args) {
730
+ return new this.rootModule.Circle(args, this);
731
+ };
732
+
733
+ BaseController.prototype.createKml = function(args) {
734
+ return new this.rootModule.Kml(args, this);
735
+ };
736
+
737
+ BaseController.prototype.initialize = function() {
738
+ var center_on_user, detectUserLocation;
739
+ detectUserLocation = this.map_options.detect_location || this.map_options.center_on_user;
740
+ center_on_user = this.map_options.center_on_user;
741
+ this.map = this.createMap();
742
+ this.afterMapInitialization();
743
+ delete this.map_options;
744
+ if (detectUserLocation) return this.findUserLocation(this, center_on_user);
745
+ };
746
+
747
+ BaseController.prototype.getMapObject = function() {
748
+ return this.map.serviceObject;
749
+ };
750
+
751
+ BaseController.prototype.adjustMapToBounds = function() {
752
+ if (this.map.autoAdjustRequested()) return this.map.adjustToBounds();
753
+ };
754
+
755
+ BaseController.prototype.clusterize = function() {
756
+ var marker, markers_array, _i, _len, _ref;
757
+ if (this.markers_conf.do_clustering) {
758
+ if (this.markerClusterer != null) this.clearClusterer();
759
+ markers_array = [];
760
+ _ref = this.markers;
761
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
762
+ marker = _ref[_i];
763
+ markers_array.push(marker.serviceObject);
764
+ }
765
+ return this.markerClusterer = this.createClusterer(markers_array);
766
+ }
767
+ };
768
+
769
+ BaseController.prototype.findUserLocation = function(controller, center_on_user) {
770
+ var positionFailure, positionSuccessful;
771
+ if (navigator.geolocation) {
772
+ positionSuccessful = function(position) {
773
+ controller.userLocation = controller.createLatLng(position.coords.latitude, position.coords.longitude);
774
+ controller.geolocationSuccess();
775
+ if (center_on_user) {
776
+ return controller.map.centerMapOnUser(controller.userLocation);
777
+ }
778
+ };
779
+ positionFailure = function(error) {
780
+ return controller.geolocationFailure(true);
781
+ };
782
+ return navigator.geolocation.getCurrentPosition(positionSuccessful, positionFailure);
783
+ } else {
784
+ return controller.geolocationFailure(false);
785
+ }
786
+ };
787
+
788
+ return BaseController;
789
+
790
+ })(Gmaps4Rails.Common);
791
+
792
+ }).call(this);
793
+ (function() {
794
+
795
+
796
+
797
+ }).call(this);
798
+ (function() {
799
+ var __hasProp = Object.prototype.hasOwnProperty,
800
+ __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; };
801
+
802
+ this.Gmaps4RailsBing = (function(_super) {
803
+
804
+ __extends(Gmaps4RailsBing, _super);
805
+
806
+ function Gmaps4RailsBing() {
807
+ Gmaps4RailsBing.__super__.constructor.apply(this, arguments);
808
+ this.map_options = {
809
+ type: "road"
810
+ };
811
+ this.markers_conf = {
812
+ infobox: "description"
813
+ };
814
+ this.mergeWithDefault("map_options");
815
+ this.mergeWithDefault("markers_conf");
816
+ }
817
+
818
+ Gmaps4RailsBing.prototype.getMapType = function() {
819
+ switch (this.map_options.type) {
820
+ case "road":
821
+ return Microsoft.Maps.MapTypeId.road;
822
+ case "aerial":
823
+ return Microsoft.Maps.MapTypeId.aerial;
824
+ case "auto":
825
+ return Microsoft.Maps.MapTypeId.auto;
826
+ case "birdseye":
827
+ return Microsoft.Maps.MapTypeId.birdseye;
828
+ case "collinsBart":
829
+ return Microsoft.Maps.MapTypeId.collinsBart;
830
+ case "mercator":
831
+ return Microsoft.Maps.MapTypeId.mercator;
832
+ case "ordnanceSurvey":
833
+ return Microsoft.Maps.MapTypeId.ordnanceSurvey;
834
+ default:
835
+ return Microsoft.Maps.MapTypeId.auto;
836
+ }
837
+ };
838
+
839
+ Gmaps4RailsBing.prototype.createPoint = function(lat, lng) {
840
+ return new Microsoft.Maps.Point(lat, lng);
841
+ };
842
+
843
+ Gmaps4RailsBing.prototype.createLatLng = function(lat, lng) {
844
+ return new Microsoft.Maps.Location(lat, lng);
845
+ };
846
+
847
+ Gmaps4RailsBing.prototype.createLatLngBounds = function() {};
848
+
849
+ Gmaps4RailsBing.prototype.createMap = function() {
850
+ return new Microsoft.Maps.Map(document.getElementById(this.map_options.id), {
851
+ credentials: this.map_options.provider_key,
852
+ mapTypeId: this.getMapType(),
853
+ center: this.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude),
854
+ zoom: this.map_options.zoom
855
+ });
856
+ };
857
+
858
+ Gmaps4RailsBing.prototype.createSize = function(width, height) {
859
+ return new google.maps.Size(width, height);
860
+ };
861
+
862
+ Gmaps4RailsBing.prototype.createMarker = function(args) {
863
+ var marker, markerLatLng;
864
+ markerLatLng = this.createLatLng(args.Lat, args.Lng);
865
+ marker;
866
+ if (args.marker_picture === "") {
867
+ marker = new Microsoft.Maps.Pushpin(this.createLatLng(args.Lat, args.Lng), {
868
+ draggable: args.marker_draggable,
869
+ anchor: this.createImageAnchorPosition(args.Lat, args.Lng),
870
+ text: args.marker_title
871
+ });
872
+ } else {
873
+ marker = new Microsoft.Maps.Pushpin(this.createLatLng(args.Lat, args.Lng), {
874
+ draggable: args.marker_draggable,
875
+ anchor: this.createImageAnchorPosition(args.Lat, args.Lng),
876
+ icon: args.marker_picture,
877
+ height: args.marker_height,
878
+ text: args.marker_title,
879
+ width: args.marker_width
880
+ });
881
+ }
882
+ this.addToMap(marker);
883
+ return marker;
884
+ };
885
+
886
+ Gmaps4RailsBing.prototype.clearMarkers = function() {
887
+ var marker, _i, _len, _ref, _results;
888
+ _ref = this.markers;
889
+ _results = [];
890
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
891
+ marker = _ref[_i];
892
+ _results.push(this.clearMarker(marker));
893
+ }
894
+ return _results;
895
+ };
896
+
897
+ Gmaps4RailsBing.prototype.clearMarker = function(marker) {
898
+ return this.removeFromMap(marker.serviceObject);
899
+ };
900
+
901
+ Gmaps4RailsBing.prototype.showMarkers = function() {
902
+ var marker, _i, _len, _ref, _results;
903
+ _ref = this.markers;
904
+ _results = [];
905
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
906
+ marker = _ref[_i];
907
+ _results.push(this.showMarker(marker));
908
+ }
909
+ return _results;
910
+ };
911
+
912
+ Gmaps4RailsBing.prototype.showMarker = function(marker) {
913
+ return marker.serviceObject.setOptions({
914
+ visible: true
915
+ });
916
+ };
917
+
918
+ Gmaps4RailsBing.prototype.hideMarkers = function() {
919
+ var marker, _i, _len, _ref, _results;
920
+ _ref = this.markers;
921
+ _results = [];
922
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
923
+ marker = _ref[_i];
924
+ _results.push(this.hideMarker(marker));
925
+ }
926
+ return _results;
927
+ };
928
+
929
+ Gmaps4RailsBing.prototype.hideMarker = function(marker) {
930
+ return marker.serviceObject.setOptions({
931
+ visible: false
932
+ });
933
+ };
934
+
935
+ Gmaps4RailsBing.prototype.extendBoundsWithMarkers = function() {
936
+ var locationsArray, marker, _i, _len, _ref;
937
+ locationsArray = [];
938
+ _ref = this.markers;
939
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
940
+ marker = _ref[_i];
941
+ locationsArray.push(marker.serviceObject.getLocation());
942
+ }
943
+ return this.boundsObject = Microsoft.Maps.LocationRect.fromLocations(locationsArray);
944
+ };
945
+
946
+ Gmaps4RailsBing.prototype.createClusterer = function(markers_array) {};
947
+
948
+ Gmaps4RailsBing.prototype.clearClusterer = function() {};
949
+
950
+ Gmaps4RailsBing.prototype.clusterize = function() {};
951
+
952
+ Gmaps4RailsBing.prototype.createInfoWindow = function(marker_container) {
953
+ var currentMap;
954
+ if (marker_container.description != null) {
955
+ if (this.markers_conf.infobox === "description") {
956
+ marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), {
957
+ description: marker_container.description,
958
+ visible: false,
959
+ showCloseButton: true
960
+ });
961
+ } else {
962
+ marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), {
963
+ htmlContent: marker_container.description,
964
+ visible: false
965
+ });
966
+ }
967
+ currentMap = this;
968
+ Microsoft.Maps.Events.addHandler(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.info_window));
969
+ return this.addToMap(marker_container.info_window);
970
+ }
971
+ };
972
+
973
+ Gmaps4RailsBing.prototype.openInfoWindow = function(currentMap, infoWindow) {
974
+ return function() {
975
+ if (currentMap.visibleInfoWindow) {
976
+ currentMap.visibleInfoWindow.setOptions({
977
+ visible: false
978
+ });
979
+ }
980
+ infoWindow.setOptions({
981
+ visible: true
982
+ });
983
+ return currentMap.visibleInfoWindow = infoWindow;
984
+ };
985
+ };
986
+
987
+ Gmaps4RailsBing.prototype.fitBounds = function() {
988
+ return this.serviceObject.setView({
989
+ bounds: this.boundsObject
990
+ });
991
+ };
992
+
993
+ Gmaps4RailsBing.prototype.addToMap = function(object) {
994
+ return this.serviceObject.entities.push(object);
995
+ };
996
+
997
+ Gmaps4RailsBing.prototype.removeFromMap = function(object) {
998
+ return this.serviceObject.entities.remove(object);
999
+ };
1000
+
1001
+ Gmaps4RailsBing.prototype.centerMapOnUser = function() {
1002
+ return this.serviceObject.setView({
1003
+ center: this.userLocation
1004
+ });
1005
+ };
1006
+
1007
+ Gmaps4RailsBing.prototype.updateBoundsWithPolylines = function() {};
1008
+
1009
+ Gmaps4RailsBing.prototype.updateBoundsWithPolygons = function() {};
1010
+
1011
+ Gmaps4RailsBing.prototype.updateBoundsWithCircles = function() {};
1012
+
1013
+ Gmaps4RailsBing.prototype.extendMapBounds = function() {};
1014
+
1015
+ Gmaps4RailsBing.prototype.adaptMapToBounds = function() {
1016
+ return this.fitBounds();
1017
+ };
1018
+
1019
+ return Gmaps4RailsBing;
1020
+
1021
+ })(Gmaps4Rails);
1022
+
1023
+ }).call(this);
1024
+ (function() {
1025
+ var __hasProp = Object.prototype.hasOwnProperty,
1026
+ __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; };
1027
+
1028
+ this.Gmaps4RailsMapquest = (function(_super) {
1029
+
1030
+ __extends(Gmaps4RailsMapquest, _super);
1031
+
1032
+ function Gmaps4RailsMapquest() {
1033
+ Gmaps4RailsMapquest.__super__.constructor.apply(this, arguments);
1034
+ this.map_options = {
1035
+ type: "map"
1036
+ };
1037
+ this.markers_conf = {};
1038
+ this.mergeWithDefault("markers_conf");
1039
+ this.mergeWithDefault("map_options");
1040
+ }
1041
+
1042
+ Gmaps4RailsMapquest.prototype.createPoint = function(lat, lng) {
1043
+ return new MQA.Poi({
1044
+ lat: lat,
1045
+ lng: lng
1046
+ });
1047
+ };
1048
+
1049
+ Gmaps4RailsMapquest.prototype.createLatLng = function(lat, lng) {
1050
+ return {
1051
+ lat: lat,
1052
+ lng: lng
1053
+ };
1054
+ };
1055
+
1056
+ Gmaps4RailsMapquest.prototype.createLatLngBounds = function() {};
1057
+
1058
+ Gmaps4RailsMapquest.prototype.createMap = function() {
1059
+ var map;
1060
+ map = new MQA.TileMap(document.getElementById(this.map_options.id), this.map_options.zoom, {
1061
+ lat: this.map_options.center_latitude,
1062
+ lng: this.map_options.center_longitude
1063
+ }, this.map_options.type);
1064
+ MQA.withModule('zoomcontrol3', (function() {
1065
+ return map.addControl(new MQA.LargeZoomControl3(), new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT));
1066
+ }));
1067
+ return map;
1068
+ };
1069
+
1070
+ Gmaps4RailsMapquest.prototype.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {};
1071
+
1072
+ Gmaps4RailsMapquest.prototype.createMarker = function(args) {
1073
+ var icon, marker;
1074
+ marker = new MQA.Poi({
1075
+ lat: args.Lat,
1076
+ lng: args.Lng
1077
+ });
1078
+ if (args.marker_picture !== "") {
1079
+ icon = new MQA.Icon(args.marker_picture, args.marker_height, args.marker_width);
1080
+ marker.setIcon(icon);
1081
+ if (args.marker_anchor !== null) {
1082
+ marker.setBias({
1083
+ x: args.marker_anchor[0],
1084
+ y: args.marker_anchor[1]
1085
+ });
1086
+ }
1087
+ }
1088
+ if (args.shadow_picture !== "") {
1089
+ icon = new MQA.Icon(args.shadow_picture, args.shadow_height, args.shadow_width);
1090
+ marker.setShadow(icon);
1091
+ if (args.shadow_anchor !== null) {
1092
+ marker.setShadowOffset({
1093
+ x: args.shadow_anchor[0],
1094
+ y: args.shadow_anchor[1]
1095
+ });
1096
+ }
1097
+ }
1098
+ this.addToMap(marker);
1099
+ return marker;
1100
+ };
1101
+
1102
+ Gmaps4RailsMapquest.prototype.clearMarkers = function() {
1103
+ var marker, _i, _len, _results;
1104
+ _results = [];
1105
+ for (_i = 0, _len = markers.length; _i < _len; _i++) {
1106
+ marker = markers[_i];
1107
+ _results.push(this.clearMarker(marker));
1108
+ }
1109
+ return _results;
1110
+ };
1111
+
1112
+ Gmaps4RailsMapquest.prototype.showMarkers = function() {
1113
+ var marker, _i, _len, _results;
1114
+ _results = [];
1115
+ for (_i = 0, _len = markers.length; _i < _len; _i++) {
1116
+ marker = markers[_i];
1117
+ _results.push(this.showMarker(marker));
1118
+ }
1119
+ return _results;
1120
+ };
1121
+
1122
+ Gmaps4RailsMapquest.prototype.hideMarkers = function() {
1123
+ var marker, _i, _len, _results;
1124
+ _results = [];
1125
+ for (_i = 0, _len = markers.length; _i < _len; _i++) {
1126
+ marker = markers[_i];
1127
+ _results.push(this.hideMarker(marker));
1128
+ }
1129
+ return _results;
1130
+ };
1131
+
1132
+ Gmaps4RailsMapquest.prototype.clearMarker = function(marker) {
1133
+ return this.removeFromMap(marker.serviceObject);
1134
+ };
1135
+
1136
+ Gmaps4RailsMapquest.prototype.showMarker = function(marker) {};
1137
+
1138
+ Gmaps4RailsMapquest.prototype.hideMarker = function(marker) {};
1139
+
1140
+ Gmaps4RailsMapquest.prototype.extendBoundsWithMarkers = function() {
1141
+ var marker, _i, _len, _ref, _results;
1142
+ if (this.markers.length >= 2) {
1143
+ this.boundsObject = new MQA.RectLL(this.markers[0].serviceObject.latLng, this.markers[1].serviceObject.latLng);
1144
+ _ref = this.markers;
1145
+ _results = [];
1146
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1147
+ marker = _ref[_i];
1148
+ _results.push(this.boundsObject.extend(marker.serviceObject.latLng));
1149
+ }
1150
+ return _results;
1151
+ }
1152
+ };
1153
+
1154
+ Gmaps4RailsMapquest.prototype.createClusterer = function(markers_array) {};
1155
+
1156
+ Gmaps4RailsMapquest.prototype.clearClusterer = function() {};
1157
+
1158
+ Gmaps4RailsMapquest.prototype.clusterize = function() {};
1159
+
1160
+ Gmaps4RailsMapquest.prototype.createInfoWindow = function(marker_container) {
1161
+ return marker_container.serviceObject.setInfoTitleHTML(marker_container.description);
1162
+ };
1163
+
1164
+ Gmaps4RailsMapquest.prototype.fitBounds = function() {
1165
+ if (this.markers.length >= 2) {
1166
+ this.serviceObject.zoomToRect(this.boundsObject);
1167
+ }
1168
+ if (this.markers.length === 1) {
1169
+ return this.serviceObject.setCenter(this.markers[0].serviceObject.latLng);
1170
+ }
1171
+ };
1172
+
1173
+ Gmaps4RailsMapquest.prototype.centerMapOnUser = function() {
1174
+ return this.serviceObject.setCenter(this.userLocation);
1175
+ };
1176
+
1177
+ Gmaps4RailsMapquest.prototype.addToMap = function(object) {
1178
+ return this.serviceObject.addShape(object);
1179
+ };
1180
+
1181
+ Gmaps4RailsMapquest.prototype.removeFromMap = function(object) {
1182
+ return this.serviceObject.removeShape(object);
1183
+ };
1184
+
1185
+ Gmaps4RailsMapquest.prototype.updateBoundsWithPolylines = function() {};
1186
+
1187
+ Gmaps4RailsMapquest.prototype.updateBoundsWithPolygons = function() {};
1188
+
1189
+ Gmaps4RailsMapquest.prototype.updateBoundsWithCircles = function() {};
1190
+
1191
+ Gmaps4RailsMapquest.prototype.extendMapBounds = function() {};
1192
+
1193
+ Gmaps4RailsMapquest.prototype.adaptMapToBounds = function() {
1194
+ return this.fitBounds();
1195
+ };
1196
+
1197
+ return Gmaps4RailsMapquest;
1198
+
1199
+ })(Gmaps4Rails);
1200
+
1201
+ }).call(this);
1202
+ (function() {
1203
+
1204
+ Gmaps4Rails.Google = {};
1205
+
1206
+ Gmaps4Rails.Google.Shared = {
1207
+ createPoint: function(lat, lng) {
1208
+ return new google.maps.Point(lat, lng);
1209
+ },
1210
+ createSize: function(width, height) {
1211
+ return new google.maps.Size(width, height);
1212
+ },
1213
+ createLatLng: function(lat, lng) {
1214
+ return new google.maps.LatLng(lat, lng);
1215
+ },
1216
+ createLatLngBounds: function() {
1217
+ return new google.maps.LatLngBounds();
1218
+ },
1219
+ clear: function() {
1220
+ return this.serviceObject.setMap(null);
1221
+ },
1222
+ show: function() {
1223
+ return this.serviceObject.setVisible(true);
1224
+ },
1225
+ hide: function() {
1226
+ return this.serviceObject.setVisible(false);
1227
+ },
1228
+ isVisible: function() {
1229
+ return this.serviceObject.getVisible();
1230
+ }
1231
+ };
1232
+
1233
+ }).call(this);
1234
+ (function() {
1235
+ var __hasProp = Object.prototype.hasOwnProperty,
1236
+ __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; };
1237
+
1238
+ this.Gmaps4Rails.Google.Circle = (function(_super) {
1239
+
1240
+ __extends(Circle, _super);
1241
+
1242
+ Circle.include(Gmaps4Rails.Interfaces.Basic);
1243
+
1244
+ Circle.include(Gmaps4Rails.Google.Shared);
1245
+
1246
+ Circle.extend(Gmaps4Rails.Circle.Class);
1247
+
1248
+ Circle.extend(Gmaps4Rails.Configuration);
1249
+
1250
+ function Circle(circle, controller) {
1251
+ var circleOptions, mergedOptions;
1252
+ this.controller = controller;
1253
+ if (circle === this.controller.circles[0]) {
1254
+ if (circle.strokeColor != null) {
1255
+ this.controller.circles_conf.strokeColor = circle.strokeColor;
1256
+ }
1257
+ if (circle.strokeOpacity != null) {
1258
+ this.controller.circles_conf.strokeOpacity = circle.strokeOpacity;
1259
+ }
1260
+ if (circle.strokeWeight != null) {
1261
+ this.controller.circles_conf.strokeWeight = circle.strokeWeight;
1262
+ }
1263
+ if (circle.fillColor != null) {
1264
+ this.controller.circles_conf.fillColor = circle.fillColor;
1265
+ }
1266
+ if (circle.fillOpacity != null) {
1267
+ this.controller.circles_conf.fillOpacity = circle.fillOpacity;
1268
+ }
1269
+ }
1270
+ if ((circle.lat != null) && (circle.lng != null)) {
1271
+ circleOptions = {
1272
+ center: this.createLatLng(circle.lat, circle.lng),
1273
+ strokeColor: circle.strokeColor || this.controller.circles_conf.strokeColor,
1274
+ strokeOpacity: circle.strokeOpacity || this.controller.circles_conf.strokeOpacity,
1275
+ strokeWeight: circle.strokeWeight || this.controller.circles_conf.strokeWeight,
1276
+ fillOpacity: circle.fillOpacity || this.controller.circles_conf.fillOpacity,
1277
+ fillColor: circle.fillColor || this.controller.circles_conf.fillColor,
1278
+ clickable: circle.clickable || this.controller.circles_conf.clickable,
1279
+ zIndex: circle.zIndex || this.controller.circles_conf.zIndex,
1280
+ radius: circle.radius
1281
+ };
1282
+ mergedOptions = this.mergeObjects(this.controller.circles_conf.raw, circleOptions);
1283
+ this.serviceObject = new google.maps.Circle(mergedOptions);
1284
+ this.serviceObject.setMap(this.controller.getMapObject());
1285
+ }
1286
+ }
1287
+
1288
+ return Circle;
1289
+
1290
+ })(Gmaps4Rails.Common);
1291
+
1292
+ }).call(this);
1293
+ (function() {
1294
+ var __hasProp = Object.prototype.hasOwnProperty,
1295
+ __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; };
1296
+
1297
+ this.Gmaps4Rails.Google.Kml = (function(_super) {
1298
+
1299
+ __extends(Kml, _super);
1300
+
1301
+ Kml.include(Gmaps4Rails.Interfaces.Basic);
1302
+
1303
+ Kml.include(Gmaps4Rails.Google.Shared);
1304
+
1305
+ Kml.include(Gmaps4Rails.Kml.Instance);
1306
+
1307
+ function Kml(kmlData, controller) {
1308
+ var kml;
1309
+ this.controller = controller;
1310
+ this.options = kmlData.options || {};
1311
+ this.options = this.mergeObjects(this.options, this.DEFAULT_CONF);
1312
+ kml = new google.maps.KmlLayer(kmlData.url, this.options);
1313
+ kml.setMap(this.controller.getMapObject());
1314
+ this.serviceObject = kml;
1315
+ }
1316
+
1317
+ return Kml;
1318
+
1319
+ })(Gmaps4Rails.Common);
1320
+
1321
+ }).call(this);
1322
+ (function() {
1323
+ var __hasProp = Object.prototype.hasOwnProperty,
1324
+ __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; };
1325
+
1326
+ Gmaps4Rails.Google.Map = (function(_super) {
1327
+
1328
+ __extends(Map, _super);
1329
+
1330
+ Map.include(Gmaps4Rails.Interfaces.Map);
1331
+
1332
+ Map.include(Gmaps4Rails.Map);
1333
+
1334
+ Map.include(Gmaps4Rails.Google.Shared);
1335
+
1336
+ Map.include(Gmaps4Rails.Configuration);
1337
+
1338
+ Map.prototype.CONF = {
1339
+ disableDefaultUI: false,
1340
+ disableDoubleClickZoom: false,
1341
+ type: "ROADMAP",
1342
+ mapTypeControl: null
1343
+ };
1344
+
1345
+ function Map(map_options, controller) {
1346
+ var defaultOptions, googleOptions, mergedGoogleOptions;
1347
+ this.controller = controller;
1348
+ defaultOptions = this.setConf();
1349
+ this.options = this.mergeObjects(map_options, defaultOptions);
1350
+ googleOptions = {
1351
+ maxZoom: this.options.maxZoom,
1352
+ minZoom: this.options.minZoom,
1353
+ zoom: this.options.zoom,
1354
+ center: this.createLatLng(this.options.center_latitude, this.options.center_longitude),
1355
+ mapTypeId: google.maps.MapTypeId[this.options.type],
1356
+ mapTypeControl: this.options.mapTypeControl,
1357
+ disableDefaultUI: this.options.disableDefaultUI,
1358
+ disableDoubleClickZoom: this.options.disableDoubleClickZoom,
1359
+ draggable: this.options.draggable
1360
+ };
1361
+ mergedGoogleOptions = this.mergeObjects(map_options.raw, googleOptions);
1362
+ this.serviceObject = new google.maps.Map(document.getElementById(this.options.id), mergedGoogleOptions);
1363
+ }
1364
+
1365
+ Map.prototype.extendBoundsWithMarker = function(marker) {
1366
+ return this.boundsObject.extend(marker.serviceObject.position);
1367
+ };
1368
+
1369
+ Map.prototype.extendBoundsWithPolyline = function(polyline) {
1370
+ var point, polyline_points, _i, _len, _results;
1371
+ polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray();
1372
+ _results = [];
1373
+ for (_i = 0, _len = polyline_points.length; _i < _len; _i++) {
1374
+ point = polyline_points[_i];
1375
+ _results.push(this.boundsObject.extend(point));
1376
+ }
1377
+ return _results;
1378
+ };
1379
+
1380
+ Map.prototype.extendBoundsWithPolygon = function(polygon) {
1381
+ var point, polygon_points, _i, _len, _results;
1382
+ polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray();
1383
+ _results = [];
1384
+ for (_i = 0, _len = polygon_points.length; _i < _len; _i++) {
1385
+ point = polygon_points[_i];
1386
+ _results.push(this.boundsObject.extend(point));
1387
+ }
1388
+ return _results;
1389
+ };
1390
+
1391
+ Map.prototype.extendBoundsWithCircle = function(circle) {
1392
+ this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
1393
+ return this.boundsObject.extend(circle.serviceObject.getBounds().getSouthWest());
1394
+ };
1395
+
1396
+ Map.prototype.extendBound = function(bound) {
1397
+ return this.boundsObject.extend(this.createLatLng(bound.lat, bound.lng));
1398
+ };
1399
+
1400
+ Map.prototype.adaptToBounds = function() {
1401
+ var map_center;
1402
+ if (!this.options.auto_zoom) {
1403
+ map_center = this.boundsObject.getCenter();
1404
+ this.options.center_latitude = map_center.lat();
1405
+ this.options.center_longitude = map_center.lng();
1406
+ return this.serviceObject.setCenter(map_center);
1407
+ } else {
1408
+ return this.fitBounds();
1409
+ }
1410
+ };
1411
+
1412
+ Map.prototype.fitBounds = function() {
1413
+ if (!this.boundsObject.isEmpty()) {
1414
+ return this.serviceObject.fitBounds(this.boundsObject);
1415
+ }
1416
+ };
1417
+
1418
+ Map.prototype.centerMapOnUser = function(position) {
1419
+ return this.serviceObject.setCenter(position);
1420
+ };
1421
+
1422
+ return Map;
1423
+
1424
+ })(Gmaps4Rails.Common);
1425
+
1426
+ }).call(this);
1427
+ (function() {
1428
+ var __hasProp = Object.prototype.hasOwnProperty,
1429
+ __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; };
1430
+
1431
+ Gmaps4Rails.Google.Marker = (function(_super) {
1432
+ var CONF;
1433
+
1434
+ __extends(Marker, _super);
1435
+
1436
+ Marker.include(Gmaps4Rails.Interfaces.Marker);
1437
+
1438
+ Marker.include(Gmaps4Rails.Google.Shared);
1439
+
1440
+ Marker.include(Gmaps4Rails.Marker.Instance);
1441
+
1442
+ Marker.extend(Gmaps4Rails.Marker.Class);
1443
+
1444
+ Marker.extend(Gmaps4Rails.Configuration);
1445
+
1446
+ CONF = {
1447
+ clusterer_gridSize: 50,
1448
+ clusterer_maxZoom: 5,
1449
+ custom_cluster_pictures: null,
1450
+ custom_infowindow_class: null,
1451
+ raw: {}
1452
+ };
1453
+
1454
+ function Marker(args, controller) {
1455
+ var markerLatLng;
1456
+ this.controller = controller;
1457
+ markerLatLng = this.createLatLng(args.lat, args.lng);
1458
+ if (this._isBasicMarker(args)) {
1459
+ this._createBasicMarker(markerLatLng, args);
1460
+ } else {
1461
+ if (args.rich_marker != null) {
1462
+ this._createRichMarker(markerLatLng, args);
1463
+ } else {
1464
+ this._createMarker(markerLatLng, args);
1465
+ }
1466
+ }
1467
+ }
1468
+
1469
+ Marker.prototype.createInfoWindow = function() {
1470
+ var boxText;
1471
+ if (typeof this.controller.jsTemplate === "function" || (this.description != null)) {
1472
+ if (typeof this.controller.jsTemplate === "function") {
1473
+ this.description = this.controller.jsTemplate(this);
1474
+ }
1475
+ if (CONF.custom_infowindow_class != null) {
1476
+ boxText = document.createElement("div");
1477
+ boxText.setAttribute("class", CONF.custom_infowindow_class);
1478
+ boxText.innerHTML = this.description;
1479
+ this.infowindow = new InfoBox(this.infobox(boxText));
1480
+ return google.maps.event.addListener(this.serviceObject, 'click', this._openInfowindow());
1481
+ } else {
1482
+ this.infowindow = new google.maps.InfoWindow({
1483
+ content: this.description
1484
+ });
1485
+ return google.maps.event.addListener(this.serviceObject, 'click', this._openInfowindow());
1486
+ }
1487
+ }
1488
+ };
1489
+
1490
+ Marker.prototype._createBasicMarker = function(markerLatLng, args) {
1491
+ var defaultOptions, mergedOptions;
1492
+ defaultOptions = {
1493
+ position: markerLatLng,
1494
+ map: this.getMap(),
1495
+ title: args.marker_title,
1496
+ draggable: args.marker_draggable,
1497
+ zIndex: args.zindex
1498
+ };
1499
+ mergedOptions = this.mergeObjects(CONF.raw, defaultOptions);
1500
+ return this.serviceObject = new google.maps.Marker(defaultOptions);
1501
+ };
1502
+
1503
+ Marker.prototype._createRichMarker = function(markerLatLng, args) {
1504
+ return new RichMarker({
1505
+ position: markerLatLng,
1506
+ map: this.serviceObject,
1507
+ draggable: args.marker_draggable,
1508
+ content: args.rich_marker,
1509
+ flat: args.marker_anchor === null ? false : args.marker_anchor[1],
1510
+ anchor: args.marker_anchor === null ? 0 : args.marker_anchor[0],
1511
+ zIndex: args.zindex
1512
+ });
1513
+ };
1514
+
1515
+ Marker.prototype._createMarker = function(markerLatLng, args) {
1516
+ var defaultOptions, imageAnchorPosition, markerImage, mergedOptions, shadowAnchorPosition, shadowImage;
1517
+ imageAnchorPosition = this._createImageAnchorPosition(args.marker_anchor);
1518
+ shadowAnchorPosition = this._createImageAnchorPosition(args.shadow_anchor);
1519
+ markerImage = this._createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition);
1520
+ shadowImage = this._createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition);
1521
+ defaultOptions = {
1522
+ position: markerLatLng,
1523
+ map: this.getMap(),
1524
+ icon: markerImage,
1525
+ title: args.marker_title,
1526
+ draggable: args.marker_draggable,
1527
+ shadow: shadowImage,
1528
+ zIndex: args.zindex
1529
+ };
1530
+ mergedOptions = this.mergeObjects(CONF.raw, defaultOptions);
1531
+ return this.serviceObject = new google.maps.Marker(mergedOptions);
1532
+ };
1533
+
1534
+ Marker.prototype._includeMarkerImage = function(obj) {
1535
+ var index, object, _len, _ref;
1536
+ _ref = this.controller.markerImages;
1537
+ for (index = 0, _len = _ref.length; index < _len; index++) {
1538
+ object = _ref[index];
1539
+ if (object.url === obj) return index;
1540
+ }
1541
+ return false;
1542
+ };
1543
+
1544
+ Marker.prototype._createOrRetrieveImage = function(currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition) {
1545
+ var markerImage, test_image_index;
1546
+ if (typeof currentMarkerPicture === "undefined" || currentMarkerPicture === "" || currentMarkerPicture === null) {
1547
+ return null;
1548
+ }
1549
+ if (!(test_image_index = this._includeMarkerImage(currentMarkerPicture))) {
1550
+ markerImage = this._createMarkerImage(currentMarkerPicture, this.createSize(markerWidth, markerHeight), null, imageAnchorPosition, null);
1551
+ this.controller.markerImages.push(markerImage);
1552
+ return markerImage;
1553
+ } else {
1554
+ if (typeof test_image_index === 'number') {
1555
+ return this.controller.markerImages[test_image_index];
1556
+ }
1557
+ return false;
1558
+ }
1559
+ };
1560
+
1561
+ Marker.prototype._isBasicMarker = function(args) {
1562
+ return !(args.marker_picture != null) && !(args.rich_marker != null);
1563
+ };
1564
+
1565
+ Marker.prototype._createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
1566
+ return new google.maps.MarkerImage(markerPicture, markerSize, origin, anchor, scaledSize);
1567
+ };
1568
+
1569
+ Marker.prototype._createImageAnchorPosition = function(anchorLocation) {
1570
+ if (anchorLocation === null) {
1571
+ return null;
1572
+ } else {
1573
+ return this.createPoint(anchorLocation[0], anchorLocation[1]);
1574
+ }
1575
+ };
1576
+
1577
+ Marker.prototype._openInfowindow = function() {
1578
+ var that;
1579
+ that = this;
1580
+ return function() {
1581
+ that.controller._closeVisibleInfoWindow();
1582
+ that.infowindow.open(that.getMap(), that.serviceObject);
1583
+ return that.controller._setVisibleInfoWindow(that.infowindow);
1584
+ };
1585
+ };
1586
+
1587
+ return Marker;
1588
+
1589
+ })(Gmaps4Rails.Common);
1590
+
1591
+ }).call(this);
1592
+ (function() {
1593
+ var __hasProp = Object.prototype.hasOwnProperty,
1594
+ __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; };
1595
+
1596
+ this.Gmaps4Rails.Google.Polygon = (function(_super) {
1597
+
1598
+ __extends(Polygon, _super);
1599
+
1600
+ Polygon.include(Gmaps4Rails.Interfaces.Basic);
1601
+
1602
+ Polygon.include(Gmaps4Rails.Google.Shared);
1603
+
1604
+ Polygon.extend(Gmaps4Rails.Polygon.Class);
1605
+
1606
+ Polygon.extend(Gmaps4Rails.Configuration);
1607
+
1608
+ function Polygon(polygon, controller) {
1609
+ var clickable, fillColor, fillOpacity, latlng, mergedOptions, point, polyOptions, polygon_coordinates, strokeColor, strokeOpacity, strokeWeight, _i, _len;
1610
+ this.controller = controller;
1611
+ polygon_coordinates = [];
1612
+ for (_i = 0, _len = polygon.length; _i < _len; _i++) {
1613
+ point = polygon[_i];
1614
+ latlng = this.createLatLng(point.lat, point.lng);
1615
+ polygon_coordinates.push(latlng);
1616
+ if (point === polygon[0]) {
1617
+ strokeColor = point.strokeColor || this.controller.polygons_conf.strokeColor;
1618
+ strokeOpacity = point.strokeOpacity || this.controller.polygons_conf.strokeOpacity;
1619
+ strokeWeight = point.strokeWeight || this.controller.polygons_conf.strokeWeight;
1620
+ fillColor = point.fillColor || this.controller.polygons_conf.fillColor;
1621
+ fillOpacity = point.fillOpacity || this.controller.polygons_conf.fillOpacity;
1622
+ clickable = point.clickable || this.controller.polygons_conf.clickable;
1623
+ }
1624
+ }
1625
+ polyOptions = {
1626
+ path: polyline_coordinates,
1627
+ strokeColor: strokeColor,
1628
+ strokeOpacity: strokeOpacity,
1629
+ strokeWeight: strokeWeight,
1630
+ clickable: clickable,
1631
+ zIndex: zIndex
1632
+ };
1633
+ mergedOptions = this.mergeObjects(controller.polygons_conf.raw, polyOptions);
1634
+ this.serviceObject = new google.maps.Polygon(mergedOptions);
1635
+ }
1636
+
1637
+ return Polygon;
1638
+
1639
+ })(Gmaps4Rails.Common);
1640
+
1641
+ }).call(this);
1642
+ (function() {
1643
+ var __hasProp = Object.prototype.hasOwnProperty,
1644
+ __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; };
1645
+
1646
+ this.Gmaps4Rails.Google.Polyline = (function(_super) {
1647
+
1648
+ __extends(Polyline, _super);
1649
+
1650
+ Polyline.include(Gmaps4Rails.Interfaces.Basic);
1651
+
1652
+ Polyline.include(Gmaps4Rails.Google.Shared);
1653
+
1654
+ Polyline.extend(Gmaps4Rails.Polyline.Class);
1655
+
1656
+ Polyline.extend(Gmaps4Rails.Configuration);
1657
+
1658
+ function Polyline(polyline, controller) {
1659
+ var clickable, decoded_array, element, mergedOptions, point, polyOptions, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
1660
+ polyline_coordinates = [];
1661
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
1662
+ element = polyline[_i];
1663
+ if (element.coded_array != null) {
1664
+ decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array);
1665
+ for (_j = 0, _len2 = decoded_array.length; _j < _len2; _j++) {
1666
+ point = decoded_array[_j];
1667
+ polyline_coordinates.push(point);
1668
+ }
1669
+ } else {
1670
+ if (element === polyline[0]) {
1671
+ strokeColor = element.strokeColor || controller.polylines_conf.strokeColor;
1672
+ strokeOpacity = element.strokeOpacity || controller.polylines_conf.strokeOpacity;
1673
+ strokeWeight = element.strokeWeight || controller.polylines_conf.strokeWeight;
1674
+ clickable = element.clickable || controller.polylines_conf.clickable;
1675
+ zIndex = element.zIndex || controller.polylines_conf.zIndex;
1676
+ }
1677
+ if ((element.lat != null) && (element.lng != null)) {
1678
+ polyline_coordinates.push(this.createLatLng(element.lat, element.lng));
1679
+ }
1680
+ }
1681
+ }
1682
+ polyOptions = {
1683
+ path: polyline_coordinates,
1684
+ strokeColor: strokeColor,
1685
+ strokeOpacity: strokeOpacity,
1686
+ strokeWeight: strokeWeight,
1687
+ clickable: clickable,
1688
+ zIndex: zIndex
1689
+ };
1690
+ mergedOptions = this.mergeObjects(controller.polylines_conf.raw, polyOptions);
1691
+ this.serviceObject = new google.maps.Polyline(mergedOptions);
1692
+ this.serviceObject.setMap(controller.getMapObject());
1693
+ }
1694
+
1695
+ return Polyline;
1696
+
1697
+ })(Gmaps4Rails.Common);
1698
+
1699
+ }).call(this);
1700
+ (function() {
1701
+ var __hasProp = Object.prototype.hasOwnProperty,
1702
+ __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; };
1703
+
1704
+ this.Gmaps4RailsGoogle = (function(_super) {
1705
+
1706
+ __extends(Gmaps4RailsGoogle, _super);
1707
+
1708
+ Gmaps4RailsGoogle.include(Gmaps4Rails.Google.Shared);
1709
+
1710
+ Gmaps4RailsGoogle.prototype.getModule = function() {
1711
+ return Gmaps4Rails.Google;
1712
+ };
1713
+
1714
+ function Gmaps4RailsGoogle() {
1715
+ Gmaps4RailsGoogle.__super__.constructor.apply(this, arguments);
1716
+ this.markerImages = [];
1717
+ }
1718
+
1719
+ Gmaps4RailsGoogle.prototype.createClusterer = function(markers_array) {
1720
+ return new MarkerClusterer(this.getMapObject(), markers_array, {
1721
+ maxZoom: this.markers_conf.clusterer_maxZoom,
1722
+ gridSize: this.markers_conf.clusterer_gridSize,
1723
+ styles: this.customClusterer()
1724
+ });
1725
+ };
1726
+
1727
+ Gmaps4RailsGoogle.prototype.clearClusterer = function() {
1728
+ return this.markerClusterer.clearMarkers();
1729
+ };
1730
+
1731
+ Gmaps4RailsGoogle.prototype.clusterize = function() {
1732
+ var marker, markers_array, _i, _len, _ref;
1733
+ if (this.markers_conf.do_clustering) {
1734
+ if (this.markerClusterer != null) this.clearClusterer();
1735
+ markers_array = [];
1736
+ _ref = this.markers;
1737
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1738
+ marker = _ref[_i];
1739
+ markers_array.push(marker.serviceObject);
1740
+ }
1741
+ return this.markerClusterer = this.createClusterer(markers_array);
1742
+ }
1743
+ };
1744
+
1745
+ Gmaps4RailsGoogle.prototype._closeVisibleInfoWindow = function() {
1746
+ if (this.visibleInfowindow != null) return this.visibleInfowindow.close();
1747
+ };
1748
+
1749
+ Gmaps4RailsGoogle.prototype._setVisibleInfoWindow = function(infowindow) {
1750
+ return this.visibleInfowindow = infowindow;
1751
+ };
1752
+
1753
+ return Gmaps4RailsGoogle;
1754
+
1755
+ })(Gmaps4Rails.BaseController);
1756
+
1757
+ }).call(this);
1758
+ (function() {
1759
+
1760
+
1761
+
1762
+ }).call(this);
1763
+ (function() {
1764
+
1765
+ Gmaps4Rails.Openlayers = {};
1766
+
1767
+ Gmaps4Rails.Openlayers.Shared = {
1768
+ createPoint: function(lat, lng) {
1769
+ return new OpenLayers.Geometry.Point(lng, lat);
1770
+ },
1771
+ createLatLng: function(lat, lng) {
1772
+ return new OpenLayers.LonLat(lng, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
1773
+ },
1774
+ createAnchor: function(offset) {
1775
+ if (offset === null) return null;
1776
+ return new OpenLayers.Pixel(offset[0], offset[1]);
1777
+ },
1778
+ createSize: function(width, height) {
1779
+ return new OpenLayers.Size(width, height);
1780
+ },
1781
+ createLatLngBounds: function() {
1782
+ return new OpenLayers.Bounds();
1783
+ }
1784
+ };
1785
+
1786
+ }).call(this);
1787
+ (function() {
1788
+ var __hasProp = Object.prototype.hasOwnProperty,
1789
+ __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; };
1790
+
1791
+ this.Gmaps4Rails.Openlayers.Map = (function(_super) {
1792
+
1793
+ __extends(Map, _super);
1794
+
1795
+ Map.include(Gmaps4Rails.Interfaces.Map);
1796
+
1797
+ Map.include(Gmaps4Rails.Map);
1798
+
1799
+ Map.include(Gmaps4Rails.Openlayers.Shared);
1800
+
1801
+ Map.include(Gmaps4Rails.Configuration);
1802
+
1803
+ Map.prototype.CONF = {
1804
+ disableDefaultUI: false,
1805
+ disableDoubleClickZoom: false,
1806
+ type: "ROADMAP",
1807
+ mapTypeControl: null
1808
+ };
1809
+
1810
+ function Map(map_options, controller) {
1811
+ var defaultOptions, mergedOpenlayersOptions, openlayersOptions;
1812
+ this.controller = controller;
1813
+ defaultOptions = this.setConf();
1814
+ this.options = this.mergeObjects(map_options, defaultOptions);
1815
+ openlayersOptions = {
1816
+ center: this.createLatLng(this.options.center_latitude, this.options.center_longitude),
1817
+ zoom: this.options.zoom
1818
+ };
1819
+ mergedOpenlayersOptions = this.mergeObjects(map_options.raw, openlayersOptions);
1820
+ this.serviceObject = new OpenLayers.Map(this.options.id, mergedOpenlayersOptions);
1821
+ this.serviceObject.addLayer(new OpenLayers.Layer.OSM());
1822
+ }
1823
+
1824
+ Map.prototype.extendBoundsWithMarker = function(marker) {
1825
+ return this.boundsObject.extend(this.createLatLng(marker.lat, marker.lng));
1826
+ };
1827
+
1828
+ Map.prototype.extendBoundsWithPolyline = function(polyline) {};
1829
+
1830
+ Map.prototype.extendBoundsWithPolygon = function(polygon) {};
1831
+
1832
+ Map.prototype.extendBoundsWithCircle = function(circle) {};
1833
+
1834
+ Map.prototype.extendBound = function(bound) {};
1835
+
1836
+ Map.prototype.fitBounds = function() {
1837
+ return this.serviceObject.zoomToExtent(this.boundsObject, true);
1838
+ };
1839
+
1840
+ Map.prototype.adaptToBounds = function() {
1841
+ return this.fitBounds();
1842
+ };
1843
+
1844
+ Map.prototype.centerMapOnUser = function(position) {
1845
+ return this.serviceObject.setCenter(position);
1846
+ };
1847
+
1848
+ return Map;
1849
+
1850
+ })(Gmaps4Rails.Common);
1851
+
1852
+ }).call(this);
1853
+ (function() {
1854
+ var __hasProp = Object.prototype.hasOwnProperty,
1855
+ __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; };
1856
+
1857
+ this.Gmaps4Rails.Openlayers.Marker = (function(_super) {
1858
+
1859
+ __extends(Marker, _super);
1860
+
1861
+ Marker.include(Gmaps4Rails.Interfaces.Marker);
1862
+
1863
+ Marker.include(Gmaps4Rails.Openlayers.Shared);
1864
+
1865
+ Marker.include(Gmaps4Rails.Marker.Instance);
1866
+
1867
+ Marker.extend(Gmaps4Rails.Marker.Class);
1868
+
1869
+ Marker.extend(Gmaps4Rails.Configuration);
1870
+
1871
+ function Marker(args, controller) {
1872
+ this.controller = controller;
1873
+ this.controller._createMarkersLayer();
1874
+ this._createMarkerStyle(args);
1875
+ if (this._isBasicMarker(args)) {
1876
+ this._styleForBasicMarker(args);
1877
+ } else {
1878
+ this._styleForCustomMarker(args);
1879
+ }
1880
+ this.serviceObject = new OpenLayers.Feature.Vector(this.createPoint(args.lat, args.lng), null, this.style_mark);
1881
+ this.serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
1882
+ this.controller.markersLayer.addFeatures([this.serviceObject]);
1883
+ }
1884
+
1885
+ Marker.prototype.createInfoWindow = function() {
1886
+ if (this.description != null) {
1887
+ return this.serviceObject.infoWindow = this.description;
1888
+ }
1889
+ };
1890
+
1891
+ Marker.prototype.isVisible = function() {
1892
+ return true;
1893
+ };
1894
+
1895
+ Marker.prototype._isBasicMarker = function(args) {
1896
+ return !(args.marker_picture != null);
1897
+ };
1898
+
1899
+ Marker.prototype._createMarkerStyle = function(args) {
1900
+ this.style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
1901
+ this.style_mark.fillOpacity = 1;
1902
+ return this.style_mark.graphicTitle = args.title;
1903
+ };
1904
+
1905
+ Marker.prototype._styleForBasicMarker = function(args) {
1906
+ this.style_mark.graphicHeight = 30;
1907
+ return this.style_mark.externalGraphic = "http://openlayers.org/dev/img/marker-blue.png";
1908
+ };
1909
+
1910
+ Marker.prototype._styleForCustomMarker = function(args) {
1911
+ this.style_mark.graphicWidth = args.marker_width;
1912
+ this.style_mark.graphicHeight = args.marker_height;
1913
+ this.style_mark.externalGraphic = args.marker_picture;
1914
+ if (args.marker_anchor != null) {
1915
+ this.style_mark.graphicXOffset = args.marker_anchor[0];
1916
+ this.style_mark.graphicYOffset = args.marker_anchor[1];
1917
+ }
1918
+ if (args.shadow_picture != null) {
1919
+ this.style_mark.backgroundGraphic = args.shadow_picture;
1920
+ this.style_mark.backgroundWidth = args.shadow_width;
1921
+ this.style_mark.backgroundHeight = args.shadow_height;
1922
+ if (args.shadow_anchor != null) {
1923
+ this.style_mark.backgroundXOffset = args.shadow_anchor[0];
1924
+ return this.style_mark.backgroundYOffset = args.shadow_anchor[1];
1925
+ }
1926
+ }
1927
+ };
1928
+
1929
+ return Marker;
1930
+
1931
+ })(Gmaps4Rails.Common);
1932
+
1933
+ }).call(this);
1934
+ (function() {
1935
+ var __hasProp = Object.prototype.hasOwnProperty,
1936
+ __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; };
1937
+
1938
+ this.Gmaps4Rails.Openlayers.Polyline = (function(_super) {
1939
+
1940
+ __extends(Polyline, _super);
1941
+
1942
+ Polyline.include(Gmaps4Rails.Openlayers.Shared);
1943
+
1944
+ Polyline.extend(Gmaps4Rails.Polyline.Class);
1945
+
1946
+ Polyline.extend(Gmaps4Rails.Configuration);
1947
+
1948
+ function Polyline(polyline, controller) {
1949
+ var clickable, element, latlng, line_points, line_style, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _len;
1950
+ this.controller = controller;
1951
+ this.controller._createPolylinesLayer();
1952
+ polyline_coordinates = [];
1953
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
1954
+ element = polyline[_i];
1955
+ if (element === polyline[0]) {
1956
+ strokeColor = element.strokeColor || this.controller.polylines_conf.strokeColor;
1957
+ strokeOpacity = element.strokeOpacity || this.controller.polylines_conf.strokeOpacity;
1958
+ strokeWeight = element.strokeWeight || this.controller.polylines_conf.strokeWeight;
1959
+ clickable = element.clickable || this.controller.polylines_conf.clickable;
1960
+ zIndex = element.zIndex || this.controller.polylines_conf.zIndex;
1961
+ }
1962
+ if ((element.lat != null) && (element.lng != null)) {
1963
+ latlng = new OpenLayers.Geometry.Point(element.lng, element.lat);
1964
+ polyline_coordinates.push(latlng);
1965
+ }
1966
+ }
1967
+ line_points = new OpenLayers.Geometry.LineString(polyline_coordinates);
1968
+ line_style = {
1969
+ strokeColor: strokeColor,
1970
+ strokeOpacity: strokeOpacity,
1971
+ strokeWidth: strokeWeight
1972
+ };
1973
+ this.serviceObject = new OpenLayers.Feature.Vector(line_points, null, line_style);
1974
+ this.serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
1975
+ this.controller.polylinesLayer.addFeatures([this.serviceObject]);
1976
+ }
1977
+
1978
+ Polyline.prototype.isVisible = function() {
1979
+ return true;
1980
+ };
1981
+
1982
+ return Polyline;
1983
+
1984
+ })(Gmaps4Rails.Common);
1985
+
1986
+ }).call(this);
1987
+ (function() {
1988
+ var __hasProp = Object.prototype.hasOwnProperty,
1989
+ __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; };
1990
+
1991
+ this.Gmaps4RailsOpenlayers = (function(_super) {
1992
+
1993
+ __extends(Gmaps4RailsOpenlayers, _super);
1994
+
1995
+ Gmaps4RailsOpenlayers.include(Gmaps4Rails.Openlayers.Shared);
1996
+
1997
+ function Gmaps4RailsOpenlayers() {
1998
+ Gmaps4RailsOpenlayers.__super__.constructor.apply(this, arguments);
1999
+ this.markersControl = null;
2000
+ this.markersLayer = null;
2001
+ this.polylinesLayer = null;
2002
+ }
2003
+
2004
+ Gmaps4RailsOpenlayers.prototype.getModule = function() {
2005
+ return Gmaps4Rails.Openlayers;
2006
+ };
2007
+
2008
+ Gmaps4RailsOpenlayers.prototype.createClusterer = function(marker_serviceObject_array) {
2009
+ var strategy, style;
2010
+ style = new OpenLayers.Style(this._clustererOptions, this._clustererFunctions);
2011
+ strategy = new OpenLayers.Strategy.Cluster;
2012
+ this._clearMarkersLayer();
2013
+ this.clusterLayer = new OpenLayers.Layer.Vector("Clusters", {
2014
+ strategies: [strategy],
2015
+ styleMap: new OpenLayers.StyleMap({
2016
+ "default": style,
2017
+ "select": {
2018
+ fillColor: "#8aeeef",
2019
+ strokeColor: "#32a8a9"
2020
+ }
2021
+ })
2022
+ });
2023
+ this.getMapObject().addLayer(this.clusterLayer);
2024
+ this.clusterLayer.addFeatures(marker_serviceObject_array);
2025
+ return this.clusterLayer;
2026
+ };
2027
+
2028
+ Gmaps4RailsOpenlayers.prototype.clearClusterer = function() {
2029
+ if ((this.clusterLayer != null) && (this.getMapObject().getLayer(this.clusterLayer.id) != null)) {
2030
+ this.getMapObject().removeLayer(this.markerClusterer);
2031
+ }
2032
+ return this.clusterLayer = null;
2033
+ };
2034
+
2035
+ Gmaps4RailsOpenlayers.prototype.clearMarkers = function() {
2036
+ this._clearMarkersLayer();
2037
+ this.clearClusterer();
2038
+ return this.markers = [];
2039
+ };
2040
+
2041
+ Gmaps4RailsOpenlayers.prototype._createPolylinesLayer = function() {
2042
+ if (this.polylinesLayer != null) return;
2043
+ this.polylinesLayer = new OpenLayers.Layer.Vector("Polylines", null);
2044
+ this.polylinesLayer.events.register("featureselected", this.polylinesLayer, this._onFeatureSelect);
2045
+ this.polylinesLayer.events.register("featureunselected", this.polylinesLayer, this._onFeatureUnselect);
2046
+ this.polylinesControl = new OpenLayers.Control.DrawFeature(this.polylinesLayer, OpenLayers.Handler.Path);
2047
+ this.getMapObject().addLayer(this.polylinesLayer);
2048
+ return this.getMapObject().addControl(this.polylinesControl);
2049
+ };
2050
+
2051
+ Gmaps4RailsOpenlayers.prototype._createMarkersLayer = function() {
2052
+ if (this.markersLayer != null) return;
2053
+ this.markersLayer = new OpenLayers.Layer.Vector("Markers", null);
2054
+ this.getMapObject().addLayer(this.markersLayer);
2055
+ this.markersLayer.events.register("featureselected", this.markersLayer, this._onFeatureSelect());
2056
+ this.markersLayer.events.register("featureunselected", this.markersLayer, this._onFeatureUnselect());
2057
+ this.markersControl = new OpenLayers.Control.SelectFeature(this.markersLayer);
2058
+ this.getMapObject().addControl(this.markersControl);
2059
+ return this.markersControl.activate();
2060
+ };
2061
+
2062
+ Gmaps4RailsOpenlayers.prototype._clearMarkersLayer = function() {
2063
+ if ((this.markersLayer != null) && (this.getMapObject().getLayer(this.markersLayer.id) != null)) {
2064
+ this.getMapObject().removeLayer(this.markersLayer);
2065
+ }
2066
+ return this.markersLayer = null;
2067
+ };
2068
+
2069
+ Gmaps4RailsOpenlayers.prototype._onFeatureSelect = function() {
2070
+ var controller;
2071
+ controller = this;
2072
+ return function(evt) {
2073
+ var feature, popup;
2074
+ feature = evt.feature;
2075
+ popup = new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(300, 200), feature.infoWindow, null, true, controller._onPopupClose(controller, feature));
2076
+ feature.popup = popup;
2077
+ popup.feature = feature;
2078
+ return controller.getMapObject().addPopup(popup);
2079
+ };
2080
+ };
2081
+
2082
+ Gmaps4RailsOpenlayers.prototype._onFeatureUnselect = function() {
2083
+ var controller;
2084
+ controller = this;
2085
+ return function(evt) {
2086
+ var feature;
2087
+ feature = evt.feature;
2088
+ if (feature.popup != null) {
2089
+ controller.getMapObject().removePopup(feature.popup);
2090
+ feature.popup.destroy();
2091
+ return feature.popup = null;
2092
+ }
2093
+ };
2094
+ };
2095
+
2096
+ Gmaps4RailsOpenlayers.prototype._onPopupClose = function(controller, feature) {
2097
+ return function() {
2098
+ return controller.markersControl.unselect(feature);
2099
+ };
2100
+ };
2101
+
2102
+ Gmaps4RailsOpenlayers.prototype._clustererFunctions = {
2103
+ context: {
2104
+ width: function(feature) {
2105
+ var _ref;
2106
+ return (_ref = feature.cluster) != null ? _ref : {
2107
+ 2: 1
2108
+ };
2109
+ },
2110
+ radius: function(feature) {
2111
+ var pix;
2112
+ pix = 2;
2113
+ if (feature.cluster) pix = feature.cluster.length + 10;
2114
+ return pix;
2115
+ },
2116
+ label: function(feature) {
2117
+ if (feature.cluster) {
2118
+ return feature.cluster.length;
2119
+ } else {
2120
+ return "";
2121
+ }
2122
+ }
2123
+ }
2124
+ };
2125
+
2126
+ Gmaps4RailsOpenlayers.prototype._clustererOptions = {
2127
+ pointRadius: "${radius}",
2128
+ fillColor: "#ffcc66",
2129
+ fillOpacity: 0.8,
2130
+ strokeColor: "#cc6633",
2131
+ strokeWidth: "${width}",
2132
+ label: "${label}"
2133
+ };
2134
+
2135
+ return Gmaps4RailsOpenlayers;
2136
+
2137
+ })(Gmaps4Rails.BaseController);
2138
+
2139
+ }).call(this);
2140
+ (function() {
2141
+
2142
+
2143
+
2144
+ }).call(this);