aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gmap_arcgis.js50
1 files changed, 29 insertions, 21 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index e7042fd..61bee34 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -2,26 +2,24 @@
function gmapArcgis(config) {
return {
- config: config,
-
- map: config.map,
-
- slider: [],
+ // Storable properties
+ config: config,
+ map: config.map,
+ slider: [],
// Set the current map
setMap: function(map) {
this.map = map;
},
+ // Get the default opacity of an layer element
+ defaultOpacity: function(element) {
+ return (this.config['layers'][element].opacity != undefined) ? this.config['layers'][element].opacity : 0.55;
+ },
+
// Add polygons from a given ArcGIS MapServer Layer
showPolygon: function(element) {
- var defaultOpacity = (this.config['layers'][element].opacity != undefined) ? this.config['layers'][element].opacity : 0.55;
-
- if (typeof this.config['layers'][element].overlay != 'undefined') {
- this.config['layers'][element].overlay.setOpacity(defaultOpacity);
- this.unblockUI();
- return;
- }
+ var defaultOpacity = this.defaultOpacity(element);
uri = this.config['layers'][element]['uri'];
layers = this.config['layers'][element]['layers'];
@@ -53,13 +51,15 @@ function gmapArcgis(config) {
showKML: function(element) {
this.config['kmls'][element].overlay = new google.maps.KmlLayer(this.config['kmls'][element].uri);
this.config['kmls'][element].overlay.setMap(this.map);
+ this.config['kmls'][element].isVisible = true;
},
// Add a KML layer into the map
addKML: function(element) {
if (typeof this.config['kmls'][element].overlay != 'undefined') {
- this.config['kmls'][element].overlay.setOpacity(this.config['kmls'][element].opacity);
- unblockUI();
+ this.config['kmls'][element].overlay.setMap(this.map);
+ this.config['kmls'][element].isVisible = true;
+ this.unblockUI();
return this.config['kmls'][element].overlay;
}
@@ -72,8 +72,10 @@ function gmapArcgis(config) {
// Add a layer to the map
addLayers: function(element) {
+ var defaultOpacity = this.defaultOpacity(element);
+
if (typeof this.config['layers'][element].overlay != 'undefined') {
- this.config['layers'][element].overlay.setOpacity(this.config['layers'][element].opacity);
+ this.config['layers'][element].overlay.setOpacity(this.config['layers'][element].defaultOpacity);
this.unblockUI();
return this.config['layers'][element].overlay;
}
@@ -169,9 +171,16 @@ function gmapArcgis(config) {
},
// Toggle KML visibility
- toggleKML: function(params) {
- // TODO
- return;
+ toggleKML: function(element) {
+ if (this.config['kmls'][element].overlay == undefined) {
+ return;
+ } else if (this.config['kmls'][element].isVisible == true) {
+ this.config['kmls'][element].isVisible = false;
+ this.config['kmls'][element].overlay.setMap();
+ } else {
+ this.config['kmls'][element].isVisible = true;
+ this.config['kmls'][element].overlay.setMap(this.map);
+ }
},
// Toggle layer visibility
@@ -253,7 +262,7 @@ function gmapArcgis(config) {
},
// Setup slider
- activateSlider: function() {
+ slider: function() {
var self = this;
// Max is the number of layers in the service
@@ -263,8 +272,7 @@ function gmapArcgis(config) {
max: 11,
step: 1,
animate: true,
- //change: sliderUpdate,
- change: function(event, ui) {
+ change: function(event, ui) {
self.sliderUpdate.call(self, ui.value);
},
});