Sha256: aaa747c1928068c4e01637093b503837b25fda525689b9e85db555407b7bf5f9

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

class @Gmaps4Rails.Openlayers.Polyline extends Gmaps4Rails.Common

  @include Gmaps4Rails.Interfaces.Basic

  @include Gmaps4Rails.Openlayers.Shared
  @extend  Gmaps4Rails.Polyline.Class
  @extend  Gmaps4Rails.Configuration

 #creates a single polyline, triggered by create_polylines
  constructor : (polyline, controller) ->
    @controller = controller
    @controller._createPolylinesLayer()

    polyline_coordinates = []

    for element in polyline
      #by convention, a single polyline could be customized in the first array or it uses default values
      if element == polyline[0]
        strokeColor   = element.strokeColor   || @controller.polylines_conf.strokeColor
        strokeOpacity = element.strokeOpacity || @controller.polylines_conf.strokeOpacity
        strokeWeight  = element.strokeWeight  || @controller.polylines_conf.strokeWeight
        clickable     = element.clickable     || @controller.polylines_conf.clickable
        zIndex        = element.zIndex        || @controller.polylines_conf.zIndex   
      
      #add latlng if positions provided
      if element.lat? && element.lng?
        latlng = new OpenLayers.Geometry.Point(element.lng, element.lat)
        polyline_coordinates.push(latlng)
    
    line_points = new OpenLayers.Geometry.LineString(polyline_coordinates);
    line_style = { strokeColor: strokeColor, strokeOpacity: strokeOpacity, strokeWidth: strokeWeight };
   
    @serviceObject = new OpenLayers.Feature.Vector(line_points, null, line_style);
    @serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"))

    @controller.polylinesLayer.addFeatures([@serviceObject])

  isVisible: ->
    true

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gmaps4rails-2.0.0.pre vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee