gmaps4rails 0.11.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/README.rdoc +6 -2
  2. data/app/views/gmaps4rails/_gmaps4rails.html.erb +18 -20
  3. data/lib/gmaps4rails/base.rb +95 -0
  4. data/lib/gmaps4rails/extensions/hash.rb +3 -67
  5. data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +13 -2
  6. data/public/javascripts/gmaps4rails/all_apis.js +5 -0
  7. data/public/javascripts/gmaps4rails/gmaps4rails.base.js +147 -112
  8. data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +182 -171
  9. data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +269 -235
  10. data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +135 -125
  11. data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +227 -218
  12. data/public/stylesheets/gmaps4rails.css +2 -2
  13. metadata +9 -111
  14. data/test/dummy/app/controllers/application_controller.rb +0 -3
  15. data/test/dummy/app/controllers/users_controller.rb +0 -60
  16. data/test/dummy/app/helpers/application_helper.rb +0 -2
  17. data/test/dummy/app/helpers/users_helper.rb +0 -3
  18. data/test/dummy/app/models/user.rb +0 -38
  19. data/test/dummy/config/application.rb +0 -41
  20. data/test/dummy/config/boot.rb +0 -6
  21. data/test/dummy/config/environment.rb +0 -5
  22. data/test/dummy/config/environments/development.rb +0 -26
  23. data/test/dummy/config/environments/production.rb +0 -49
  24. data/test/dummy/config/environments/test.rb +0 -35
  25. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  26. data/test/dummy/config/initializers/inflections.rb +0 -10
  27. data/test/dummy/config/initializers/mime_types.rb +0 -5
  28. data/test/dummy/config/initializers/secret_token.rb +0 -7
  29. data/test/dummy/config/initializers/session_store.rb +0 -8
  30. data/test/dummy/config/routes.rb +0 -7
  31. data/test/dummy/db/migrate/20110306182914_create_users.rb +0 -21
  32. data/test/dummy/db/migrate/20110430081624_add_addresses_to_users.rb +0 -11
  33. data/test/dummy/db/migrate/20110430083824_remove_address_from_users.rb +0 -9
  34. data/test/dummy/db/schema.rb +0 -35
  35. data/test/dummy/db/seeds.rb +0 -7
  36. data/test/dummy/spec/base/base_spec.rb +0 -127
  37. data/test/dummy/spec/helpers/gmaps4rails_helper_spec.rb +0 -13
  38. data/test/dummy/spec/javascripts/support/jasmine_config.rb +0 -23
  39. data/test/dummy/spec/javascripts/support/jasmine_runner.rb +0 -20
  40. data/test/dummy/spec/models/user_spec.rb +0 -284
  41. data/test/dummy/spec/requests/users_spec.rb +0 -22
  42. data/test/dummy/spec/spec_helper.rb +0 -41
  43. data/test/dummy/spec/support/factories.rb +0 -20
  44. data/test/dummy/spec/support/matchers.rb +0 -7
  45. data/test/dummy31/app/controllers/application_controller.rb +0 -3
  46. data/test/dummy31/app/controllers/users_controller.rb +0 -83
  47. data/test/dummy31/app/helpers/application_helper.rb +0 -2
  48. data/test/dummy31/app/helpers/users_helper.rb +0 -2
  49. data/test/dummy31/app/models/user.rb +0 -7
  50. data/test/dummy31/config/application.rb +0 -43
  51. data/test/dummy31/config/boot.rb +0 -6
  52. data/test/dummy31/config/environment.rb +0 -5
  53. data/test/dummy31/config/environments/development.rb +0 -27
  54. data/test/dummy31/config/environments/production.rb +0 -51
  55. data/test/dummy31/config/environments/test.rb +0 -39
  56. data/test/dummy31/config/initializers/backtrace_silencers.rb +0 -7
  57. data/test/dummy31/config/initializers/inflections.rb +0 -10
  58. data/test/dummy31/config/initializers/mime_types.rb +0 -5
  59. data/test/dummy31/config/initializers/secret_token.rb +0 -7
  60. data/test/dummy31/config/initializers/session_store.rb +0 -8
  61. data/test/dummy31/config/initializers/wrap_parameters.rb +0 -12
  62. data/test/dummy31/config/routes.rb +0 -61
  63. data/test/dummy31/db/migrate/20110809134019_create_users.rb +0 -13
  64. data/test/dummy31/db/schema.rb +0 -25
  65. data/test/dummy31/db/seeds.rb +0 -7
