gmaps4rails 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,13 +39,13 @@ To make Rails serve the assets (javascripts, stylesheets and marker images) you
39
39
  - if you are using Rails 3.1 and have asset pipeline enabled ('config.assets.enabled = true' in config/application.rb), include the appropriate manifest:
40
40
 
41
41
  * //= require gmaps4rails/bing.js
42
-
42
+
43
43
  * //= require gmaps4rails/googlemaps.js
44
-
44
+
45
45
  * //= require gmaps4rails/mapquest.js
46
-
46
+
47
47
  * //= require gmaps4rails/openlayers.js
48
-
48
+
49
49
  * //= require gmaps4rails/all_apis.js
50
50
 
51
51
  Stylesheet:
@@ -1,6 +1,6 @@
1
1
  Gmaps = {}
2
2
 
3
- Gmaps.loadMaps = ->
3
+ Gmaps.loadMaps = ->
4
4
  #loop through all variable names.
5
5
  #there should only be maps inside so it trigger their load function
6
6
  for key, value of Gmaps
@@ -26,22 +26,22 @@ class @Gmaps4Rails
26
26
  @infobox = -> false #to let user use custom infoboxes
27
27
  @jsTemplate = false #to let user create infowindows client side
28
28
 
29
- @default_map_options =
29
+ @default_map_options =
30
30
  id: 'map'
31
31
  draggable: true
32
32
  detect_location: false # should the browser attempt to use geolocation detection features of HTML5?
33
33
  center_on_user: false # centers map on the location detected through the browser
34
34
  center_latitude: 0
35
- center_longitude: 0
35
+ center_longitude: 0
36
36
  zoom: 7
37
37
  maxZoom: null
38
38
  minZoom: null
39
39
  auto_adjust : true # adjust the map to the markers if set to true
40
40
  auto_zoom: true # zoom given by auto-adjust
41
- bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
41
+ bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
42
42
  raw: {} # raw json to pass additional options
43
43
 
44
- @default_markers_conf =
44
+ @default_markers_conf =
45
45
  #Marker config
46
46
  title: ""
47
47
  #MarkerImage config
@@ -65,15 +65,15 @@ class @Gmaps4Rails
65
65
  @circles = [] # contains raw data, array of hash
66
66
  @markerClusterer = null # contains all marker clusterers
67
67
  @markerImages = []
68
-
68
+
69
69
  #tnitializes the map
70
70
  initialize : ->
71
71
  @map = @createMap()
72
- if (@map_options.detect_location == true or @map_options.center_on_user == true)
73
- @findUserLocation(this)
72
+ if (@map_options.detect_location == true or @map_options.center_on_user == true)
73
+ @findUserLocation(this)
74
74
  #resets sidebar if needed
75
75
  @resetSidebarContent()
76
-
76
+
77
77
  findUserLocation : (map_object) ->
78
78
  if (navigator.geolocation)
79
79
  #try to retrieve user's position
@@ -84,9 +84,9 @@ class @Gmaps4Rails
84
84
  map_object.centerMapOnUser()
85
85
  positionFailure = ->
86
86
  map_object.geolocationFailure(true)
87
-
87
+
88
88
  navigator.geolocation.getCurrentPosition( positionSuccessful, positionFailure)
89
- else
89
+ else
90
90
  #failure but the navigator doesn't handle geolocation
91
91
  map_object.geolocationFailure(false)
92
92
 
@@ -101,16 +101,16 @@ class @Gmaps4Rails
101
101
 
102
102
  directionsDisplay.setMap(@map)
103
103
  #display panel only if required
104
- if @direction_conf.display_panel
104
+ if @direction_conf.display_panel
105
105
  directionsDisplay.setPanel(document.getElementById(@direction_conf.panel_id))
106
-
106
+
107
107
  directionsDisplay.setOptions
108
108
  suppressMarkers: false
109
109
  suppressInfoWindows: false
110
110
  suppressPolylines: false
111
-
112
- request =
113
- origin: @direction_conf.origin
111
+
112
+ request =
113
+ origin: @direction_conf.origin
114
114
  destination: @direction_conf.destination
115
115
  waypoints: @direction_conf.waypoints
116
116
  optimizeWaypoints: @direction_conf.optimizeWaypoints
@@ -195,7 +195,7 @@ class @Gmaps4Rails
195
195
  #creates a single polygon, triggered by create_polygons
196
196
  create_polygon : (polygon) ->
197
197
  polygon_coordinates = []
198
-
198
+
199
199
  #Polygon points are in an Array, that's why looping is necessary
200
200
  for point in polygon
201
201
  latlng = @createLatLng(point.lat, point.lng)
@@ -225,7 +225,7 @@ class @Gmaps4Rails
225
225
  #////////////////////////////////////////////////////
226
226
  #/////////////////// POLYLINES //////////////////////
227
227
  #////////////////////////////////////////////////////
228
-
228
+
229
229
  #replace old markers with new markers on an existing map
230
230
  replacePolylines : (new_polylines) ->
231
231
  #reset previous polylines and kill them from map
@@ -236,7 +236,7 @@ class @Gmaps4Rails
236
236
  @create_polylines()
237
237
  #.... and adjust map boundaries
238
238
  @adjustMapToBounds()
239
-
239
+
240
240
  destroy_polylines : ->
241
241
  for polyline in @polylines
242
242
  #delete polylines from map
@@ -252,17 +252,16 @@ class @Gmaps4Rails
252
252
  #creates a single polyline, triggered by create_polylines
253
253
  create_polyline : (polyline) ->
254
254
  polyline_coordinates = []
255
-
255
+
256
256
  #2 cases here, either we have a coded array of LatLng or we have an Array of LatLng
257
257
  for element in polyline
258
258
  #if we have a coded array
259
259
  if element.coded_array?
260
260
  decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array)
261
261
  #loop through every point in the array
262
- for point in decoded_array.length
262
+ for point in decoded_array
263
263
  polyline_coordinates.push(point)
264
- polyline_coordinates.push(point)
265
-
264
+
266
265
  #or we have an array of latlng
267
266
  else
268
267
  #by convention, a single polyline could be customized in the first array or it uses default values
@@ -270,19 +269,22 @@ class @Gmaps4Rails
270
269
  strokeColor = element.strokeColor || @polylines_conf.strokeColor
271
270
  strokeOpacity = element.strokeOpacity || @polylines_conf.strokeOpacity
272
271
  strokeWeight = element.strokeWeight || @polylines_conf.strokeWeight
273
-
272
+ clickable = element.clickable || @polylines_conf.clickable
273
+ zIndex = element.zIndex || @polylines_conf.zIndex
274
+
274
275
  #add latlng if positions provided
275
- if element.lat? && element.lng?
276
+ if element.lat? && element.lng?
276
277
  latlng = @createLatLng(element.lat, element.lng)
277
278
  polyline_coordinates.push(latlng)
278
279
 
279
- # Construct the polyline
280
+ # Construct the polyline
280
281
  new_poly = new google.maps.Polyline
281
282
  path: polyline_coordinates
282
283
  strokeColor: strokeColor
283
284
  strokeOpacity: strokeOpacity
284
285
  strokeWeight: strokeWeight
285
- clickable: false
286
+ clickable: clickable
287
+ zIndex: zIndex
286
288
 
287
289
  #save polyline
288
290
  polyline.serviceObject = new_poly
@@ -292,7 +294,7 @@ class @Gmaps4Rails
292
294
  #///////////////////// MARKERS //////////////////////
293
295
  #////////////////////////////////////////////////////
294
296
 
295
- #creates, clusterizes and adjusts map
297
+ #creates, clusterizes and adjusts map
296
298
  create_markers : ->
297
299
  @createServiceMarkersFromMarkers()
298
300
  @clusterize()
@@ -310,7 +312,7 @@ class @Gmaps4Rails
310
312
  #retrieve coordinates from the æarray
311
313
  Lat = LatLng[0]
312
314
  Lng = LatLng[1]
313
-
315
+
314
316
  #save object
315
317
  @markers[index].serviceObject = @createMarker
316
318
  "marker_picture": if @markers[index].picture then @markers[index].picture else @markers_conf.picture
@@ -332,10 +334,10 @@ class @Gmaps4Rails
332
334
  @createInfoWindow(@markers[index])
333
335
  #create sidebar if enabled
334
336
  @createSidebar(@markers[index])
335
-
337
+
336
338
  @markers_conf.offset = @markers.length
