socmap_adf 0.0.3 → 0.0.4

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/.rvmrc CHANGED
@@ -4,7 +4,7 @@
4
4
  # development environment upon cd'ing into the directory
5
5
 
6
6
  # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
- environment_id="ruby-1.9.3-p125@rails32"
7
+ environment_id="ruby-1.9.3@rails32"
8
8
 
9
9
  #
10
10
  # Uncomment the following lines if you want to verify rvm version per project
@@ -3,7 +3,7 @@ class ADF.GMap.Views.Overlay extends google.maps.OverlayView
3
3
  hidden: true
4
4
  topPoint: null
5
5
  zindex: 1
6
- body: "body"
6
+ divPixel: null
7
7
 
8
8
  constructor: (map, view) ->
9
9
  @map = map
@@ -14,7 +14,6 @@ class ADF.GMap.Views.Overlay extends google.maps.OverlayView
14
14
  @hoverable = @view.hoverable
15
15
  @showAfterDrag = @view.showAfterDrag
16
16
  @view.overlay = @
17
- @body = @view.body if @view.body?
18
17
  @initMarker()
19
18
  @bindMapEvents()
20
19
 
@@ -164,6 +163,9 @@ class ADF.GMap.Views.Overlay extends google.maps.OverlayView
164
163
  getPosition: () ->
165
164
  @view.point
166
165
 
166
+ getDivPixel: () ->
167
+ @divPixel
168
+
167
169
  # = From OverlayView
168
170
  onAdd: ->
169
171
  @div = @view.render().el
@@ -171,23 +173,23 @@ class ADF.GMap.Views.Overlay extends google.maps.OverlayView
171
173
  @pane = @getPanes().overlayLayer
172
174
  @pane.appendChild(@div)
173
175
  else
174
- $(@body).append(@div)
176
+ $(@view.getMapElement()).append(@div)
175
177
  @view.onMarkerAdded(@view.point)
176
178
 
177
179
  draw: () ->
178
180
  overlayProjection = @getProjection()
179
181
  if (overlayProjection != null && overlayProjection != undefined && @view.point)
180
182
  if @view.asLabel
181
- divPixel = overlayProjection.fromLatLngToDivPixel(@view.point)
183
+ @divPixel = overlayProjection.fromLatLngToDivPixel(@view.point)
182
184
  else
183
- divPixel = overlayProjection.fromLatLngToContainerPixel(@view.point)
185
+ @divPixel = overlayProjection.fromLatLngToContainerPixel(@view.point)
184
186
 
185
- @left = divPixel.x + @view.left - (@view.getWidth() / 2)
187
+ @left = @divPixel.x + @view.left - (@view.getWidth() / 2)
186
188
 
187
189
  if @view.overlayPositionVertical == "top"
188
- @top = divPixel.y + @view.top - @view.getHeight()
190
+ @top = @divPixel.y + @view.top - @view.getHeight()
189
191
  else
190
- @top = divPixel.y + @view.top
192
+ @top = @divPixel.y + @view.top
191
193
 
192
194
  if @top < 0
193
195
  point = new google.maps.Point(@left, (@top / 2) + ($(window).height() / 2))
@@ -64,7 +64,6 @@ class ADF.GMap.Views.OverlayView extends ADF.MVC.Views.Base
64
64
  redraw: () ->
65
65
  @overlay.draw()
66
66
 
67
-
68
67
  isClustering: () ->
69
68
  @clustering
70
69
 
@@ -75,6 +74,9 @@ class ADF.GMap.Views.OverlayView extends ADF.MVC.Views.Base
75
74
  @overlay = new ADF.GMap.Views.Overlay(@map.getGMap(), @)
76
75
  @map.addOverlay(@overlay)
77
76
 
77
+ getMapElement: () ->
78
+ @map.getMapElement()
79
+
78
80
  addOrChangeLocation: (point) ->
79
81
  @point = point
80
82
  if @overlay
@@ -5,6 +5,7 @@ class ADF.Map.Models.Map extends Backbone.Model
5
5
 
6
6
  maxZoomLevelForClustering: 21
7
7
  maxZoomOnClick: 18
8
+ mapElement: null
8
9
 
9
10
  defaults:
10
11
  center: new google.maps.LatLng(57,25)
@@ -28,7 +29,8 @@ class ADF.Map.Models.Map extends Backbone.Model
28
29
  @clusterOptions = $.extend(@clusterDefaults, clusterOptions)
29
30
 
30
31
  initGMap: (mapElement) ->
31
- @map = new google.maps.Map(document.getElementById(mapElement), @attributes)
32
+ @mapElement = mapElement
33
+ @map = new google.maps.Map(document.getElementById(@mapElement), @attributes)
32
34
  @markerClusterer = new ADF.Cluster.Views.MarkerClusterer(@map, null, @clusterOptions)
33
35
  @loadOSM() if @get("mapTypeId") == "OSM"
34
36
  return @map
@@ -39,6 +41,9 @@ class ADF.Map.Models.Map extends Backbone.Model
39
41
 
40
42
  getGMap: () ->
41
43
  return @map
44
+
45
+ getMapElement: () ->
46
+ return $("##{@mapElement}")
42
47
 
43
48
  addOverlay: (overlay, clustering = false) ->
44
49
  @overlays.push(overlay)
@@ -64,6 +69,13 @@ class ADF.Map.Models.Map extends Backbone.Model
64
69
  @overlays = []
