aboutsummaryrefslogtreecommitdiff
path: root/gmap_arcgis.js
diff options
context:
space:
mode:
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);
}