aboutsummaryrefslogtreecommitdiff
path: root/gmap_arcgis.js
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-02-26 19:47:29 -0300
committerSilvio <silvio@socioambiental.org>2013-02-26 19:47:29 -0300
commit30c2455c9f540f2e620d1bae5a26ea495e8848a1 (patch)
tree1c8aa9f7c2c82f024a6317046e9acffd49d5987b /gmap_arcgis.js
parentea6cce3937970cd5c22f04b823a6def0b1b78989 (diff)
downloadgmap_arcgis-30c2455c9f540f2e620d1bae5a26ea495e8848a1.tar.gz
gmap_arcgis-30c2455c9f540f2e620d1bae5a26ea495e8848a1.tar.bz2
Cleanup and polygon rendering without callbacks
Diffstat (limited to 'gmap_arcgis.js')
-rw-r--r--gmap_arcgis.js89
1 files changed, 11 insertions, 78 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index d01a85c..a63003d 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -35,85 +35,12 @@ function gmap_arcgis() {
// Get an existing GMap instance using Drupal GMap Module API
map = Drupal.gmap.getMap(id).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);
- }
- return;
-
gmapArcgisShowPolygons(Drupal.settings.gmap_arcgis.polygons);
}, 5);
//setTimeout(unblockUI, 10000);
}
-// Add labels from a given ArcGIS MapServer Layer
-function showLabels(label, fields, content, icon) {
- var bounds = map.getBounds();
- var queryTask = new esri.arcgis.gmaps.QueryTask(label);
- var query = new esri.arcgis.gmaps.Query();
-
- // clear gOverlays overlays and event listeners
- //mapExtension.removeFromMap(gOverlays);
-
- // set query parameters
- query.queryGeometry = bounds;
- query.returnGeometry = true;
- query.outFields = fields;
-
- // set the callback
- var callback = showLabelsCallback(fields, content, icon);
-
- // execute query task
- queryTask.execute(query, false, callback);
-}
-
-// Callback for showLabels
-function showLabelsCallback(fields, content, icon) {
- return function(fset) {
- // Label title
- var title = '{' + fields[1] + '}';
-
- // JS literal class esri.arcgis.gmaps.MarkerOptions
- var myMarkerOptions = { title:title, icon:icon };
-
- // JS literal class esri.arcgis.gmaps.OverlayOptions
- var overlayOptions = { markerOptions:myMarkerOptions };
-
- // JS literal class esri.arcgis.gmaps.InfoWindowOptions without tabs
- var infoWindowOptions = { content: content };
-
- gOverlays = mapExtension.addToMap(fset, overlayOptions, infoWindowOptions);
- }
-}
-
// Show all defined polygons
function gmapArcgisShowPolygons(polygons) {
for (j = 0; j < polygons.length; j++) {
@@ -142,12 +69,18 @@ function showPolygon(polygon) {
uri = polygon['base'] + polygon['service'];
layers = polygon['layers'];
- polygon.overlay = new esri.arcgis.gmaps.DynamicMapServiceLayer(uri, null, defaultOpacity);
+ polygon.overlay = new gmaps.ags.MapOverlay(uri, {
+ exportOptions: {
+ layerIds: layers,
+ layerOption: 'show',
+ }
+ });
- if (layers != undefined || layers == []) {
- polygon.overlay.setVisibleLayers(layers);
- }
+ polygon.overlay.setMap(map);
+ polygon.overlay.setOpacity(defaultOpacity);
+ // TODO
+ return;
GEvent.addListener(polygon.overlay, "load", showPolygonCallback);
GEvent.addListener(polygon.overlay, "update", function() { unblockUI(); });
}
@@ -179,7 +112,7 @@ function unblockUI() {
// Add map overlays
$(document).ready(function() {
- //google.setOnLoadCallback(gmap_arcgis);
+ google.setOnLoadCallback(gmap_arcgis);
$('#edit-lista-uc').change(function() {
oelem = $("option:selected", this).val();
marcador = Drupal.gmap.getMap('auto1map').vars.markers[oelem];