aboutsummaryrefslogtreecommitdiff
path: root/gmap_arcgis.js
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2012-11-14 14:33:47 -0200
committerSilvio <silvio@socioambiental.org>2012-11-14 14:33:47 -0200
commit7738b0f7b99eeeeaab3d9467928e63d7b59383dd (patch)
tree52f088c7fcf9bf2d5376cab936797a725dccb3a5 /gmap_arcgis.js
parent1def03804a2081c0d0825279b526fa306eb14707 (diff)
downloadgmap_arcgis-7738b0f7b99eeeeaab3d9467928e63d7b59383dd.tar.gz
gmap_arcgis-7738b0f7b99eeeeaab3d9467928e63d7b59383dd.tar.bz2
Adding gmapArcgisShowPolygons() and gmapArcgisHidePolygons()
Diffstat (limited to 'gmap_arcgis.js')
-rw-r--r--gmap_arcgis.js47
1 files changed, 32 insertions, 15 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index a5774ce..eb90428 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -4,7 +4,7 @@
google.load("maps", "2.x");
// Global variables
-var map, mapExtension, gOverlays,markers,pol;
+var map, mapExtension, gOverlays;
// Setup custom GMap Overlays (layers and labels)
function gmap_arcgis() {
@@ -22,10 +22,6 @@ function gmap_arcgis() {
// Get data from Drupal
if (Drupal.settings.gmap_arcgis !== undefined) {
- // Get array of polygons
- if (Drupal.settings.gmap_arcgis.polygons !== undefined) {
- polygons = Drupal.settings.gmap_arcgis.polygons;
- }
// Get array of labels
if (Drupal.settings.gmap_arcgis.labels !== undefined) {
labels = Drupal.settings.gmap_arcgis.labels;
@@ -73,9 +69,7 @@ function gmap_arcgis() {
showLabels(label[0], fields, content, icon);
}
- for (j = 0; j < polygons.length; j++) {
- showPolygons(polygons[j]['base'] + polygons[j]['service'], polygons[j]['layers']);
- }
+ gmapArcgisShowPolygons(Drupal.settings.gmap_arcgis.polygons);
}, 5);
//setTimeout($.unblockUI, 10000);
@@ -121,20 +115,43 @@ function showLabelsCallback(fields, content, icon) {
}
}
+// Show all defined polygons
+function gmapArcgisShowPolygons(polygons) {
+ for (j = 0; j < polygons.length; j++) {
+ //showPolygons(polygons[j]['base'] + polygons[j]['service'], polygons[j]['layers']);
+ showPolygon(polygons[j]);
+ }
+}
+
+// Hide all defined polygons
+function gmapArcgisHidePolygons(polygons) {
+ for (j = 0; j < polygons.length; j++) {
+ polygons[j].overlay.hide();
+ }
+}
+
// Add polygons from a given ArcGIS MapServer Layer
-function showPolygons(uri, layers = undefined) {
- pol = new esri.arcgis.gmaps.DynamicMapServiceLayer(uri, null, 0.55);
+function showPolygon(polygon) {
+ if (polygon.overlay != undefined) {
+ polygon.overlay.show();
+ return;
+ }
+
+ uri = polygon['base'] + polygon['service'];
+ layers = polygon['layers'];
+
+ polygon.overlay = new esri.arcgis.gmaps.DynamicMapServiceLayer(uri, null, 0.55);
if (layers != undefined || layers == []) {
- pol.setVisibleLayers(layers);
+ polygon.overlay.setVisibleLayers(layers);
}
- //GEvent.addListener(pol,"load",function(g) { map.addOverlay(g);setTimeout($.unblockUI, 6000);});
- GEvent.addListener(pol, "load", showPolygonsCallback);
+ //GEvent.addListener(polygon.overlay,"load",function(g) { map.addOverlay(g);setTimeout($.unblockUI, 6000);});
+ GEvent.addListener(polygon.overlay, "load", showPolygonCallback);
}
-// Callback for showPolygons
-function showPolygonsCallback(mapservicelayer, error) {
+// Callback for showPolygon
+function showPolygonCallback(mapservicelayer, error) {
map.addOverlay(mapservicelayer);
setTimeout($.unblockUI, 6000);
}