gmaps4rails 0.11.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,172 +1,182 @@
1
- // http://www.mapquestapi.com/sdk/js/v6.0.0/poi.html
1
+ var Gmaps4RailsMapquest = function() {
2
2
 
3
- //Map settings
4
- Gmaps4Rails.map_options.type = "map"; // //map type (map, sat, hyb)
3
+ // http://www.mapquestapi.com/sdk/js/v6.0.0/poi.html
5
4
 
5
+ //Map settings
6
+ this.map_options = {
7
+ type: "map" // //map type (map, sat, hyb)
8
+ };
9
+ this.markers_conf = {};
6
10
 
7
- ////////////////////////////////////////////////////
8
- /////////////// Basic Objects //////////////
9
- ////////////////////////////////////////////////////
11
+ this.mergeWithDefault("markers_conf");
12
+ this.mergeWithDefault("map_options");
10
13
 
11
- Gmaps4Rails.createPoint = function(lat, lng){
12
- return new MQA.Poi({lat: lat, lng: lng});
13
- };
14
+ ////////////////////////////////////////////////////
15
+ /////////////// Basic Objects //////////////
16
+ ////////////////////////////////////////////////////
14
17
 
15
- Gmaps4Rails.createLatLng = function(lat, lng){
16
- return {lat: lat, lng: lng};
17
- };
18
+ this.createPoint = function(lat, lng){
19
+ return new MQA.Poi({lat: lat, lng: lng});
20
+ };
18
21
 
19
- Gmaps4Rails.createLatLngBounds = function(){
20
- };
22
+ this.createLatLng = function(lat, lng){
23
+ return {lat: lat, lng: lng};
24
+ };
21
25
 
26
+ this.createLatLngBounds = function(){
27
+ };
22
28
 
23
- Gmaps4Rails.createMap = function(){
24
- var map = new MQA.TileMap( // Constructs an instance of MQA.TileMap
25
- document.getElementById("mapQuest"), //the id of the element on the page you want the map to be added into
26
- Gmaps4Rails.map_options.zoom, //intial zoom level of the map
27
- {lat: Gmaps4Rails.map_options.center_latitude, //the lat/lng of the map to center on
28
- lng: Gmaps4Rails.map_options.center_longitude},
29
- Gmaps4Rails.map_options.type); //map type (map, sat, hyb)
30
- MQA.withModule('zoomcontrol3', function() {
31
29
 
32
- map.addControl(
33
- new MQA.LargeZoomControl3(),
34
- new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT)
35
- );
30
+ this.createMap = function(){
31
+ var map = new MQA.TileMap( // Constructs an instance of MQA.TileMap
32
+ document.getElementById(this.map_options.id), //the id of the element on the page you want the map to be added into
33
+ this.map_options.zoom, //intial zoom level of the map
34
+ {lat: this.map_options.center_latitude, //the lat/lng of the map to center on
35
+ lng: this.map_options.center_longitude},
36
+ this.map_options.type); //map type (map, sat, hyb)
37
+ MQA.withModule('zoomcontrol3', function() {
36
38
 
37
- });
38
- return map;
39
- };
39
+ map.addControl(
40
+ new MQA.LargeZoomControl3(),
41
+ new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT)
42
+ );
40
43
 
41
- Gmaps4Rails.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
44
+ });
45
+ return map;
46
+ };
42
47
 
43
- };
48
+ this.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
44
49
 
50
+ };
45
51
 
46
- ////////////////////////////////////////////////////
47
- ////////////////////// Markers /////////////////////
48
- ////////////////////////////////////////////////////
49
52
 
