 # A network consists of all the links, nodes, sensors, controllers
 # events, and signals along a route. It uses the google api Directions
 # Service to determine the route by passing the service
-# a set of latitude and longitudes along the route(waypoints). Due to 
-# limitations in the google service, you'll notice that we need to make 
-# multiple calls to the routes for every 8 waypoints.
+# a set of latitude and longitudes along the route(waypoints). 
 #
 # The class also creates and then triggers the rendering of the treeView 
 # of the scenario elements.
 class window.sirius.MapNetworkView extends Backbone.View
-  wypnts = []
-  network_begin_end = []
   $a = window.sirius
   
   initialize: (@scenario) ->

      )
    )
  
  # # This method is used to determine the begin and end points
  #   # of each link as well as to store the waypoints used to
  #   # get an accurate path from the beginning to the end of each link
  #   _linkInformationForMap: ->
  #     self = @
  #     _.each(self.network.get('linklist').get('link'), (link) -> 
  #       @begin =  link.get('begin').get('node')
  #       @end = link.get('end').get('node')
  #       self._determineWayPointsAndNetworkStartEnd(@begin,@end)
  #     )
  # 
  #   # Called by _linkInformationForMap to determine if begin or end are
  #   # the terminal points of the link and if not to push the begin point
  #   # into the waypoints array
  #   _determineWayPointsAndNetworkStartEnd: (begin,end) ->
  #       #if it is not a terminal node, then it is a waypoint for the directions request
  #       if begin.get("type") != "terminal"
  #         wypnts.push { location:$a.Util.getLatLng(begin) }
  #       else
  #         network_begin_end.push $a.Util.getLatLng(begin)
  # 
  #       if end.get("type") == "terminal"
  #         network_begin_end.push $a.Util.getLatLng(end)

  # These methods instantiate each elements view instance in the map
  _drawLinks: (links) ->

    @_drawRoute()
  
  # _drawRoute uses the Google Direction's api to get the data used to render the route.
  _drawRoute: ->
    directionsService = new google.maps.DirectionsService()
    self = @
    _.each(self.network.get('linklist').get('link'), (link) -> 
      begin =  link.get('begin').get('node')
      end = link.get('end').get('node')
      #Create DirectionsRequest using DRIVING directions.
      request = {
        origin: $a.Util.getLatLng(begin),
        destination: $a.Util.getLatLng(end),
        travelMode: google.maps.TravelMode.DRIVING,
      }
      #Route the directions and pass the response to a
      #function to draw the full link for each step.
      directionsService.route(request, (response, status) =>
        if (status == google.maps.DirectionsStatus.OK)
          warnings = $("#warnings_panel")