337
339
 
338
- #creates Image Anchor Position or return null if nothing passed
340
+ #creates Image Anchor Position or return null if nothing passed
339
341
  createImageAnchorPosition : (anchorLocation) ->
340
342
  if (anchorLocation == null)
341
343
  return null
@@ -409,31 +411,31 @@ class @Gmaps4Rails
409
411
  if @map_options.auto_adjust
410
412
  #from markers
411
413
  @extendBoundsWithMarkers()
412
-
414
+
413
415
  #from polylines:
414
- for polyline in @polylines
416
+ for polyline in @polylines
415
417
  polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray()
416
418
  for point in polyline_points
417
419
  @boundsObject.extend point
418
-
420
+
419
421
  #from polygons:
420
422
  for polygon in @polygons
421
423
  polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray()
422
- for point in polygon_points
424
+ for point in polygon_points
423
425
  @boundsObject.extend point
424
-
426
+
425
427
  #from circles
426
428
  for circle in @circles
427
429
  @boundsObject.extend(circle.serviceObject.getBounds().getNorthEast())
428
430
  @boundsObject.extend(circle.serviceObject.getBounds().getSouthWest())
429
431
 
430
- #in every case, I've to take into account the bounds set up by the user
432
+ #in every case, I've to take into account the bounds set up by the user
431
433
  for bound in @map_options.bounds
432
434
  #create points from bounds provided
433
435
  #TODO:only works with google maps
434
436
  bound = @createLatLng(bound.lat, bound.lng)
435
437
  @boundsObject.extend bound
436
-
438
+
437
439
  #SECOND_STEP: ajust the map to the bounds
438
440
  if @map_options.auto_adjust or @map_options.bounds.length > 0
439
441
 
@@ -443,13 +445,13 @@ class @Gmaps4Rails
443
445
  @map_options.center_latitude = map_center.lat()
444
446
  @map_options.center_longitude = map_center.lng()
445
447
  @map.setCenter(map_center)
446
- else
448
+ else
447
449
  @fitBounds()
448
-
450
+
449
451
  #////////////////////////////////////////////////////
450
452
  #///////////////// KML //////////////////
451
453
  #////////////////////////////////////////////////////
452
-
454
+
453
455
  create_kml : ->
454
456
  for kml in @kml
455
457
  kml.serviceObject = @createKmlLayer kml
@@ -471,7 +473,7 @@ class @Gmaps4Rails
471
473
  Lat = parseFloat(Lat0) + (180/Math.PI)*(dy/6378137)
472
474
  Lng = parseFloat(Lng0) + ( 90/Math.PI)*(dx/6378137)/Math.cos(Lat0)
473
475
  return [Lat, Lng]
474
-
476
+
475
477
  mergeObjectWithDefault : (object1, object2) ->
476
478
  copy_object1 = {}
477
479
  for key, value of object1
@@ -481,12 +483,12 @@ class @Gmaps4Rails
481
483
  unless copy_object1[key]?
482
484
  copy_object1[key] = value
483
485
  return copy_object1
484
-
486
+
485
487
  mergeWithDefault : (objectName) ->
486
488
  default_object = @["default_" + objectName]
487
489
  object = @[objectName]
488
490
  @[objectName] = @mergeObjectWithDefault(object, default_object)
489
491
  return true
490
-
492
+
491
493
  #gives a value between -1 and 1
492
- random : -> return(Math.random() * 2 -1)
494
+ random : -> return(Math.random() * 2 -1)
@@ -3,7 +3,7 @@
3
3
  #######################################################################################################
4
4
 
5
5
  class @Gmaps4RailsGoogle extends Gmaps4Rails
6
-
6
+
7
7
  constructor: ->
8
8
  super
9
9
  #Map settings
@@ -13,12 +13,12 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
13
13
  type: "ROADMAP" # HYBRID, ROADMAP, SATELLITE, TERRAIN
14
14
 
15
15
  #markers + info styling
16
- @markers_conf =
16
+ @markers_conf =
17
17
  clusterer_gridSize: 50
18
18
  clusterer_maxZoom: 5
19
19
  custom_cluster_pictures: null
20
- custom_infowindow_class: null
21
-
20
+ custom_infowindow_class: null
21
+
22
22
  @mergeWithDefault("map_options")
