diff options
author | Silvio <silvio@socioambiental.org> | 2009-10-22 16:59:13 -0200 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2009-10-22 16:59:13 -0200 |
commit | 7f0b04cd90757624d7323c9209ff4b27caebd0f4 (patch) | |
tree | cebf0b5900da1a2e9f1b23de5874f5f026f809d6 /gmap_arcgis.js | |
parent | 4bbf8693a2571a28d62b12a2177fea7eacfde66a (diff) | |
download | gmap_arcgis-7f0b04cd90757624d7323c9209ff4b27caebd0f4.tar.gz gmap_arcgis-7f0b04cd90757624d7323c9209ff4b27caebd0f4.tar.bz2 |
Adding content field at labels array
Diffstat (limited to 'gmap_arcgis.js')
-rw-r--r-- | gmap_arcgis.js | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 8dd4481..44d859b 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -6,7 +6,7 @@ google.load("maps", "2.x"); // Global variables var map, mapExtension, gOverlays; -// Setup custom ISA GMap Overlays (layers and labels) +// Setup custom GMap Overlays (layers and labels) function gmap_arcgis() { // Fallback setting @@ -15,6 +15,7 @@ function gmap_arcgis() { var labels = [ fallback + '/2' ]; var fields = new Array(); var id = 'auto1map'; + var content; // Get data from Drupal if (Drupal.settings.gmap_arcgis !== undefined) { @@ -38,15 +39,24 @@ function gmap_arcgis() { mapExtension = new esri.arcgis.gmaps.MapExtension(map); for each (var label in labels) { - fields = ["id", "name"]; - icon = new GIcon(G_DEFAULT_ICON); + // 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[2]; + var info = label[3]; icon.shadow = info[0]; icon.image = info[1]; icon.infoSize = new GSize(info[2][0], info[2][1]); @@ -54,8 +64,8 @@ function gmap_arcgis() { 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, icon); }); - showLabels(label[0], fields, icon); + GEvent.addListener(map, "moveend", function() { showLabels(label[0], fields, content, icon); }); + showLabels(label[0], fields, content, icon); } for each (var polygon in polygons) { @@ -64,7 +74,7 @@ function gmap_arcgis() { } // Add labels from a given ArcGIS MapServer Layer -function showLabels(label, fields, icon) { +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(); @@ -78,27 +88,26 @@ function showLabels(label, fields, icon) { query.outFields = fields; // set the callback - var callback = showLabelsCallback(icon); + var callback = showLabelsCallback(fields, content, icon); // execute query task queryTask.execute(query, false, callback); } // Callback for showLabels -function showLabelsCallback(icon) { +function showLabelsCallback(fields, content, icon) { return function(fset) { + // Label title + var title = '{' + fields[1] + '}'; + // JS literal class esri.arcgis.gmaps.MarkerOptions - // TODO: general default settings instead of custom ISA config - var myMarkerOptions = { title:"{nome_uc}", icon:icon }; + 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 = { - // TODO: general default settings instead of custom ISA config - content:"<h2>{nome_uc}</h2><a href=\"?q=/uc/{id_arp}\">Mais informações sobre esta UC</a>" - }; + var infoWindowOptions = { content: content }; gOverlays = mapExtension.addToMap(fset, overlayOptions, infoWindowOptions); } |