gmaps4rails 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -27,7 +27,7 @@ Any help would be appreciated to complete this work.
27
27
 
28
28
  == Requirements
29
29
  - gem 'gmaps4rails' (in your gemfile, then bundle)
30
- - <%= yield :head %> (in your header)
30
+ - <%= yield :head %> (in your header, Rails 3.0.x only)
31
31
  - <%= yield :scripts %> (in your footer)
32
32
 
33
33
  To make Rails serve the assets (javascripts, stylesheets and marker images) you have several options, depending on your configuration and Rails version:
@@ -43,7 +43,9 @@ To make Rails serve the assets (javascripts, stylesheets and marker images) you
43
43
 
44
44
  * //= require gmaps4rails/all_apis.js
45
45
 
46
- You even don't need the `yield :head` if you include `require gmaps4rails` in your CSS manifest.
46
+ Stylesheet:
47
+
48
+ * `require gmaps4rails` (if you use the default)
47
49
 
48
50
  - if you are using Rails 3.0:
49
51
  see para below to be sure everything will work in production.
@@ -109,7 +111,7 @@ Done!
109
111
 
110
112
  == Todo?
111
113
 
112
- Feel free ton contact us, you have your say.
114
+ Feel free to contact us, you have your say.
113
115
 
114
116
  == Copyright
115
117
  MIT license.
@@ -24,6 +24,7 @@ class @Gmaps4Rails
24
24
  @callback = -> false #to let user set a custom callback function
25
25
  @customClusterer = -> false #to let user set custom clusterer pictures
26
26
  @infobox = -> false #to let user use custom infoboxes
27
+ @jsTemplate = false #to let user create infowindows client side
27
28
 
28
29
  @default_map_options =
29
30
  id: 'map'
@@ -211,22 +211,23 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
211
211
  #////////////////////////////////////////////////////
212
212
 
213
213
  #// creates infowindows
214
- createInfoWindow : (marker_container) ->
215
- if @markers_conf.custom_infowindow_class == null && marker_container.description?
216
- #create the infowindow
217
- marker_container.infowindow = new google.maps.InfoWindow({content: marker_container.description })
218
- #add the listener associated
219
- currentMap = this
220
- google.maps.event.addListener(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject))
221
- else #creating custom infowindow
222
- if marker_container.description?
214
+ createInfoWindow : (marker_container) ->
215
+ if typeof(@jsTemplate) == "function" or marker_container.description?
216
+ marker_container.description = @jsTemplate(marker_container) if typeof(@jsTemplate) == "function"
217
+ if @markers_conf.custom_infowindow_class != null
218
+ #creating custom infowindow
223
219
  boxText = document.createElement("div")
224
220
  boxText.setAttribute("class", @markers_conf.custom_infowindow_class) #to customize
225
- boxText.innerHTML = marker_container.description
221
+ boxText.innerHTML = marker_container.description
226
222
  marker_container.infowindow = new InfoBox(@infobox(boxText))
227
223
  currentMap = this
228
224
  google.maps.event.addListener(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject))
229
-
225
+ else
226
+ #create default infowindow
227
+ marker_container.infowindow = new google.maps.InfoWindow({content: marker_container.description })
228
+ #add the listener associated
229
+ currentMap = this
230
+ google.maps.event.addListener(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject))
230
231
 
231
232
  openInfoWindow : (currentMap, infoWindow, marker) ->
232
233
  return ->
@@ -159,7 +159,7 @@ class @Gmaps4RailsOpenlayers extends Gmaps4Rails
159
159
  if @markerClusterer != null
160
160
  @clearClusterer()
161
161
  markers_array = new Array
162
- for marker in markers
162
+ for marker in @markers
163
163
  markers_array.push(marker.serviceObject)
164
164
  @markerClusterer = @createClusterer markers_array
165
165
 
@@ -1,7 +1,9 @@
1
1
  <% #thanks to enable_css, user can avoid this css to be loaded
2
2
  if enable_css == true and options[:scripts].nil? %>
3
- <% content_for :head do %>
4
- <%= stylesheet_link_tag 'gmaps4rails' %>
3
+ <% if Rails::VERSION::MAJOR >= 3 and Rails::VERSION::MINOR < 1 %>
4
+ <% content_for :head do %>
5
+ <%= stylesheet_link_tag 'gmaps4rails' %>
6
+ <% end %>
5
7
  <% end %>
6
8
  <% end %>
7
9
  <% content_for :scripts do %>
@@ -29,6 +29,7 @@
29
29
  this.infobox = function() {
30
30
  return false;
31
31
  };
32
+ this.jsTemplate = false;
32
33
  this.default_map_options = {
33
34
  id: 'map',
34
35
  draggable: true,
@@ -239,20 +239,23 @@
239
239
  };
240
240
  Gmaps4RailsGoogle.prototype.createInfoWindow = function(marker_container) {
241
241
  var boxText, currentMap;
242
- if (this.markers_conf.custom_infowindow_class === null && (marker_container.description != null)) {
243
- marker_container.infowindow = new google.maps.InfoWindow({
244
- content: marker_container.description
245
- });
246
- currentMap = this;
247
- return google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject));
248
- } else {
249
- if (marker_container.description != null) {
242
+ if (typeof this.jsTemplate === "function" || (marker_container.description != null)) {
243
+ if (typeof this.jsTemplate === "function") {
244
+ marker_container.description = this.jsTemplate(marker_container);
245
+ }
246
+ if (this.markers_conf.custom_infowindow_class !== null) {
250
247
  boxText = document.createElement("div");
251
248
  boxText.setAttribute("class", this.markers_conf.custom_infowindow_class);
252
249
  boxText.innerHTML = marker_container.description;
253
250
  marker_container.infowindow = new InfoBox(this.infobox(boxText));
254
251
  currentMap = this;
255
252
  return google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject));
253
+ } else {
254
+ marker_container.infowindow = new google.maps.InfoWindow({
255
+ content: marker_container.description
256
+ });
257
+ currentMap = this;
258
+ return google.maps.event.addListener(marker_container.serviceObject, 'click', this.openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject));
256
259
  }
257
260
  }
258
261
  };
@@ -148,14 +148,15 @@
148
148
  return clusters;
149
149
  };
150
150
  Gmaps4RailsOpenlayers.prototype.clusterize = function() {
151
- var marker, markers_array, _i, _len;
151
+ var marker, markers_array, _i, _len, _ref;
152
152
  if (this.markers_conf.do_clustering === true) {
153
153
  if (this.markerClusterer !== null) {
154
154
  this.clearClusterer();
155
155
  }
156
156
  markers_array = new Array;
157
- for (_i = 0, _len = markers.length; _i < _len; _i++) {
158
- marker = markers[_i];
157
+ _ref = this.markers;
158
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
159
+ marker = _ref[_i];
159
160
  markers_array.push(marker.serviceObject);
160
161
  }
161
162
  return this.markerClusterer = this.createClusterer(markers_array);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmaps4rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-30 00:00:00.000000000Z
13
+ date: 2011-10-03 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: crack
17
- requirement: &2152393380 !ruby/object:Gem::Requirement
17
+ requirement: &2152373580 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152393380
25
+ version_requirements: *2152373580
26
26
  description: ! 'Enables easy display of items (taken from a Rails 3 model) on a Google
27
27
  Maps (JS API V3), OpenLayers, Mapquest and Bing. Geocoding + Directions included.
28
28
  Provides much options: markers customization, infowindows, auto-adjusted zoom, polylines,