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,195 +1,206 @@
1
- Gmaps4Rails.map_options.type = "road"; // aerial, auto, birdseye, collinsBart, mercator, ordnanceSurvey, road
2
- Gmaps4Rails.markers_conf.infobox = "description"; // description or htmlContent
3
-
4
- ////////////////////////////////////////////////////
5
- /////////////// Basic Objects //////////////
6
- ////////////////////////////////////////////////////
7
-
8
- Gmaps4Rails.getMapType = function(){
9
- switch(Gmaps4Rails.map_options.type)
10
- {
11
- case "road":
12
- return Microsoft.Maps.MapTypeId.road;
13
- case "aerial":
14
- return Microsoft.Maps.MapTypeId.aerial;
15
- case "auto":
16
- return Microsoft.Maps.MapTypeId.auto;
17
- case "birdseye":
18
- return Microsoft.Maps.MapTypeId.birdseye;
19
- case "collinsBart":
20
- return Microsoft.Maps.MapTypeId.collinsBart;
21
- case "mercator":
22
- return Microsoft.Maps.MapTypeId.mercator;
23
- case "ordnanceSurvey":
24
- return Microsoft.Maps.MapTypeId.ordnanceSurvey;
25
- default:
26
- return Microsoft.Maps.MapTypeId.auto;
27
- }
28
- };
29
-
30
- Gmaps4Rails.createPoint = function(lat, lng){
31
- return new Microsoft.Maps.Point(lat, lng);
32
- };
33
-
34
- Gmaps4Rails.createLatLng = function(lat, lng){
35
- return new Microsoft.Maps.Location(lat, lng);
36
- };
37
-
38
- Gmaps4Rails.createLatLngBounds = function(){
39
-
40
- };
41
-
42
- Gmaps4Rails.createMap = function(){
43
- return new Microsoft.Maps.Map(document.getElementById(Gmaps4Rails.map_options.id), {
44
- credentials: Gmaps4Rails.map_options.provider_key,
45
- mapTypeId: Gmaps4Rails.getMapType(),
46
- center: Gmaps4Rails.createLatLng(Gmaps4Rails.map_options.center_latitude, Gmaps4Rails.map_options.center_longitude),
47
- zoom: Gmaps4Rails.map_options.zoom
48
- });
49
- };
50
-
51
- Gmaps4Rails.createSize = function(width, height){
52
- return new google.maps.Size(width, height);
53
- };
54
-
55
- ////////////////////////////////////////////////////
56
- ////////////////////// Markers /////////////////////
57
- ////////////////////////////////////////////////////
58
-
59
- Gmaps4Rails.createMarker = function(args){
60
- var markerLatLng = Gmaps4Rails.createLatLng(args.Lat, args.Lng);
61
- var marker;
62
- // Marker sizes are expressed as a Size of X,Y
63
- if (args.marker_picture === "" ) {
64
- marker = new Microsoft.Maps.Pushpin(Gmaps4Rails.createLatLng(args.Lat, args.Lng), {
65
- draggable: args.marker_draggable,
66
- anchor: Gmaps4Rails.createImageAnchorPosition(args.Lat, args.Lng),
67
- text: args.marker_title
68
- }
69
- );
70
- } else {
71
- marker = new Microsoft.Maps.Pushpin(Gmaps4Rails.createLatLng(args.Lat, args.Lng), {
72
- draggable: args.marker_draggable,
73
- anchor: Gmaps4Rails.createImageAnchorPosition(args.Lat, args.Lng),
74
- icon: args.marker_picture,
75
- height: args.marker_height,
76
- text: args.marker_title,
77
- width: args.marker_width
1
+ var Gmaps4RailsBing = function() {
2
+
3
+ this.map_options = {
4
+ type: "road" // aerial, auto, birdseye, collinsBart, mercator, ordnanceSurvey, road
5
+ };
6
+ this.markers_conf = {
7
+ infobox: "description" // description or htmlContent
8
+ };
9
+
10
+ this.mergeWithDefault("map_options");
11
+ this.mergeWithDefault("markers_conf");
12
+
13
+ ////////////////////////////////////////////////////
14
+ /////////////// Basic Objects //////////////
15
+ ////////////////////////////////////////////////////
16
+
17
+ this.getMapType = function(){
18
+ switch(this.map_options.type)
19
+ {
20
+ case "road":
21
+ return Microsoft.Maps.MapTypeId.road;
22
+ case "aerial":
23
+ return Microsoft.Maps.MapTypeId.aerial;
24
+ case "auto":
25
+ return Microsoft.Maps.MapTypeId.auto;
26
+ case "birdseye":
27
+ return Microsoft.Maps.MapTypeId.birdseye;
28
+ case "collinsBart":
29
+ return Microsoft.Maps.MapTypeId.collinsBart;
30
+ case "mercator":
31
+ return Microsoft.Maps.MapTypeId.mercator;
32
+ case "ordnanceSurvey":
33
+ return Microsoft.Maps.MapTypeId.ordnanceSurvey;
34
+ default:
35
+ return Microsoft.Maps.MapTypeId.auto;
36
+ }
37
+ };
38
+
39
+ this.createPoint = function(lat, lng){
40
+ return new Microsoft.Maps.Point(lat, lng);
41
+ };
42
+
43
+ this.createLatLng = function(lat, lng){
44
+ return new Microsoft.Maps.Location(lat, lng);
45
+ };
46
+
47
+ this.createLatLngBounds = function(){
48
+
49
+ };
50
+
51
+ this.createMap = function(){
52
+ return new Microsoft.Maps.Map(document.getElementById(this.map_options.id), {
53
+ credentials: this.map_options.provider_key,
54
+ mapTypeId: this.getMapType(),
55
+ center: this.createLatLng(this.map_options.center_latitude, this.map_options.center_longitude),
56
+ zoom: this.map_options.zoom
57
+ });
58
+ };
59
+
60
+ this.createSize = function(width, height){
61
+ return new google.maps.Size(width, height);
62
+ };
63
+
64
+ ////////////////////////////////////////////////////
65
+ ////////////////////// Markers /////////////////////
66
+ ////////////////////////////////////////////////////
67
+
68
+ this.createMarker = function(args){
69
+ var markerLatLng = this.createLatLng(args.Lat, args.Lng);
70
+ var marker;
71
+ // Marker sizes are expressed as a Size of X,Y
72
+ if (args.marker_picture === "" ) {
73
+ marker = new Microsoft.Maps.Pushpin(this.createLatLng(args.Lat, args.Lng), {
74
+ draggable: args.marker_draggable,
75
+ anchor: this.createImageAnchorPosition(args.Lat, args.Lng),
76
+ text: args.marker_title
77
+ }
78
+ );
79
+ } else {
80
+ marker = new Microsoft.Maps.Pushpin(this.createLatLng(args.Lat, args.Lng), {
81
+ draggable: args.marker_draggable,
82
+ anchor: this.createImageAnchorPosition(args.Lat, args.Lng),
83
+ icon: args.marker_picture,
84
+ height: args.marker_height,
85
+ text: args.marker_title,
86
+ width: args.marker_width
87
+ }
88
+ );
78
89
  }
79
- );
80
- }
81
- Gmaps4Rails.addToMap(marker);
82
- return marker;
83
- };
90
+ this.addToMap(marker);
91
+ return marker;
92
+ };
93
+
94
+ // clear markers
95
+ this.clearMarkers = function() {
96
+ for (var i = 0; i < this.markers.length; ++i) {
97
+ this.clearMarker(this.markers[i]);
98
+ }
99
+ };
84
100
 
85
- // clear markers
86
- Gmaps4Rails.clearMarkers = function() {
87
- for (var i = 0; i < this.markers.length; ++i) {
88
- this.clearMarker(this.markers[i]);
89
- }
90
- };
101
+ this.clearMarker = function(marker) {
102
+ this.removeFromMap(marker.serviceObject);
103
+ };
91
104
 
92
- Gmaps4Rails.clearMarker = function(marker) {
93
- this.removeFromMap(marker.serviceObject);
94
- };
105
+ //show and hide markers
106
+ this.showMarkers = function() {
107
+ for (var i = 0; i < this.markers.length; ++i) {
108
+ this.showMarker(this.markers[i]);
109
+ }
110
+ };
95
111
 
96
- //show and hide markers
97
- Gmaps4Rails.showMarkers = function() {
98
- for (var i = 0; i < this.markers.length; ++i) {
99
- this.showMarker(this.markers[i]);
100
- }
101
- };
112
+ this.showMarker = function(marker) {
113
+ marker.serviceObject.setOptions({ visible: true });
114
+ };
102
115
 
103
- Gmaps4Rails.showMarker = function(marker) {
104
- marker.serviceObject.setOptions({ visible: true });
105
- };
116
+ this.hideMarkers = function() {
117
+ for (var i = 0; i < this.markers.length; ++i) {
118
+ this.hideMarker(this.markers[i]);
119
+ }
120
+ };
106
121
 
107
- Gmaps4Rails.hideMarkers = function() {
108
- for (var i = 0; i < this.markers.length; ++i) {
109
- this.hideMarker(this.markers[i]);
110
- }
111
- };
122
+ this.hideMarker = function(marker) {
123
+ marker.serviceObject.setOptions({ visible: false });
124
+ };
112
125
 
113
- Gmaps4Rails.hideMarker = function(marker) {
114
- marker.serviceObject.setOptions({ visible: false });
115
- };
126
+ this.extendBoundsWithMarkers = function(){
127
+ var locationsArray = [];
128
+ for (var i = 0; i < this.markers.length; ++i) {
129
+ locationsArray.push(this.markers[i].serviceObject.getLocation());
130
+ }
131
+ this.boundsObject = Microsoft.Maps.LocationRect.fromLocations(locationsArray);
132
+ };
116
133
 
117
- Gmaps4Rails.extendBoundsWithMarkers = function(){
118
- var locationsArray = [];
119
- for (var i = 0; i < this.markers.length; ++i) {
120
- locationsArray.push(Gmaps4Rails.markers[i].serviceObject.getLocation());
121
- }
122
- Gmaps4Rails.boundsObject = Microsoft.Maps.LocationRect.fromLocations(locationsArray);
123
- };
124
134
 
135
+ ////////////////////////////////////////////////////
136
+ /////////////////// Clusterer //////////////////////
137
+ ////////////////////////////////////////////////////
125
138
 
126
- ////////////////////////////////////////////////////
127
- /////////////////// Clusterer //////////////////////
128
- ////////////////////////////////////////////////////
139
+ this.createClusterer = function(markers_array){
129
140
 
130
- Gmaps4Rails.createClusterer = function(markers_array){
141
+ };
131
142
 
132
- };
143
+ this.clearClusterer = function() {
144
+ };
133
145
 
134
- Gmaps4Rails.clearClusterer = function() {
135
- };
146
+ //creates clusters
147
+ this.clusterize = function()
148
+ {
136
149
 
137
- //creates clusters
138
- Gmaps4Rails.clusterize = function()
139
- {
150
+ };
140
151
 
141
- };
152
+ ////////////////////////////////////////////////////
153
+ /////////////////// INFO WINDOW ////////////////////
154
+ ////////////////////////////////////////////////////
142
155
 
143
- ////////////////////////////////////////////////////
144
- /////////////////// INFO WINDOW ////////////////////
145
- ////////////////////////////////////////////////////
146
-
147
- // creates infowindows
148
- Gmaps4Rails.createInfoWindow = function(marker_container){
149
- var info_window;
150
- if (Gmaps4Rails.exists(marker_container.description)) {
151
- //create the infowindow
152
- if (Gmaps4Rails.markers_conf.infobox == "description") {
153
- marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), { description: marker_container.description, visible: false, showCloseButton: true});
154
- }
155
- else {
156
- marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), { htmlContent: marker_container.description, visible: false});
157
- }
156
+ // creates infowindows
157
+ this.createInfoWindow = function(marker_container){
158
+ var info_window;
159
+ if (this.exists(marker_container.description)) {
160
+ //create the infowindow
161
+ if (this.markers_conf.infobox === "description") {
162
+ marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), { description: marker_container.description, visible: false, showCloseButton: true});
163
+ }
164
+ else {
165
+ marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), { htmlContent: marker_container.description, visible: false});
166
+ }
158
167
 
