Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngeoDecorate*: two way binding ? #101

Closed
fredj opened this issue Nov 20, 2014 · 8 comments
Closed

ngeoDecorate*: two way binding ? #101

fredj opened this issue Nov 20, 2014 · 8 comments

Comments

@fredj
Copy link
Member

fredj commented Nov 20, 2014

For now, the ngeoDecorate* services offer a one way binding (angular to ol3).
Is it planned to have a two way binding (ol3 to angular) ?

@elemoine
Copy link
Contributor

Yes why not. Do you have a specific use-case in mind?

@fgravin
Copy link
Member

fgravin commented Nov 20, 2014

We can do it with handling some ol events maybe, but take care of infinite loop !

@fredj
Copy link
Member Author

fredj commented Nov 20, 2014

Yes why not. Do you have a specific use-case in mind?

A ngeoDecorateView for example

@elemoine
Copy link
Contributor

Yes why not. Do you have a specific use-case in mind?

A ngeoDecorateView for example

I was wondering about an application use-case.

Also, we could extend the ngeoDecorateGeolocation service to add a position property to the passed ol.Geolocation instance. This would also require binding in the other direction (ol3 -> angular).

I'd rather wait for specific use-cases before implementing this though, this is why I was asking if you had any.

@fredj
Copy link
Member Author

fredj commented Nov 20, 2014

I was wondering about an application use-case.

Display the view rotation in a text element:

<span>{{view.rotation}}</span>

@elemoine
Copy link
Contributor

Ok.

Note that for view.center we'd need some debouncing, not to incur a digest cycle on each frame (when the map is panned or animates). We introduced an ngeoDebounce service that could be used there as well.

@elemoine
Copy link
Contributor

@fredj, I guess making this work would just require triggering a digest cycle when the ol3 property changes. For example, this is what the ngeoDecorateLayer would do for the visible property:

    goog.events.listen(layer, ol.Object.getChangeEventType('visible'),
        /**
         * @type {ol.ObjectEvent} e Object event.
         */
        function(e) {
            $rootScope.$digest();
        }, false, this);

As I said, we'd need to be careful for the view center, because we don't want to trigger a digest every time the center changes while dragging the map.

What we could possibly do is add a boolean option/argument to the ngeoDecorate* functions.

@elemoine
Copy link
Contributor

Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants