gmaps4rails 1.0.0 → 1.0.1
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.
data/lib/gmaps4rails/base.rb
CHANGED
@@ -201,15 +201,13 @@ module Gmaps4rails
|
|
201
201
|
#
|
202
202
|
#TODO: clean up this method
|
203
203
|
result = Array.new
|
204
|
-
map_id = edit_map_with_id || Gmaps4rails.get_map_id(hash[:map_options])
|
205
|
-
map_id = "Gmaps." + map_id
|
204
|
+
map_id = "Gmaps." + (edit_map_with_id || Gmaps4rails.get_map_id(hash[:map_options]) )
|
206
205
|
|
207
206
|
#means we are creating a new map
|
208
207
|
if edit_map_with_id == false
|
209
208
|
|
210
|
-
|
211
|
-
result << "#{
|
212
|
-
result << "function #{Gmaps4rails.js_function_name(hash)}() {"
|
209
|
+
result << "#{map_id} = new #{Gmaps4rails.get_constructor hash[:map_options] }" + ";"
|
210
|
+
result << "function #{Gmaps4rails.js_function_name hash }() {"
|
213
211
|
#extract map_options
|
214
212
|
unless hash[:map_options].nil?
|
215
213
|
hash[:map_options].each do |option_k, option_v|
|
@@ -228,7 +226,7 @@ module Gmaps4rails
|
|
228
226
|
if [:map_options, :last_map, :scripts].include? category.to_sym
|
229
227
|
#nothing to do
|
230
228
|
elsif category.to_sym == :direction
|
231
|
-
result <<
|
229
|
+
result << "#{map_id}.direction_conf.origin = '#{content["data"]["from"]}';"
|
232
230
|
result << "#{map_id}.direction_conf.destination = '#{content["data"]["to"]}';"
|
233
231
|
|
234
232
|
content[:options] ||= Array.new
|
@@ -256,7 +254,7 @@ module Gmaps4rails
|
|
256
254
|
result << "#{map_id}.callback();"
|
257
255
|
|
258
256
|
if edit_map_with_id == false
|
259
|
-
result << "}
|
257
|
+
result << "};"
|
260
258
|
if hash[:last_map].nil? || hash[:last_map] == true
|
261
259
|
result << "window.onload = Gmaps.loadMaps;"
|
262
260
|
end
|
@@ -1,10 +1,14 @@
|
|
1
|
-
var Gmaps = {
|
1
|
+
var Gmaps = {};
|
2
2
|
|
3
3
|
Gmaps.loadMaps = function(){
|
4
|
-
|
5
|
-
|
4
|
+
//loop through all variable names.
|
5
|
+
// there should only be maps inside so it trigger their load function
|
6
|
+
for (var attrname in Gmaps) {
|
7
|
+
if (attrname !== "loadMaps"){
|
8
|
+
window["load_" + attrname]();
|
9
|
+
}
|
6
10
|
}
|
7
|
-
}
|
11
|
+
}
|
8
12
|
|
9
13
|
function Gmaps4Rails() {
|
10
14
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmaps4rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Roth
|