aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsilvio <silvio@gota.(none)>2010-01-26 11:55:28 -0200
committersilvio <silvio@gota.(none)>2010-01-26 11:55:28 -0200
commit50f4e6298d6fb06fa2f3276308629b48d2dad5ee (patch)
tree2efdb47bbcf7b42333dcef18383c65175600ca81
parentb7f6ea207c769e21a98064641fd50e0d98889706 (diff)
downloadgmap_arcgis-50f4e6298d6fb06fa2f3276308629b48d2dad5ee.tar.gz
gmap_arcgis-50f4e6298d6fb06fa2f3276308629b48d2dad5ee.tar.bz2
Adding timers before acting on map objects
-rw-r--r--gmap_arcgis.js124
1 files changed, 64 insertions, 60 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index ef5da45..3b38592 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -8,69 +8,73 @@ var map, mapExtension, gOverlays;
// Setup custom GMap Overlays (layers and labels)
function gmap_arcgis() {
-
- // Variables
- var polygons = new Array();
- var labels = new Array();
- var fields = new Array();
- var id = 'auto1map';
- var content, label;
-
- // 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;
- }
- // Get Map Id
- if (Drupal.settings.gmap_arcgis.id !== undefined) {
- id = Drupal.settings.gmap_arcgis.id;
+ /**
+ * Use a timer to make sure everything is loaded upon execution time.
+ */
+ setTimeout(function() {
+ // Variables
+ var polygons = new Array();
+ var labels = new Array();
+ var fields = new Array();
+ var id = 'auto1map';
+ var content, label;
+
+ // 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;
+ }
+ // Get Map Id
+ if (Drupal.settings.gmap_arcgis.id !== undefined) {
+ id = Drupal.settings.gmap_arcgis.id;
+ }
}
- }
-
- // Get an existing GMap instance using Drupal GMap Module API
- // and add an ArcGIS extension to it
- map = Drupal.gmap.getMap(id).map;
- mapExtension = new esri.arcgis.gmaps.MapExtension(map);
-
- for (var i = 0; i < labels.length; i++) {
- label = labels[i];
- // Set default fallback values for labels
- fields = ["id", "name"];
- content = 'Placeholder';
- icon = new GIcon(G_DEFAULT_ICON);
-
- if (label[1] !== undefined) {
- // Set custom fields
- fields = [ label[1][0], label[1][1] ];
+
+ // Get an existing GMap instance using Drupal GMap Module API
+ // and add an ArcGIS extension to it
+ map = Drupal.gmap.getMap(id).map;
+ mapExtension = new esri.arcgis.gmaps.MapExtension(map);
+
+ for (var i = 0; i < labels.length; i++) {
+ label = labels[i];
+ // Set default fallback values for labels
+ fields = ["id", "name"];
+ content = 'Placeholder';
+ icon = new GIcon(G_DEFAULT_ICON);
+
+ if (label[1] !== undefined) {
+ // Set custom fields
+ fields = [ label[1][0], label[1][1] ];
+ }
+
+ if (label[2] !== undefined) {
+ // Set custom content
+ content = label[2];
+ }
+
+ if (label[3] !== undefined) {
+ // Set label icons
+ var info = label[3];
+ icon.shadow = info[0];
+ icon.image = info[1];
+ icon.infoSize = new GSize(info[2][0], info[2][1]);
+ icon.shadowSize = new GSize(info[3][0], info[3][1]);
+ icon.infoAnchor = new GPoint(info[4][0], info[4][1]);
+ icon.infoWindowAnchor = new GPoint(info[5][0], info[5][1]);
+ }
+ GEvent.addListener(map, "moveend", function() { showLabels(label[0], fields, content, icon); });
+ showLabels(label[0], fields, content, icon);
}
-
- if (label[2] !== undefined) {
- // Set custom content
- content = label[2];
+
+ for (var j = 0; j < polygons.length; j++) {
+ showPolygons(polygons[j]);
}
-
- if (label[3] !== undefined) {
- // Set label icons
- var info = label[3];
- icon.shadow = info[0];
- icon.image = info[1];
- icon.infoSize = new GSize(info[2][0], info[2][1]);
- icon.shadowSize = new GSize(info[3][0], info[3][1]);
- icon.infoAnchor = new GPoint(info[4][0], info[4][1]);
- icon.infoWindowAnchor = new GPoint(info[5][0], info[5][1]);
- }
- GEvent.addListener(map, "moveend", function() { showLabels(label[0], fields, content, icon); });
- showLabels(label[0], fields, content, icon);
- }
-
- for (var j = 0; j < polygons.length; j++) {
- showPolygons(polygons[j]);
- }
+ }, 500);
}
// Add labels from a given ArcGIS MapServer Layer