50
- Gmaps4Rails.createMarker = function(args){
53
+ ////////////////////////////////////////////////////
54
+ ////////////////////// Markers /////////////////////
55
+ ////////////////////////////////////////////////////
56
+
57
+ this.createMarker = function(args){
51
58
 
52
- var marker = new MQA.Poi( {lat: args.Lat, lng: args.Lng} );
59
+ var marker = new MQA.Poi( {lat: args.Lat, lng: args.Lng} );
53
60
 
54
- if (args.marker_picture !== "" ) {
55
- var icon = new MQA.Icon(args.marker_picture, args.marker_height, args.marker_width);
56
- marker.setIcon(icon);
57
- if(args.marker_anchor !== null) {
58
- marker.setBias({x: args.marker_anchor[0], y: args.marker_anchor[1]});
61
+ if (args.marker_picture !== "" ) {
62
+ var icon = new MQA.Icon(args.marker_picture, args.marker_height, args.marker_width);
63
+ marker.setIcon(icon);
64
+ if(args.marker_anchor !== null) {
65
+ marker.setBias({x: args.marker_anchor[0], y: args.marker_anchor[1]});
66
+ }
59
67
  }
60
- }
61
68
 
62
- if (args.shadow_picture !== "" ) {
63
- var icon = new MQA.Icon(args.shadow_picture, args.shadow_height, args.shadow_width);
64
- marker.setShadow(icon);
69
+ if (args.shadow_picture !== "" ) {
70
+ var icon = new MQA.Icon(args.shadow_picture, args.shadow_height, args.shadow_width);
71
+ marker.setShadow(icon);
65
72
 
66
- if(args.shadow_anchor !== null) {
67
- marker.setShadowOffset({x: args.shadow_anchor[0], y: args.shadow_anchor[1]});
68
- }
69
- }
73
+ if(args.shadow_anchor !== null) {
74
+ marker.setShadowOffset({x: args.shadow_anchor[0], y: args.shadow_anchor[1]});
75
+ }
76
+ }
70
77
 
71
- Gmaps4Rails.addToMap(marker);
72
- return marker;
73
- };
78
+ this.addToMap(marker);
79
+ return marker;
80
+ };
74
81
 
75
82
 
76
- // clear markers
77
- Gmaps4Rails.clearMarkers = function() {
78
- for (var i = 0; i < this.markers.length; ++i) {
79
- this.clearMarker(this.markers[i]);
80
- }
81
- };
83
+ // clear markers
84
+ this.clearMarkers = function() {
85
+ for (var i = 0; i < this.markers.length; ++i) {
86
+ this.clearMarker(this.markers[i]);
87
+ }
88
+ };
82
89
 
83
- //show and hide markers
84
- Gmaps4Rails.showMarkers = function() {
85
- for (var i = 0; i < this.markers.length; ++i) {
86
- this.showMarker(this.markers[i]);
87
- }
88
- };
90
+ //show and hide markers
91
+ this.showMarkers = function() {
92
+ for (var i = 0; i < this.markers.length; ++i) {
93
+ this.showMarker(this.markers[i]);
94
+ }
95
+ };
89
96
 
90
- Gmaps4Rails.hideMarkers = function() {
91
- for (var i = 0; i < this.markers.length; ++i) {
92
- this.hideMarker(this.markers[i]);
93
- }
94
- };
97
+ this.hideMarkers = function() {
98
+ for (var i = 0; i < this.markers.length; ++i) {
99
+ this.hideMarker(this.markers[i]);
100
+ }
101
+ };
95
102
 
96
- Gmaps4Rails.clearMarker = function(marker) {
97
- this.removeFromMap(marker.serviceObject);
98
- };
103
+ this.clearMarker = function(marker) {
104
+ this.removeFromMap(marker.serviceObject);
105
+ };
99
106
 
100
- Gmaps4Rails.showMarker = function(marker) {
101
- // marker.serviceObject
102
- };
107
+ this.showMarker = function(marker) {
108
+ // marker.serviceObject
109
+ };
103
110
 
104
- Gmaps4Rails.hideMarker = function(marker) {
105
- // marker.serviceObject
106
- };
111
+ this.hideMarker = function(marker) {
112
+ // marker.serviceObject
113
+ };
107
114
 
108
- Gmaps4Rails.extendBoundsWithMarkers = function(){
115
+ this.extendBoundsWithMarkers = function(){
109
116
 
110
- if (Gmaps4Rails.markers.length >=2) {
111
- Gmaps4Rails.boundsObject = new MQA.RectLL(Gmaps4Rails.markers[0].serviceObject.latLng, Gmaps4Rails.markers[1].serviceObject.latLng);
117
+ if (this.markers.length >=2) {
118
+ this.boundsObject = new MQA.RectLL(this.markers[0].serviceObject.latLng, this.markers[1].serviceObject.latLng);
112
119
 
113
- for (var i = 2; i < Gmaps4Rails.markers.length; ++i) {
114
- Gmaps4Rails.boundsObject.extend(Gmaps4Rails.markers[i].serviceObject.latLng);
120
+ for (var i = 2; i < this.markers.length; ++i) {
121
+ this.boundsObject.extend(this.markers[i].serviceObject.latLng);
122
+ }
115
123
  }
116
- }
117
124
 
118
- };
125
+ };
119
126
 
120
- ////////////////////////////////////////////////////
121
- /////////////////// Clusterer //////////////////////
122
- ////////////////////////////////////////////////////
127
+ ////////////////////////////////////////////////////
128
+ /////////////////// Clusterer //////////////////////
129
+ ////////////////////////////////////////////////////
123
130
 
124
- Gmaps4Rails.createClusterer = function(markers_array){
131
+ this.createClusterer = function(markers_array){
125
132
 
126
- };
133
+ };
127
134
 
128
- Gmaps4Rails.clearClusterer = function() {
135
+ this.clearClusterer = function() {
129
136
 
130
- };
137
+ };
131
138
 
132
- //creates clusters
133
- Gmaps4Rails.clusterize = function()
134
- {
139
+ //creates clusters
140
+ this.clusterize = function()
141
+ {
135
142
 
136
- };
143
+ };
137
144
 
138
- ////////////////////////////////////////////////////
139
- /////////////////// INFO WINDOW ////////////////////
140
- ////////////////////////////////////////////////////
145
+ ////////////////////////////////////////////////////
146
+ /////////////////// INFO WINDOW ////////////////////
147
+ ////////////////////////////////////////////////////
141
148
 
142
- // creates infowindows
143
- Gmaps4Rails.createInfoWindow = function(marker_container){
144
- marker_container.serviceObject.setInfoTitleHTML(marker_container.description);
145
- //TODO: how to disable the mouseover display when using setInfoContentHTML?
146
- //marker_container.serviceObject.setInfoContentHTML(marker_container.description);
147
- };
149
+ // creates infowindows
150
+ this.createInfoWindow = function(marker_container){
151
+ marker_container.serviceObject.setInfoTitleHTML(marker_container.description);
152
+ //TODO: how to disable the mouseover display when using setInfoContentHTML?
153
+ //marker_container.serviceObject.setInfoContentHTML(marker_container.description);
154
+ };
148
155
 
149
- ////////////////////////////////////////////////////
150
- /////////////////// Other methods //////////////////
151
- ////////////////////////////////////////////////////
156
+ ////////////////////////////////////////////////////
157
+ /////////////////// Other methods //////////////////
158
+ ////////////////////////////////////////////////////
152
159
 
153
- Gmaps4Rails.fitBounds = function(){
154
- if (Gmaps4Rails.markers.length >=2) {
155
- Gmaps4Rails.map.zoomToRect(Gmaps4Rails.boundsObject);
156
- }
157
- if (Gmaps4Rails.markers.length ==1 ) {
158
- Gmaps4Rails.map.setCenter(Gmaps4Rails.markers[0].serviceObject.latLng);
159
- }
160
- };
160
+ this.fitBounds = function(){
161
+ if (this.markers.length >=2) {
162
+ this.map.zoomToRect(this.boundsObject);
163
+ }
164
+ if (this.markers.length ==1 ) {
165
+ this.map.setCenter(this.markers[0].serviceObject.latLng);
166
+ }
167
+ };
161
168
 
162
- Gmaps4Rails.centerMapOnUser = function(){
163
- Gmaps4Rails.map.setCenter(Gmaps4Rails.userLocation);
164
- };
169
+ this.centerMapOnUser = function(){
170
+ this.map.setCenter(this.userLocation);
171
+ };
165
172
 
166
- Gmaps4Rails.addToMap = function(object){
167
- Gmaps4Rails.map.addShape(object);
168
- };
173
+ this.addToMap = function(object){
174
+ this.map.addShape(object);
175
+ };
176
+
177
+ this.removeFromMap = function(object){
178
+ this.map.removeShape(object);
179
+ }
180
+ }
169
181
 
170
- Gmaps4Rails.removeFromMap = function(object){
171
- Gmaps4Rails.map.removeShape(object);
172
- }
182
+ Gmaps4RailsMapquest.prototype = new Gmaps4Rails();