src/geo/gmaps/gmaps.geometry.js
/**
 * view for other geometries (polygons/lines)
 */
view for other geometries (polygons/lines)
view for other geometries ( polygons / lines )
function PathView(geometryModel) {
  var self = this;
  var events = [
    'click',
    'dblclick',
    'mousedown',
    'mouseover',
    'mouseout',
  ];
  this._eventHandlers = {};
  this.model = geometryModel;
  this.points = [];
  var style = _.clone(geometryModel.get('style')) || {};
  this.geom = new GeoJSON (
    geometryModel.get('geojson'),
    style
  );
  _.bindAll(this, '_updateModel');
  var self = this;
  function bindPath(p) {
    google.maps.event.addListener(p, 'insert_at', self._updateModel);
  }
  if(this.geom.getPaths) {
    var paths = this.geom.getPaths();
    if (paths && paths[0]) {
      for(var i = 0; i < paths.length; ++i) {
        bindPath(paths[i]);
      }
    } else {
      bindPath(paths);
      google.maps.event.addListener(this.geom, 'mouseup', this._updateModel);
    }
  } else {
    if (this.geom.length) {
      for(var i = 0; i < this.geom.length; ++i) {
        bindPath(this.geom[i].getPath());
        google.maps.event.addListener(this.geom[i], 'mouseup', this._updateModel);
      }
    } else {
      bindPath(this.geom.getPath());
      google.maps.event.addListener(this.geom, 'mouseup', this._updateModel);
    }
  }
}
function PathView ( geometryModel ) { var self = this ; var events = [ 'click' , 'dblclick' , 'mousedown' , 'mouseover' , 'mouseout' , ] ; this . _eventHandlers = { } ; this . model = geometryModel ; this . points = [ ] ; var style = _ . clone ( geometryModel . get ( 'style' ) ) || { } ; this . geom = new GeoJSON ( geometryModel . get ( 'geojson' ) , style ) ; _ . bindAll ( this , '_updateModel' ) ; var self = this ; function bindPath ( p ) { google . maps . event . addListener ( p , 'insert_at' , self . _updateModel ) ; } if ( this . geom . getPaths ) { var paths = this . geom . getPaths ( ) ; if ( paths && paths [ 0 ] ) { for ( var i = 0 ; i < paths . length ; ++ i ) { bindPath ( paths [ i ] ) ; } } else { bindPath ( paths ) ; google . maps . event . addListener ( this . geom , 'mouseup' , this . _updateModel ) ; } } else { if ( this . geom . length ) { for ( var i = 0 ; i < this . geom . length ; ++ i ) { bindPath ( this . geom [ i ] . getPath ( ) ) ; google . maps . event . addListener ( this . geom [ i ] , 'mouseup' , this . _updateModel ) ; } } else { bindPath ( this . geom . getPath ( ) ) ; google . maps . event . addListener ( this . geom , 'mouseup' , this . _updateModel ) ; } } }
view for other geometries (polygons/lines)
view for other geometries ( polygons / lines )
// events to link /*_.each(this.geom._layers, function(g) {
    g.setStyle(geometryModel.get('style'));
    g.on('edit', function() {
      geometryModel.set('geojson', L.GeoJSON.toGeoJSON(self.geom));
    }, self);
  });
  */ /*
    google.maps.event.addListener(p, 'remove_at', this._updateModel);
    google.maps.event.addListener(p, 'set_at', this._updateModel);
    */ // TODO: check this conditions // More than one path // One path // More than one path // One path /*for(var i = 0; i < events.length; ++i) {
    var e = events[i];
    this.geom.on(e, self._eventHandler(e));
  }*/