@@ -1,272 +1,306 @@
1
- //Map settings
2
- Gmaps4Rails.map_options.disableDefaultUI = false;
3
- Gmaps4Rails.map_options.disableDoubleClickZoom = false;
4
- Gmaps4Rails.map_options.type = "ROADMAP"; // HYBRID, ROADMAP, SATELLITE, TERRAIN
5
-
6
- //markers + info styling
7
- Gmaps4Rails.markers_conf.clusterer_gridSize = 50;
8
- Gmaps4Rails.markers_conf.clusterer_maxZoom = 5;
9
- Gmaps4Rails.markers_conf.custom_cluster_pictures = null;
10
- Gmaps4Rails.markers_conf.custom_infowindow_class = null;
11
-
12
- //Polygon Styling
13
- Gmaps4Rails.polygons_conf = { // default style for polygons
14
- strokeColor: "#FFAA00",
15
- strokeOpacity: 0.8,
16
- strokeWeight: 2,
17
- fillColor: "#000000",
18
- fillOpacity: 0.35
19
- };
1
+ var Gmaps4RailsGoogle = function() {
2
+
3
+ //Map settings
4
+ this.map_options = {
5
+ disableDefaultUI: false,
6
+ disableDoubleClickZoom: false,
7
+ type: "ROADMAP" // HYBRID, ROADMAP, SATELLITE, TERRAIN
8
+ };
9
+
10
+ this.mergeWithDefault("map_options");
11
+
12
+ //markers + info styling
13
+ this.markers_conf = {
14
+ clusterer_gridSize: 50,
15
+ clusterer_maxZoom: 5,
16
+ custom_cluster_pictures: null,
17
+ custom_infowindow_class: null
18
+ };
19
+
20
+ this.mergeWithDefault("markers_conf");
21
+
22
+ this.kml_options = {
23
+ clickable: true,
24
+ preserveViewport: false,
25
+ suppressInfoWindows: false
26
+ };
27
+
28
+ //Polygon Styling
29
+ this.polygons_conf = { // default style for polygons
30
+ strokeColor: "#FFAA00",
31
+ strokeOpacity: 0.8,
32
+ strokeWeight: 2,
33
+ fillColor: "#000000",
34
+ fillOpacity: 0.35
35
+ };
20
36
 
21
- //Polyline Styling
22
- Gmaps4Rails.polylines_conf = { //default style for polylines
23
- strokeColor: "#FF0000",
24
- strokeOpacity: 1,
25
- strokeWeight: 2
26
- };
37
+ //Polyline Styling
38
+ this.polylines_conf = { //default style for polylines
39
+ strokeColor: "#FF0000",
40
+ strokeOpacity: 1,
41
+ strokeWeight: 2
42
+ };
27
43
 
28
- //Circle Styling
29
- Gmaps4Rails.circles_conf = { //default style for circles
30
- fillColor: "#00AAFF",
31
- fillOpacity: 0.35,
32
- strokeColor: "#FFAA00",
33
- strokeOpacity: 0.8,
34
- strokeWeight: 2,
35
- clickable: false,
36
- zIndex: null
37
- };
44
+ //Circle Styling
45
+ this.circles_conf = { //default style for circles
46
+ fillColor: "#00AAFF",
47
+ fillOpacity: 0.35,
48
+ strokeColor: "#FFAA00",
49
+ strokeOpacity: 0.8,
50
+ strokeWeight: 2,
51
+ clickable: false,
52
+ zIndex: null
53
+ };
38
54
 
39
- //Direction Settings
40
- Gmaps4Rails.direction_conf = {
41
- panel_id: null,
42
- display_panel: false,
43
- origin: null,
44
- destination: null,
45
- waypoints: [], //[{location: "toulouse,fr", stopover: true}, {location: "Clermont-Ferrand, fr", stopover: true}]
46
- optimizeWaypoints: false,
47
- unitSystem: "METRIC", //IMPERIAL
48
- avoidHighways: false,
49
- avoidTolls: false,
50
- region: null,
51
- travelMode: "DRIVING" //WALKING, BICYCLING
52
- };
55
+ //Direction Settings
56
+ this.direction_conf = {
57
+ panel_id: null,
58
+ display_panel: false,
59
+ origin: null,
60
+ destination: null,
61
+ waypoints: [], //[{location: "toulouse,fr", stopover: true}, {location: "Clermont-Ferrand, fr", stopover: true}]
62
+ optimizeWaypoints: false,
63
+ unitSystem: "METRIC", //IMPERIAL
64
+ avoidHighways: false,
65
+ avoidTolls: false,
66
+ region: null,
67
+ travelMode: "DRIVING" //WALKING, BICYCLING
68
+ };
53
69
 
54
- ////////////////////////////////////////////////////
55
- /////////////// Basic Objects //////////////
56
- ////////////////////////////////////////////////////
70
+ ////////////////////////////////////////////////////
71
+ /////////////// Basic Objects //////////////
72
+ ////////////////////////////////////////////////////
57
73
 
58
- Gmaps4Rails.createPoint = function(lat, lng){
59
- return new google.maps.Point(lat, lng);
60
- };
74
+ this.createPoint = function(lat, lng){
75
+ return new google.maps.Point(lat, lng);
76
+ };
61
77
 
62
- Gmaps4Rails.createLatLng = function(lat, lng){
63
- return new google.maps.LatLng(lat, lng);
64
- };
78
+ this.createLatLng = function(lat, lng){
79
+ return new google.maps.LatLng(lat, lng);
80
+ };
65
81
 
66
- Gmaps4Rails.createLatLngBounds = function(){
67
- return new google.maps.LatLngBounds();
68
- };
82
+ this.createLatLngBounds = function(){
83
+ return new google.maps.LatLngBounds();
84
+ };
69
85
 
70
- Gmaps4Rails.createMap = function(){
71
- return new google.maps.Map(document.getElementById(Gmaps4Rails.map_options.id), {
72
- maxZoom: Gmaps4Rails.map_options.maxZoom,
73
- minZoom: Gmaps4Rails.map_options.minZoom,
74
- zoom: Gmaps4Rails.map_options.zoom,
75
- center: Gmaps4Rails.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude),
76
- mapTypeId: google.maps.MapTypeId[this.map_options.type],
77
- mapTypeControl: Gmaps4Rails.map_options.mapTypeControl,
78
- disableDefaultUI: Gmaps4Rails.map_options.disableDefaultUI,
79
- disableDoubleClickZoom: Gmaps4Rails.map_options.disableDoubleClickZoom,
80
- draggable: Gmaps4Rails.map_options.draggable
81
- });
82
- };
86
+ this.createMap = function(){
87
+ return new google.maps.Map(document.getElementById(this.map_options.id), {
88
+ maxZoom: this.map_options.maxZoom,
89
+ minZoom: this.map_options.minZoom,
90
+ zoom: this.map_options.zoom,
91
+ center: this.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude),
92
+ mapTypeId: google.maps.MapTypeId[this.map_options.type],
93
+ mapTypeControl: this.map_options.mapTypeControl,
94
+ disableDefaultUI: this.map_options.disableDefaultUI,
95
+ disableDoubleClickZoom: this.map_options.disableDoubleClickZoom,
96
+ draggable: this.map_options.draggable
97
+ });
98
+ };
83
99
 
84
- Gmaps4Rails.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
85
- return new google.maps.MarkerImage(markerPicture, markerSize, origin, anchor, scaledSize);
86
- };
100
+ this.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
101
+ return new google.maps.MarkerImage(markerPicture, markerSize, origin, anchor, scaledSize);
102
+ };
87
103
 
88
104
 
89
- Gmaps4Rails.createSize = function(width, height){
90
- return new google.maps.Size(width, height);
91
- };
105
+ this.createSize = function(width, height){
106
+ return new google.maps.Size(width, height);
107
+ };
92
108
 
93
- ////////////////////////////////////////////////////
94
- ////////////////////// Markers /////////////////////
95
- ////////////////////////////////////////////////////
96
-
97
- Gmaps4Rails.createMarker = function(args){
98
- var markerLatLng = Gmaps4Rails.createLatLng(args.Lat, args.Lng);
99
-
100
- // Marker sizes are expressed as a Size of X,Y
101
- if (args.marker_picture === "" && args.rich_marker === null) {
102
- return new google.maps.Marker({position: markerLatLng, map: Gmaps4Rails.map, title: args.marker_title, draggable: args.marker_draggable});
103
- }
104
- else if (args.rich_marker !== null){
105
- return new RichMarker({position: markerLatLng,
106
- map: Gmaps4Rails.map,
107
- draggable: args.marker_draggable,
108
- content: args.rich_marker,
109
- flat: args.marker_anchor === null ? false : args.marker_anchor[1],
110
- anchor: args.marker_anchor === null ? 0 : args.marker_anchor[0]
111
- });
112
- }
113
- else {
114
- // calculate MarkerImage anchor location
115
- var imageAnchorPosition = this.createImageAnchorPosition(args.marker_anchor);
116
- var shadowAnchorPosition = this.createImageAnchorPosition(args.shadow_anchor);
117
-
118
- //create or retrieve existing MarkerImages
119
- var markerImage = this.createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition);
120
- var shadowImage = this.createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition);
121
- return new google.maps.Marker({position: markerLatLng, map: this.map, icon: markerImage, title: args.marker_title, draggable: args.marker_draggable, shadow: shadowImage});
122
- }
123
- };
109
+ ////////////////////////////////////////////////////
110
+ ////////////////////// Markers /////////////////////
111
+ ////////////////////////////////////////////////////
112
+
113
+ this.createMarker = function(args){
114
+ var markerLatLng = this.createLatLng(args.Lat, args.Lng);
115
+
116
+ // Marker sizes are expressed as a Size of X,Y
117
+ if (args.marker_picture === "" && args.rich_marker === null) {
118
+ return new google.maps.Marker({position: markerLatLng, map: this.map, title: args.marker_title, draggable: args.marker_draggable});
119
+ }
120
+ else if (args.rich_marker !== null){
121
+ return new RichMarker({position: markerLatLng,
122
+ map: this.map,
123
+ draggable: args.marker_draggable,
124
+ content: args.rich_marker,
125
+ flat: args.marker_anchor === null ? false : args.marker_anchor[1],
126
+ anchor: args.marker_anchor === null ? 0 : args.marker_anchor[0]
127
+ });
128
+ }
129
+ else {
130
+ // calculate MarkerImage anchor location
131
+ var imageAnchorPosition = this.createImageAnchorPosition(args.marker_anchor);
132
+ var shadowAnchorPosition = this.createImageAnchorPosition(args.shadow_anchor);
133
+
134
+ //create or retrieve existing MarkerImages
135
+ var markerImage = this.createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition);
136
+ var shadowImage = this.createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition);
137
+ return new google.maps.Marker({position: markerLatLng, map: this.map, icon: markerImage, title: args.marker_title, draggable: args.marker_draggable, shadow: shadowImage});
138
+ }
139
+ };
124
140
 
