aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts/access_points.js.coffee
blob: 74c5e926f5f54505391ca53254f612d425679d09 (plain)
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
jQuery ->
  x_y_change = (event) -> 
    if referential_projection != undefined
      referential_point = new OpenLayers.Geometry.Point($('input#access_point_longitude').val(), $('input#access_point_latitude').val()).transform(new OpenLayers.Projection("EPSG:4326"), referential_projection )      
      
      $('input#access_point_x').val(referential_point.x)
      $('input#access_point_y').val(referential_point.y)
          
    feature = map.getLayersByName("access_point")[0].getFeatureByFid($('input#access_point_id').val())  
    google_point = new OpenLayers.LonLat($('input#access_point_longitude').val(), $('input#access_point_latitude').val()).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())
    feature.move(google_point)
    map.setCenter(google_point, 16, false, true)      

  $('input#access_point_longitude').change(x_y_change)
  $('input#access_point_latitude').change(x_y_change)
   
  lon_lat_change = (event) -> 
    if referential_projection != undefined
      wgs84_point = new OpenLayers.Geometry.Point($('input#access_point_x').val(), $('input#access_point_y').val()).transform(referential_projection, new OpenLayers.Projection("EPSG:4326"))    
     
      $('input#access_point_longitude').val( wgs84_point.x)
      $('input#access_point_latitude').val( wgs84_point.y)

    feature = map.getLayersByName("stop_area")[0].getFeatureByFid($('input#access_point_id').val())  
    google_point =  new OpenLayers.LonLat(wgs84_point.x, wgs84_point.y).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())
    feature.move(google_point)
    map.setCenter(google_point, 16, false, true)      

  $('input#access_point_x').change(lon_lat_change)
  $('input#access_point_y').change(lon_lat_change)
  
  
  # switch visibility of access_links
  switch_generics = (event) -> 
    event.preventDefault()
    $('.access_points .generics.content').toggle('slow')
    $('a.generics .switcher').toggle()

  $('.access_points a.generics').click(switch_generics)

  switch_details = (event) -> 
    event.preventDefault()
    $('.access_points .details.content').toggle('slow')
    $('a.details .switcher').toggle()

  $('.access_points a.details').click(switch_details)