aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-07-23 15:56:18 -0300
committerSilvio <silvio@socioambiental.org>2013-07-23 15:56:18 -0300
commit3f98458bec76087a6acc3c0ee58a1544192e4100 (patch)
tree484819641d983a8222a7c63bd1fbf92c12f61517
parenta40c14d2e6070972d5af9fb4972ae61f18744a00 (diff)
downloadgmap_arcgis_js-3f98458bec76087a6acc3c0ee58a1544192e4100.tar.gz
gmap_arcgis_js-3f98458bec76087a6acc3c0ee58a1544192e4100.tar.bz2
toggleLayers shall really toggle and not just hide layers
-rw-r--r--gmap_arcgis.js30
1 files changed, 25 insertions, 5 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index 70adb19..81df878 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -227,7 +227,11 @@ function gmapArcgis(config) {
this.config['layers'][element].opacity = this.defaultOpacity(element);
if (typeof this.config['layers'][element].overlay != 'undefined') {
- if (this.config['layers'][element].overlay.setOpacity != undefined) {
+ if (this.config['layers'][element].overlay.setVisible != undefined) {
+ this.config['layers'][element].overlay.setVisible(true);
+ this.identifyPolygon(this.config['layers'][element]);
+ }
+ else if (this.config['layers'][element].overlay.setOpacity != undefined) {
this.config['layers'][element].overlay.setOpacity(this.config['layers'][element].opacity);
this.identifyPolygon(this.config['layers'][element]);
}
@@ -362,16 +366,32 @@ function gmapArcgis(config) {
},
// Toggle layer visibility
- // TODO: it should really toggle and not just hide layers
toggleLayers: function(element) {
- if (this.config['layers'][element].overlay.setOpacity != undefined) {
- this.config['layers'][element].overlay.setOpacity(0);
+ if (this.config['layers'][element].overlay.setVisible != undefined) {
+ var changeTo = !this.config['layers'][element].overlay.getVisible();
+ this.config['layers'][element].overlay.setVisible(changeTo);
+ }
+ else if (this.config['layers'][element].overlay.setOpacity != undefined) {
+ var opacity = this.config['layers'][element].overlay.getOpacity;
+
+ if (opacity == 0) {
+ opacity = this.config['layers'][element].opacity;
+ }
+ else {
+ opacity = 0;
+ }
+
+ this.config['layers'][element].overlay.setOpacity(opacity);
}
else if (this.config['layers'][element].overlay[0] != undefined) {
for (i=0; i < this.config['layers'][element].overlay.length; i++) {
- this.config['layers'][element].overlay[i].setVisible(false);
+ var changeTo = !this.config['layers'][element].overlay[i].getVisible();
+ this.config['layers'][element].overlay[i].setVisible(changeTo);
}
}
+ else {
+ console.log(this.config['layers'][element].overlay);
+ }
if (this.config['layers'][element].identifyListener != undefined) {
google.maps.event.removeListener(this.config['layers'][element].identifyListener);