125
- //checks if obj is included in arr Array and returns the position or false
126
- Gmaps4Rails.includeMarkerImage = function(arr, obj) {
127
- for(var i=0; i<arr.length; i++) {
128
- if (arr[i].url == obj) {return i;}
129
- }
130
- return false;
131
- };
141
+ //checks if obj is included in arr Array and returns the position or false
142
+ this.includeMarkerImage = function(arr, obj) {
143
+ for(var i=0; i<arr.length; i++) {
144
+ if (arr[i].url == obj) {return i;}
145
+ }
146
+ return false;
147
+ };
132
148
 
133
- // checks if MarkerImage exists before creating a new one
134
- // returns a MarkerImage or false if ever something wrong is passed as argument
135
- Gmaps4Rails.createOrRetrieveImage = function(currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition){
136
- if (currentMarkerPicture === "" || currentMarkerPicture === null )
137
- { return null;}
138
-
139
- var test_image_index = this.includeMarkerImage(this.markerImages, currentMarkerPicture);
140
- switch (test_image_index)
141
- {
142
- case false:
143
- var markerImage = Gmaps4Rails.createMarkerImage(currentMarkerPicture, Gmaps4Rails.createSize(markerWidth, markerHeight), null, imageAnchorPosition, null );
144
- this.markerImages.push(markerImage);
145
- return markerImage;
146
- break;
147
- default:
148
- if (typeof test_image_index == 'number') { return this.markerImages[test_image_index]; }
149
- else { return false; }
150
- break;
151
- }
152
- };
149
+ // checks if MarkerImage exists before creating a new one
150
+ // returns a MarkerImage or false if ever something wrong is passed as argument
151
+ this.createOrRetrieveImage = function(currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition){
152
+ if (currentMarkerPicture === "" || currentMarkerPicture === null )
153
+ { return null;}
154
+
155
+ var test_image_index = this.includeMarkerImage(this.markerImages, currentMarkerPicture);
156
+ switch (test_image_index)
157
+ {
158
+ case false:
159
+ var markerImage = this.createMarkerImage(currentMarkerPicture, this.createSize(markerWidth, markerHeight), null, imageAnchorPosition, null );
160
+ this.markerImages.push(markerImage);
161
+ return markerImage;
162
+ break;
163
+ default:
164
+ if (typeof test_image_index == 'number') { return this.markerImages[test_image_index]; }
165
+ else { return false; }
166
+ break;
167
+ }
168
+ };
153
169
 