23
23
  @mergeWithDefault("markers_conf")
24
24
 
@@ -40,8 +40,10 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
40
40
  strokeColor: "#FF0000"
41
41
  strokeOpacity: 1
42
42
  strokeWeight: 2
43
+ clickable: false
44
+ zIndex: null
43
45
 
44
- #Circle Styling
46
+ #Circle Styling
45
47
  @circles_conf = #default style for circles
46
48
  fillColor: "#00AAFF"
47
49
  fillOpacity: 0.35
@@ -52,17 +54,17 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
52
54
  zIndex: null
53
55
 
54
56
  #Direction Settings
55
- @direction_conf =
57
+ @direction_conf =
56
58
  panel_id: null
57
59
  display_panel: false
58
- origin: null
60
+ origin: null
59
61
  destination: null
60
62
  waypoints: [] #[{location: "toulouse,fr", stopover: true}, {location: "Clermont-Ferrand, fr", stopover: true}]
61
63
  optimizeWaypoints: false
62
64
  unitSystem: "METRIC" #IMPERIAL
63
65
  avoidHighways: false
64
66
  avoidTolls: false
65
- region: null
67
+ region: null
66
68
  travelMode: "DRIVING" #WALKING, BICYCLING
67
69
 
68
70
  #////////////////////////////////////////////////////
@@ -79,7 +81,7 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
79
81
  return new google.maps.LatLngBounds()
80
82
 
81
83
  createMap : ->
82
- defaultOptions =
84
+ defaultOptions =
83
85
  maxZoom: @map_options.maxZoom
84
86
  minZoom: @map_options.minZoom
85
87
  zoom: @map_options.zoom
@@ -91,7 +93,7 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
91
93
  draggable: @map_options.draggable
92
94
 
93
95
  mergedOptions = @mergeObjectWithDefault @map_options.raw, defaultOptions
94
-
96
+
95
97
  return new google.maps.Map document.getElementById(@map_options.id), mergedOptions
96
98
 
97
99
 
@@ -106,11 +108,11 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
106
108
  #////////////////////////////////////////////////////
107
109
 
108
110
  createMarker : (args) ->
109
- markerLatLng = @createLatLng(args.Lat, args.Lng)
111
+ markerLatLng = @createLatLng(args.Lat, args.Lng)
110
112
  #Marker sizes are expressed as a Size of X,Y
111
113
  if args.marker_picture == "" and args.rich_marker == null
112
114
  defaultOptions = {position: markerLatLng, map: @map, title: args.marker_title, draggable: args.marker_draggable}
113
- mergedOptions = @mergeObjectWithDefault @markers_conf.raw, defaultOptions
115
+ mergedOptions = @mergeObjectWithDefault @markers_conf.raw, defaultOptions
114
116
  return new google.maps.Marker mergedOptions
115
117
 
116
118
  if (args.rich_marker != null)
@@ -123,7 +125,7 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
123
125
  anchor: if args.marker_anchor == null then 0 else args.marker_anchor[0]
124
126
  })
125
127
 
126
- #default behavior
128
+ #default behavior
127
129
  #calculate MarkerImage anchor location
128
130
  imageAnchorPosition = @createImageAnchorPosition args.marker_anchor
129
131
  shadowAnchorPosition = @createImageAnchorPosition args.shadow_anchor
@@ -131,7 +133,7 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
131
133
  markerImage = @createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition)
132
134
  shadowImage = @createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition)
133
135
  defaultOptions = {position: markerLatLng, map: @map, icon: markerImage, title: args.marker_title, draggable: args.marker_draggable, shadow: shadowImage}
134
- mergedOptions = @mergeObjectWithDefault @markers_conf.raw, defaultOptions
136
+ mergedOptions = @mergeObjectWithDefault @markers_conf.raw, defaultOptions
135
137
  return new google.maps.Marker mergedOptions
136
138
 
137
139
  #checks if obj is included in arr Array and returns the position or false
@@ -145,13 +147,13 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
145
147
  createOrRetrieveImage : (currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition) ->
146
148
  return null if (currentMarkerPicture == "" or currentMarkerPicture == null )
147
149
 
148
- test_image_index = @includeMarkerImage(@markerImages, currentMarkerPicture)
150
+ test_image_index = @includeMarkerImage(@markerImages, currentMarkerPicture)
149
151
  switch test_image_index
150
152
  when false
151
153
  markerImage = @createMarkerImage(currentMarkerPicture, @createSize(markerWidth, markerHeight), null, imageAnchorPosition, null )
152
154
  @markerImages.push(markerImage)
153
- return markerImage
154
- break
155
+ return markerImage
156
+ break
155
157
  else
156
158
  return @markerImages[test_image_index] if typeof test_image_index == 'number'
157
159
  return false
@@ -210,7 +212,7 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
210
212
  #////////////////////////////////////////////////////
211
213
 
212
214
  #// creates infowindows
213
- createInfoWindow : (marker_container) ->
215
+ createInfoWindow : (marker_container) ->
214
216
  if typeof(@jsTemplate) == "function" or marker_container.description?
215
217
  marker_container.description = @jsTemplate(marker_container) if typeof(@jsTemplate) == "function"
216
218
  if @markers_conf.custom_infowindow_class != null
@@ -231,7 +233,7 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
231
233
  openInfoWindow : (currentMap, infoWindow, marker) ->
232
234
  return ->
233
235
  # Close the latest selected marker before opening the current one.
234
- currentMap.visibleInfoWindow.close() if currentMap.visibleInfoWindow != null
236
+ currentMap.visibleInfoWindow.close() if currentMap.visibleInfoWindow != null
235
237
  infoWindow.open(currentMap.map, marker)
236
238
  currentMap.visibleInfoWindow = infoWindow
237
239
 
@@ -256,4 +258,4 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
256
258
 
257
259
  centerMapOnUser : ->
258
260
  @map.setCenter(@userLocation)
259
-
261
+
@@ -9,7 +9,7 @@ if enable_css == true && options[:scripts].nil? %>
9
9
 
10
10
  <% content_for :scripts do %>
11
11
 
12
- <%= gmaps4rails_js_files(options[:map_options], options[:scripts], enable_js) %>
12
+ <%= gmaps4rails_js_files(options[:map_options], options[:scripts], enable_js, options[:markers].try(:[], :options)) %>
13
13
  <script type="text/javascript" charset="utf-8">
14
14
  <%=raw options.to_gmaps4rails %>
15
15
  </script>
@@ -7,12 +7,18 @@
7
7
  <% when "bing" %>
8
8
  <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
9
9
  <% else %>
10
- <script type="text/javascript" src="//maps.google.com/maps/api/js?v=3.5&sensor=false&amp;libraries=geometry<%= gmaps4rails_js_libraries(map_options.try(:[], :libraries)) %>"></script>
11
- <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script>
12
- <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script>
13
- <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>
10
+ <script type="text/javascript" src="//maps.google.com/maps/api/js?v=3.8&sensor=false&libraries=geometry<%= gmaps4rails_js_libraries(map_options.try(:[], :libraries)) %>&<%= gmaps4rails_map_language(map_options) %>"></script>
11
+ <% if marker_options.try(:[], :custom_infowindow_class) %>
12
+ <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script>
13
+ <% end %>
14
+ <% if marker_options.try(:[], :do_clustering) %>
15
+ <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script>
16
+ <% end %>
17
+ <% if marker_options.try(:[], :rich_marker) %>
18
+ <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>
19
+ <% end %>
14
20
  <% end %>
15
-
21
+
16
22
  <% if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR < 1 %>
17
23
  <% unless scripts.try(:to_sym) == :api %>
18
24
  <%= javascript_include_tag 'gmaps4rails/gmaps4rails.base.js' %>
@@ -28,4 +34,4 @@
28
34
  <%= javascript_include_tag 'gmaps4rails/gmaps4rails.googlemaps.js' %>
29
35
  <% end %>
30
36
  <% end %>
31
- <% end %>
37
+ <% end %>
@@ -1,7 +1,7 @@
1
1
  module Gmaps4railsHelper
2
-
2
+
3
3
  # shortcut helper for basic marker display
4
-
4
+
5
5
  def gmaps4rails(builder, enable_css = true, enable_js = true )
6
6
  options = {
7
7
  :map_options => { :auto_adjust => true},
@@ -9,36 +9,41 @@ module Gmaps4railsHelper
9
9
  }