65
70
  @markerClusterer.clearMarkers()
66
71
 
72
+ getOverlays: () ->
73
+ @overlays
74
+
75
+ hideAllOverlays: () ->
76
+ for overlay in @overlays
77
+ overlay.hide()
78
+
67
79
  clusterOverlay: (overlay) ->
68
80
  @markerClusterer.addMarker(overlay) if @markerClusterer
69
81
 
@@ -1,6 +1,8 @@
1
1
  class ADF.Minimap.Models.Minimap extends Backbone.Model
2
2
 
3
3
  overlays: []
4
+
5
+ mapElement: null
4
6
 
5
7
  defaults:
6
8
  center: new google.maps.LatLng(57,25)
@@ -15,15 +17,26 @@ class ADF.Minimap.Models.Minimap extends Backbone.Model
15
17
  streetViewControl: false
16
18
 
17
19
  initGMap: (mapElement) ->
18
- @map = new google.maps.Map(document.getElementById(mapElement), @attributes)
20
+ @mapElement = mapElement
21
+ @map = new google.maps.Map(document.getElementById(@mapElement), @attributes)
19
22
  return @map
20
23
 
21
24
  getGMap: () ->
22
25
  return @map
26
+
27
+ getMapElement: () ->
28
+ return $("##{@mapElement}")
23
29
 
24
30
  addOverlay: (overlay) ->
25
31
  @overlays.push(overlay)
26
32
 
33
+ getOverlays: () ->
34
+ @overlays
35
+
36
+ hideAllOverlays: () ->
37
+ for overlay in @overlays
38
+ overlay.hide()
39
+
27
40
  setCenter: (latLng) ->
28
41
  @map.setCenter(latLng)
29
42
 
@@ -0,0 +1,49 @@
1
+ class ADF.Overlay.Views.FlashOverlay extends ADF.GMap.Views.OverlayView
2
+
3
+ opened: false
4
+ hoverable: true
5
+ top: -60
6
+ left: 0
7
+
8
+ constructor: (options) ->
9
+ super(options)
10
+ @clickable = false
11
+ @pushOverlay()
12
+
13
+ onMarkerMouseOver: () =>
14
+ @openOverlayOnHover()
15
+
16
+ onMarkerMouseOut: () =>
17
+ @hideOverlayAfterTime()
18
+
19
+ openOverlayOnHover: () =>
20
+ @map.hideAllOverlays()
21
+ @opened = true
22
+ @calculatePosition()
23
+ @show()
24
+
25
+ hideOverlayIfNeeded: () =>
26
+ @hide() if !@opened
27
+
28
+ hideOverlayAfterTime: () =>
29
+ @opened = false
30
+ setTimeout(@hideOverlayIfNeeded, 1000)
31
+
32
+ onRenderCompleted: () =>
33
+ $(@el).hover(@openOverlayOnHover, @hideOverlayAfterTime)
34
+
35
+ calculatePosition: () ->
36
+ arr = @getPositionArray()
37
+ @setPosition(arr[0], arr[1])
38
+
39
+ getPositionArray: () ->
40
+ halfWidth = @map.getMapElement().width() / 2
41
+ halfHeight = @map.getMapElement().height() / 2
42
+ divPixel = @overlay.getDivPixel()
43
+ w = @getWidth() / 2
44
+ h = @getHeight()
45
+
46
+ return [h, w] if divPixel.x <= halfWidth && divPixel.y < halfHeight
47
+ return [h, -w] if divPixel.x > halfWidth && divPixel.y < halfHeight
48
+ return [@top, w] if divPixel.x <= halfWidth && divPixel.y >= halfHeight
49
+ return [@top, -w] if divPixel.x > halfWidth && divPixel.y >= halfHeight
@@ -1,3 +1,3 @@
1
1
  module SocmapAdf
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socmap_adf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-10-08 00:00:00.000000000 Z
14
+ date: 2012-10-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -141,6 +141,7 @@ files:
141
141
  - lib/assets/javascripts/socmap_adf/modules/overlay/templates/main.jst.eco
142
142
  - lib/assets/javascripts/socmap_adf/modules/overlay/templates/polygon_label.jst.eco
143
143
  - lib/assets/javascripts/socmap_adf/modules/overlay/views/.DS_Store
144
+ - lib/assets/javascripts/socmap_adf/modules/overlay/views/flash_overlay.coffee
144
145
  - lib/assets/javascripts/socmap_adf/modules/overlay/views/main.js.coffee
145
146
  - lib/assets/javascripts/socmap_adf/modules/overlay/views/overlay.js.coffee
146
147
  - lib/assets/javascripts/socmap_adf/modules/overlay/views/polygon_label.js.coffee
@@ -196,12 +197,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
197
  - - ! '>='
197
198
  - !ruby/object:Gem::Version
198
199
  version: '0'
200
+ segments:
201
+ - 0
202
+ hash: -4555781509594738467
199
203
  required_rubygems_version: !ruby/object:Gem::Requirement
200
204
  none: false
201
205
  requirements:
202
206
  - - ! '>='
203
207
  - !ruby/object:Gem::Version
204
208
  version: '0'
209
+ segments:
210
+ - 0
211
+ hash: -4555781509594738467
205
212
  requirements: []
206
213
  rubyforge_project: socmap_adf
207
214
  rubygems_version: 1.8.24