154
- // clear markers
155
- Gmaps4Rails.clearMarkers = function() {
156
- for (var i = 0; i < this.markers.length; ++i) {
157
- this.clearMarker(this.markers[i]);
158
- }
159
- };
170
+ // clear markers
171
+ this.clearMarkers = function() {
172
+ for (var i = 0; i < this.markers.length; ++i) {
173
+ this.clearMarker(this.markers[i]);
174
+ }
175
+ };
160
176
 
161
- //show and hide markers
162
- Gmaps4Rails.showMarkers = function() {
163
- for (var i = 0; i < this.markers.length; ++i) {
164
- this.showMarker(this.markers[i]);
165
- }
166
- };
177
+ //show and hide markers
178
+ this.showMarkers = function() {
179
+ for (var i = 0; i < this.markers.length; ++i) {
180
+ this.showMarker(this.markers[i]);
181
+ }
182
+ };
167
183
 
168
- Gmaps4Rails.hideMarkers = function() {
169
- for (var i = 0; i < this.markers.length; ++i) {
170
- this.hideMarker(this.markers[i]);
171
- }
172
- };
184
+ this.hideMarkers = function() {
185
+ for (var i = 0; i < this.markers.length; ++i) {
186
+ this.hideMarker(this.markers[i]);
187
+ }
188
+ };
173
189
 
174
- Gmaps4Rails.clearMarker = function(marker) {
175
- marker.serviceObject.setMap(null);
176
- };
190
+ this.clearMarker = function(marker) {
191
+ marker.serviceObject.setMap(null);
192
+ };
177
193
 
