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

Using onAdd and onRemove to support layer control #64

Open
asneuvon opened this issue Jul 25, 2016 · 1 comment
Open

Using onAdd and onRemove to support layer control #64

asneuvon opened this issue Jul 25, 2016 · 1 comment

Comments

@asneuvon
Copy link

First of all, thanks for a great package, solved a real problem for me!

But: The ArcGIS Server layer (lvector.AGS) didn't seem to support adding it into a layer control i.e. letting the user check it visible and invisible in a list of contents. I experimented a bit and ti would seem to me that this functionality can easily be included by adding following methods the Layer.js:

onAdd: function(o){
    this._show();
},

onRemove: function(o){
    this._hide();
},

Worked for me at least. However, I couldn't figure out how to set the layer invisible by code (this would be the default state when adding the layer)...

@devinpatterson
Copy link

i just did the same for GISCloud, for me i just added these to the bottom of lvector.js

lvector.GISCloud.prototype.onAdd = function() {
this.setMap(window.map);
};
lvector.GISCloud.prototype.onRemove = function() {
this._hide();
this.setMap(null);
};

and changed this piece:

_hide: function() {
this._idleListener && this.options.map.off("moveend", this._idleListener);
this._zoomChangeListener && this.options.map.off("zoomend", this._zoomChangeListener);
this._autoUpdateInterval && clearInterval(this._autoUpdateInterval);
this._clearFeatures();
this._lastQueriedBounds = null;
if (this._gotAll) this._gotAll = !1
},

to this:

_hide: function() {
this._idleListener && this.options.map.off("moveend", this._idleListener, this);
this._zoomChangeListener && this.options.map.off("zoomend", this._zoomChangeListener, this);
this._autoUpdateInterval && clearInterval(this._autoUpdateInterval);
this._clearFeatures();
this._lastQueriedBounds = null;
if (this._gotAll) this._gotAll = !1
},

should work for all the other sources.

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

2 participants