10
10
  render :partial => '/gmaps4rails/gmaps4rails', :locals => { :options => options.with_indifferent_access, :enable_css => enable_css, :enable_js => enable_js }
11
11
  end
12
-
12
+
13
13
  # complete helper to pass all variables alongside their options
14
-
14
+
15
15
  def gmaps(options, enable_css = true, enable_js = true )
16
16
  render :partial => '/gmaps4rails/gmaps4rails', :locals => { :options => options.with_indifferent_access, :enable_css => enable_css, :enable_js => enable_js }
17
17
  end
18
-
18
+
19
19
  def gmaps4rails_js_libraries(libraries_array)
20
20
  return "" if libraries_array.nil?
21
21
  "," + libraries_array.join(",")
22
22
  end
23
-
23
+
24
+ def gmaps4rails_map_language(map_options)
25
+ "language=#{map_options.try(:[], :language) || ''}&hl=#{map_options.try(:[], :hl) || ''}&region=#{map_options.try(:[], :region) || ''}".html_safe
26
+ end
27
+
24
28
  def gmaps4rails_map_id(map_options)
25
29
  map_options.try(:[], :id) || Gmaps4rails::DEFAULT_MAP_ID
26
30
  end
27
-
31
+
28
32
  def gmaps4rails_container_class(map_options)
29
33
  map_options.try(:[], :container_class) || "map_container"
30
34
  end
31
-
35
+
32
36
  def gmaps4rails_map_class(map_options)
33
37
  default_class = map_options.try(:[], :provider) == "bing" ? "bing_map" : "gmaps4rails_map"
34
38
  map_options.try(:[], :class) || default_class
35
39
  end
36
-
37
- def gmaps4rails_js_files(map_options = nil, scripts = nil, enable_js = true)
38
- render "/gmaps4rails/scripts", :map_options => map_options, :scripts => scripts, :enable_js => enable_js
40
+
41
+
42
+ def gmaps4rails_js_files(map_options = nil, scripts = nil, enable_js = true, marker_options = nil)
43
+ render "/gmaps4rails/scripts", :map_options => map_options, :scripts => scripts, :enable_js => enable_js, :marker_options => marker_options
39
44
  end
40
-
45
+
41
46
  def gmaps4rails_html(map_options = nil)
42
47
  render "/gmaps4rails/html", :map_options => map_options
43
48
  end
44
- end
49
+ end
@@ -15,23 +15,27 @@ module Gmaps4rails
15
15
 
16
16
  def Gmaps4rails.infowindow(string)
17
17
  @json_hash[:description] = string
18
+ true
18
19
  end
19
20
 
20
21
  def Gmaps4rails.title(string)
21
22
  @json_hash[:title] = string
23
+ true
22
24
  end
23
25
 
24
26
  def Gmaps4rails.sidebar(string)
25
27
  @json_hash[:sidebar] = string
28
+ true
26
29
  end
27
30
 
28
31
  def Gmaps4rails.json(json)
29
32
  return @json_hash.merge! json if json.is_a? Hash
30
- json
33
+ true
31
34
  end
32
35
 
33
36
  def Gmaps4rails.picture(hash)
34
37
  @json_hash.merge! hash
38
+ true
35
39
  end
36
40
 
37
41
  private
@@ -106,8 +110,7 @@ module Gmaps4rails
106
110
  #
107
111
  def Gmaps4rails.handle_block(&block)
108
112
  block_result = yield(@object, ::Gmaps4rails)
109
- return Gmaps4rails.json(block_result) unless block_result.is_a? String
110
- @custom_json = block_result
113
+ @custom_json = block_result unless block_result == true
111
114
  end
112
115
 
113
116
  end
@@ -268,16 +268,14 @@
268
268
  return _results;
269
269
  };
