gmaps4rails 0.11.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -2
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +18 -20
- data/lib/gmaps4rails/base.rb +95 -0
- data/lib/gmaps4rails/extensions/hash.rb +3 -67
- data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +13 -2
- data/public/javascripts/gmaps4rails/all_apis.js +5 -0
- data/public/javascripts/gmaps4rails/gmaps4rails.base.js +147 -112
- data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +182 -171
- data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +269 -235
- data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +135 -125
- data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +227 -218
- data/public/stylesheets/gmaps4rails.css +2 -2
- metadata +9 -111
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/controllers/users_controller.rb +0 -60
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/users_helper.rb +0 -3
- data/test/dummy/app/models/user.rb +0 -38
- data/test/dummy/config/application.rb +0 -41
- data/test/dummy/config/boot.rb +0 -6
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -26
- data/test/dummy/config/environments/production.rb +0 -49
- data/test/dummy/config/environments/test.rb +0 -35
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/routes.rb +0 -7
- data/test/dummy/db/migrate/20110306182914_create_users.rb +0 -21
- data/test/dummy/db/migrate/20110430081624_add_addresses_to_users.rb +0 -11
- data/test/dummy/db/migrate/20110430083824_remove_address_from_users.rb +0 -9
- data/test/dummy/db/schema.rb +0 -35
- data/test/dummy/db/seeds.rb +0 -7
- data/test/dummy/spec/base/base_spec.rb +0 -127
- data/test/dummy/spec/helpers/gmaps4rails_helper_spec.rb +0 -13
- data/test/dummy/spec/javascripts/support/jasmine_config.rb +0 -23
- data/test/dummy/spec/javascripts/support/jasmine_runner.rb +0 -20
- data/test/dummy/spec/models/user_spec.rb +0 -284
- data/test/dummy/spec/requests/users_spec.rb +0 -22
- data/test/dummy/spec/spec_helper.rb +0 -41
- data/test/dummy/spec/support/factories.rb +0 -20
- data/test/dummy/spec/support/matchers.rb +0 -7
- data/test/dummy31/app/controllers/application_controller.rb +0 -3
- data/test/dummy31/app/controllers/users_controller.rb +0 -83
- data/test/dummy31/app/helpers/application_helper.rb +0 -2
- data/test/dummy31/app/helpers/users_helper.rb +0 -2
- data/test/dummy31/app/models/user.rb +0 -7
- data/test/dummy31/config/application.rb +0 -43
- data/test/dummy31/config/boot.rb +0 -6
- data/test/dummy31/config/environment.rb +0 -5
- data/test/dummy31/config/environments/development.rb +0 -27
- data/test/dummy31/config/environments/production.rb +0 -51
- data/test/dummy31/config/environments/test.rb +0 -39
- data/test/dummy31/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy31/config/initializers/inflections.rb +0 -10
- data/test/dummy31/config/initializers/mime_types.rb +0 -5
- data/test/dummy31/config/initializers/secret_token.rb +0 -7
- data/test/dummy31/config/initializers/session_store.rb +0 -8
- data/test/dummy31/config/initializers/wrap_parameters.rb +0 -12
- data/test/dummy31/config/routes.rb +0 -61
- data/test/dummy31/db/migrate/20110809134019_create_users.rb +0 -13
- data/test/dummy31/db/schema.rb +0 -25
- data/test/dummy31/db/seeds.rb +0 -7
@@ -1,195 +1,206 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
};
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
);
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
82
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
this.clearMarker(this.markers[i]);
|
89
|
-
}
|
90
|
-
};
|
101
|
+
this.clearMarker = function(marker) {
|
102
|
+
this.removeFromMap(marker.serviceObject);
|
103
|
+
};
|
91
104
|
|
92
|
-
|
93
|
-
this.
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
this.showMarker(this.markers[i]);
|
100
|
-
}
|
101
|
-
};
|
112
|
+
this.showMarker = function(marker) {
|
113
|
+
marker.serviceObject.setOptions({ visible: true });
|
114
|
+
};
|
102
115
|
|
103
|
-
|
104
|
-
|
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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
}
|
111
|
-
};
|
122
|
+
this.hideMarker = function(marker) {
|
123
|
+
marker.serviceObject.setOptions({ visible: false });
|
124
|
+
};
|
112
125
|
|
113
|
-
|
114
|
-
|
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
|
-
|
141
|
+
};
|
131
142
|
|
132
|
-
|
143
|
+
this.clearClusterer = function() {
|
144
|
+
};
|
133
145
|
|
134
|
-
|
135
|
-
|
146
|
+
//creates clusters
|
147
|
+
this.clusterize = function()
|
148
|
+
{
|
136
149
|
|
137
|
-
|
138
|
-
Gmaps4Rails.clusterize = function()
|
139
|
-
{
|
150
|
+
};
|
140
151
|
|
141
|
-
|
152
|
+
////////////////////////////////////////////////////
|
153
|
+
/////////////////// INFO WINDOW ////////////////////
|
154
|
+
////////////////////////////////////////////////////
|
142
155
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
//
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
-
|
160
|
-
|
161
|
-
|
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
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
-
|
181
|
-
|
182
|
-
};
|
189
|
+
this.fitBounds = function(){
|
190
|
+
this.map.setView({bounds: this.boundsObject});
|
191
|
+
};
|
183
192
|
|
184
|
-
|
185
|
-
|
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
|
-
|
189
|
-
|
190
|
-
|
201
|
+
this.centerMapOnUser = function(){
|
202
|
+
this.map.setView({ center: this.userLocation});
|
203
|
+
};
|
191
204
|
};
|
192
205
|
|
193
|
-
|
194
|
-
Gmaps4Rails.map.setView({ center: Gmaps4Rails.userLocation});
|
195
|
-
};
|
206
|
+
Gmaps4RailsBing.prototype = new Gmaps4Rails();
|