159
- //add the listener associated
160
- Microsoft.Maps.Events.addHandler(marker_container.serviceObject, 'click', Gmaps4Rails.openInfoWindow(marker_container.info_window));
161
- Gmaps4Rails.addToMap(marker_container.info_window);
162
- }
163
- };
168
+ //add the listener associated
169
+ Microsoft.Maps.Events.addHandler(marker_container.serviceObject, 'click', this.openInfoWindow(marker_container.info_window));
170
+ this.addToMap(marker_container.info_window);
171
+ }
172
+ };
164
173
 
165
- Gmaps4Rails.openInfoWindow = function(infoWindow) {
166
- return function() {
167
- // Close the latest selected marker before opening the current one.
168
- if (Gmaps4Rails.visibleInfoWindow) {
169
- Gmaps4Rails.visibleInfoWindow.setOptions({ visible: false });
170
- }
171
- infoWindow.setOptions({ visible:true });
172
- Gmaps4Rails.visibleInfoWindow = infoWindow;
173
- };
174
- };
174
+ this.openInfoWindow = function(infoWindow) {
175
+ return function() {
176
+ // Close the latest selected marker before opening the current one.
177
+ if (this.visibleInfoWindow) {
178
+ this.visibleInfoWindow.setOptions({ visible: false });
179
+ }
180
+ infoWindow.setOptions({ visible:true });
181
+ this.visibleInfoWindow = infoWindow;
182
+ };
183
+ };
175
184
 
176
- ////////////////////////////////////////////////////
177
- /////////////////// Other methods //////////////////
178
- ////////////////////////////////////////////////////
185
+ ////////////////////////////////////////////////////
186
+ /////////////////// Other methods //////////////////
187
+ ////////////////////////////////////////////////////
179
188
 
180
- Gmaps4Rails.fitBounds = function(){
181
- Gmaps4Rails.map.setView({bounds: Gmaps4Rails.boundsObject});
182
- };
189
+ this.fitBounds = function(){
190
+ this.map.setView({bounds: this.boundsObject});
191
+ };
183
192
 
184
- Gmaps4Rails.addToMap = function(object){
185
- Gmaps4Rails.map.entities.push(object);
186
- };
193
+ this.addToMap = function(object){
194
+ this.map.entities.push(object);
195
+ };
196
+
197
+ this.removeFromMap = function(object){
198
+ this.map.entities.remove(object);
199
+ };
187
200
 
188
- Gmaps4Rails.removeFromMap = function(object){
189
- console.log(object);
190
- Gmaps4Rails.map.entities.remove(object);
201
+ this.centerMapOnUser = function(){
202
+ this.map.setView({ center: this.userLocation});
203
+ };
191
204
  };
192
205
 
193
- Gmaps4Rails.centerMapOnUser = function(){
194
- Gmaps4Rails.map.setView({ center: Gmaps4Rails.userLocation});
195
- };
206
+ Gmaps4RailsBing.prototype = new Gmaps4Rails();