gabesmed / ember-leaflet

Ember + Leaflet = Fun with maps
gabesmed.github.io/ember-leaflet
MIT License
164 stars 35 forks source link

Delay tolerant computed optionProperty #55

Closed miguelcobain closed 10 years ago

miguelcobain commented 10 years ago

Like stated on #38, something similar is needed for option properties.

How hard could this be?

gabesmed commented 10 years ago

There's actually some code for this already: look in utils.js: EmberLeaflet.computed.optionProperty.

Is there a specific option you'd like to be added to the default options that have convenient bindings?

miguelcobain commented 10 years ago

Actually, there is a problem with icon binding (which is pretty useful):

When you change icon in leaflet, you lose the draggability. So you need to restore it.

I use this code:

  iconBinding: 'content.icon',
  _updateLayerOnIconChange: Ember.observer(function(){
    var newIcon = get(this, 'icon');
    var oldIcon = this._layer && this._layer.options.icon;
    if(oldIcon && newIcon && oldIcon !== newIcon) {
      var draggable = this._layer.dragging.enabled();
      this._layer.setIcon(newIcon);
      if(draggable) this._layer.dragging.enable();
      else this._layer.dragging.disable();
    }
  }, 'content.icon'),

I don't have much time right now, but it would be nice to have failing tests for this.

gabesmed commented 10 years ago

oh nice good call. making a separate issue for this.

miguelcobain commented 10 years ago

@gabesmed, from what I can tell, the optionProperty isn't delay tolerant yet. Am I right?

Like @codefox421 stated in #38: "If the layer does not exist, propagate style changes to the layer once it exists".

gabesmed commented 10 years ago

Yeah I don't think it is. But styleProperty and pathStyleProperty are, and tested. And optionProperty could be made to be.

miguelcobain commented 10 years ago

This issue is about optionProperty, so I think it should be reopened. I'll try to tackle this in the next days.