178
- Gmaps4Rails.showMarker = function(marker) {
179
- marker.serviceObject.setVisible(true);
180
- };
194
+ this.showMarker = function(marker) {
195
+ marker.serviceObject.setVisible(true);
196
+ };
181
197
 
182
- Gmaps4Rails.hideMarker = function(marker) {
183
- marker.serviceObject.setVisible(false);
184
- };
198
+ this.hideMarker = function(marker) {
199
+ marker.serviceObject.setVisible(false);
200
+ };
185
201
 
186
- Gmaps4Rails.extendBoundsWithMarkers = function(){
187
- for (var i = 0; i < Gmaps4Rails.markers.length; ++i) {
188
- Gmaps4Rails.boundsObject.extend(Gmaps4Rails.markers[i].serviceObject.position);
189
- }
190
- };
202
+ this.extendBoundsWithMarkers = function(){
203
+ for (var i = 0; i < this.markers.length; ++i) {
204
+ this.boundsObject.extend(this.markers[i].serviceObject.position);
205
+ }
206
+ };
191
207
 
192
- ////////////////////////////////////////////////////
193
- /////////////////// Clusterer //////////////////////
194
- ////////////////////////////////////////////////////
208
+ ////////////////////////////////////////////////////
209
+ /////////////////// Clusterer //////////////////////
210
+ ////////////////////////////////////////////////////
195
211
 
196
- Gmaps4Rails.createClusterer = function(markers_array){
197
- return new MarkerClusterer( Gmaps4Rails.map,
198
- markers_array,
199
- { maxZoom: Gmaps4Rails.markers_conf.clusterer_maxZoom, gridSize: Gmaps4Rails.markers_conf.clusterer_gridSize, styles: Gmaps4Rails.customClusterer() }
200
- );
201
- };
212
+ this.createClusterer = function(markers_array){
213
+ return new MarkerClusterer( this.map,
214
+ markers_array,
215
+ { maxZoom: this.markers_conf.clusterer_maxZoom, gridSize: this.markers_conf.clusterer_gridSize, styles: this.customClusterer() }
216
+ );
217
+ };
202
218
 
203
- Gmaps4Rails.clearClusterer = function() {
204
- this.markerClusterer.clearMarkers();
205
- };
219
+ this.clearClusterer = function() {
220
+ this.markerClusterer.clearMarkers();
221
+ };
206
222
 