270
270
  Gmaps4Rails.prototype.create_polyline = function(polyline) {
271
- var decoded_array, element, latlng, new_poly, point, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, _i, _j, _len, _len2, _ref;
271
+ var clickable, decoded_array, element, latlng, new_poly, point, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
272
272
  polyline_coordinates = [];
273
273
  for (_i = 0, _len = polyline.length; _i < _len; _i++) {
274
274
  element = polyline[_i];
275
275
  if (element.coded_array != null) {
276
276
  decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array);
277
- _ref = decoded_array.length;
278
- for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
279
- point = _ref[_j];
280
- polyline_coordinates.push(point);
277
+ for (_j = 0, _len2 = decoded_array.length; _j < _len2; _j++) {
278
+ point = decoded_array[_j];
281
279
  polyline_coordinates.push(point);
282
280
  }
283
281
  } else {
@@ -285,6 +283,8 @@
285
283
  strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
286
284
  strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
287
285
  strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
286
+ clickable = element.clickable || this.polylines_conf.clickable;
287
+ zIndex = element.zIndex || this.polylines_conf.zIndex;
288
288
  }
289
289
  if ((element.lat != null) && (element.lng != null)) {
290
290
  latlng = this.createLatLng(element.lat, element.lng);
@@ -297,7 +297,8 @@
297
297
  strokeColor: strokeColor,
298
298
  strokeOpacity: strokeOpacity,
299
299
  strokeWeight: strokeWeight,
300
- clickable: false
300
+ clickable: clickable,
301
+ zIndex: zIndex
301
302
  });
302
303
  polyline.serviceObject = new_poly;
303
304
  return new_poly.setMap(this.map);
@@ -39,7 +39,9 @@
39
39
  this.polylines_conf = {
40
40
  strokeColor: "#FF0000",
41
41
  strokeOpacity: 1,
42
- strokeWeight: 2
42
+ strokeWeight: 2,
43
+ clickable: false,
44
+ zIndex: null
43
45
  };
44
46
  this.circles_conf = {
45
47
  fillColor: "#00AAFF",
metadata CHANGED
@@ -1,49 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gmaps4rails
3
- version: !ruby/object:Gem::Version
4
- hash: 13
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.6
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 5
10
- version: 1.4.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Benjamin Roth
14
9
  - David Ruyer
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-02-02 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-03-07 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: json
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2153339940 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
33
23
  type: :runtime
34
- version_requirements: *id001
35
- description: "Enables easy display of items (taken from a Rails 3 model) on a Google Maps (JS API V3), OpenLayers, Mapquest and Bing. Geocoding + Directions included. Provides much options: markers customization, infowindows, auto-adjusted zoom, polylines, polygons, circles etc... See wiki on github for full description and examples."
36
- email:
24
+ prerelease: false
25
+ version_requirements: *2153339940
26
+ description: ! 'Enables easy display of items (taken from a Rails 3 model) on a Google
27
+ Maps (JS API V3), OpenLayers, Mapquest and Bing. Geocoding + Directions included.
28
+ Provides much options: markers customization, infowindows, auto-adjusted zoom, polylines,
29
+ polygons, circles etc... See wiki on github for full description and examples.'
30
+ email:
37
31
  - apnea.diving.deep@gmail.com
38
32
  - david.ruyer@gmail.com
39
33
  executables: []
40
-
41
34
  extensions: []
42
-
43
- extra_rdoc_files:
35
+ extra_rdoc_files:
44
36
  - LICENSE.txt
45
37
  - README.rdoc
46
- files:
38
+ files:
47
39
  - app/assets/javascripts/gmaps4rails/all_apis.js
48
40
  - app/assets/javascripts/gmaps4rails/bing.js
49
41
  - app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee
@@ -80,36 +72,27 @@ files:
80
72
  - README.rdoc
81
73
  homepage: http://github.com/apneadiving/Google-Maps-for-Rails
82
74
  licenses: []
83
-
84
75
  post_install_message:
85
76
  rdoc_options: []
86
-
87
- require_paths:
77
+ require_paths:
88
78
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
79
+ required_ruby_version: !ruby/object:Gem::Requirement
90
80
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
98
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
86
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
107
91
  requirements: []
108
-
109
92
  rubyforge_project:
110
- rubygems_version: 1.8.15
93
+ rubygems_version: 1.8.6
111
94
  signing_key:
112
95
  specification_version: 3
113
- summary: Enables easy display of items (taken from a Rails 3 model) on a Google Maps (JS API V3), OpenLayers, Mapquest and Bing. Geocoding + Directions included.
96
+ summary: Enables easy display of items (taken from a Rails 3 model) on a Google Maps
97
+ (JS API V3), OpenLayers, Mapquest and Bing. Geocoding + Directions included.
114
98
  test_files: []
115
-