From 7f0b04cd90757624d7323c9209ff4b27caebd0f4 Mon Sep 17 00:00:00 2001 From: Silvio Date: Thu, 22 Oct 2009 16:59:13 -0200 Subject: Adding content field at labels array --- gmap_arcgis.js | 39 ++++++++++++++++++++++++--------------- gmap_arcgis.module | 7 ++++--- 2 files changed, 28 insertions(+), 18 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:"

{nome_uc}

Mais informações sobre esta UC" - }; + var infoWindowOptions = { content: content }; gOverlays = mapExtension.addToMap(fset, overlayOptions, infoWindowOptions); } diff --git a/gmap_arcgis.module b/gmap_arcgis.module index 9988676..76e2e80 100644 --- a/gmap_arcgis.module +++ b/gmap_arcgis.module @@ -65,10 +65,11 @@ function gmap_arcgis_gmap($op, &$map) { * * Where $layer is * - * $layer = array($layer_uri, $fields, $icon); + * $layer = array($layer_uri, $fields, $content, $icon); * - * Where $layer_uri is a MapService layer and $fields is an array with - * a pair of layer fields to pass to the queryand $icon is an array + * Where $layer_uri is a MapService layer, $fields is an array with + * a pair of layer fields to pass to the query, $content is a string + * with the content to display for each marker and $icon is an array * with parameteres from a GIcon class * * $icon = array($shadow, $image, $info_size, $shadow_size, -- cgit v1.2.3