207
- //creates clusters
208
- Gmaps4Rails.clusterize = function()
209
- {
210
- if (this.markers_conf.do_clustering === true)
223
+ //creates clusters
224
+ this.clusterize = function()
211
225
  {
212
- //first clear the existing clusterer if any
213
- if (this.markerClusterer !== null) {
214
- this.clearClusterer();
215
- }
216
-
217
- var markers_array = new Array;
218
- for (var i = 0; i < this.markers.length; ++i) {
219
- markers_array.push(this.markers[i].serviceObject);
226
+ if (this.markers_conf.do_clustering === true)
227
+ {
228
+ //first clear the existing clusterer if any
229
+ if (this.markerClusterer !== null) {
230
+ this.clearClusterer();
231
+ }
232
+
233
+ var markers_array = new Array;
234
+ for (var i = 0; i < this.markers.length; ++i) {
235
+ markers_array.push(this.markers[i].serviceObject);
236
+ }
237
+
238
+ this.markerClusterer = this.createClusterer(markers_array);
220
239
  }
240
+ };
221
241
 
222
- this.markerClusterer = Gmaps4Rails.createClusterer(markers_array);
223
- }
224
- };
225
-
226
- ////////////////////////////////////////////////////
227
- /////////////////// INFO WINDOW ////////////////////
228
- ////////////////////////////////////////////////////
229
-
230
- // creates infowindows
231
- Gmaps4Rails.createInfoWindow = function(marker_container){
232
- var info_window;
233
- if (this.markers_conf.custom_infowindow_class === null && Gmaps4Rails.exists(marker_container.description)) {
234
- //create the infowindow
235
- info_window = new google.maps.InfoWindow({content: marker_container.description });
236
- //add the listener associated
237
- google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(info_window, marker_container.serviceObject));
238
- }
239
- else { //creating custom infowindow
240
- if (this.exists(marker_container.description)) {
241
- var boxText = document.createElement("div");
242
- boxText.setAttribute("class", this.markers_conf.custom_infowindow_class); //to customize
243
- boxText.innerHTML = marker_container.description;
244
- info_window = new InfoBox(Gmaps4Rails.infobox(boxText));
242
+ ////////////////////////////////////////////////////
243
+ /////////////////// INFO WINDOW ////////////////////
244
+ ////////////////////////////////////////////////////
245
+
246
+ // creates infowindows
247
+ this.createInfoWindow = function(marker_container){
248
+ var info_window;
249
+ if (this.markers_conf.custom_infowindow_class === null && this.exists(marker_container.description)) {
250
+ //create the infowindow
251
+ info_window = new google.maps.InfoWindow({content: marker_container.description });
252
+ //add the listener associated
245
253
  google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(info_window, marker_container.serviceObject));
246
254
  }
247
- }
248
- };
249
-
250
- Gmaps4Rails.openInfoWindow = function(infoWindow, marker) {
251
- return function() {
252
- // Close the latest selected marker before opening the current one.
253
- if (Gmaps4Rails.visibleInfoWindow) {
254
- Gmaps4Rails.visibleInfoWindow.close();
255
+ else { //creating custom infowindow
256
+ if (this.exists(marker_container.description)) {
257
+ var boxText = document.createElement("div");
258
+ boxText.setAttribute("class", this.markers_conf.custom_infowindow_class); //to customize
259
+ boxText.innerHTML = marker_container.description;
260
+ info_window = new InfoBox(this.infobox(boxText));
261
+ google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(info_window, marker_container.serviceObject));
262
+ }
255
263
  }
264
+ };
265
+
266
+ this.openInfoWindow = function(infoWindow, marker) {
267
+ return function() {
268
+ // Close the latest selected marker before opening the current one.
269
+ if (this.visibleInfoWindow) {
270
+ this.visibleInfoWindow.close();
271
+ }
256
272
 
257
- infoWindow.open(Gmaps4Rails.map, marker);
258
- Gmaps4Rails.visibleInfoWindow = infoWindow;
273
+ infoWindow.open(this.map, marker);
274
+ this.visibleInfoWindow = infoWindow;
275
+ };
276
+ };
277
+
278
+ ////////////////////////////////////////////////////
279
+ ///////////////// KML //////////////////
280
+ ////////////////////////////////////////////////////
281
+
282
+ this.createKmlLayer = function(kml){
283
+ var kml_options = kml.options || {};
284
+ kml_options = this.mergeObjectWithDefault(kml_options, this.kml_options);
285
+ var kml = new google.maps.KmlLayer( kml.url,
286
+ kml_options
287
+ );
288
+ kml.setMap(this.map);
289
+ return kml;
259
290
  };
260
- };
261
291
 
262
- ////////////////////////////////////////////////////
263
- /////////////////// Other methods //////////////////
264
- ////////////////////////////////////////////////////
265
292
 
266
- Gmaps4Rails.fitBounds = function(){
267
- this.map.fitBounds(this.boundsObject);
293
+ ////////////////////////////////////////////////////
294
+ /////////////////// Other methods //////////////////
295
+ ////////////////////////////////////////////////////
296
+
297
+ this.fitBounds = function(){
298
+ this.map.fitBounds(this.boundsObject);
299
+ };
300
+
301
+ this.centerMapOnUser = function(){
302
+ this.map.setCenter(this.userLocation);
303
+ };
268
304
  };
269
305
 
270
- Gmaps4Rails.centerMapOnUser = function(){
271
- Gmaps4Rails.map.setCenter(Gmaps4Rails.userLocation);
272
- };
306
+ Gmaps4RailsGoogle.prototype = new Gmaps4Rails();