aboutsummaryrefslogtreecommitdiff
path: root/gmap_arcgis.module
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2009-10-22 15:44:14 -0200
committerSilvio <silvio@socioambiental.org>2009-10-22 15:44:14 -0200
commitccaa9e7ea24f735ae83bd03cce41feef7738cd0d (patch)
tree54679ac7fe1210de7bfe5c7c7b8d1d9cfe5480b8 /gmap_arcgis.module
downloadgmap_arcgis-ccaa9e7ea24f735ae83bd03cce41feef7738cd0d.tar.gz
gmap_arcgis-ccaa9e7ea24f735ae83bd03cce41feef7738cd0d.tar.bz2
Initial import
Diffstat (limited to 'gmap_arcgis.module')
-rw-r--r--gmap_arcgis.module102
1 files changed, 102 insertions, 0 deletions
diff --git a/gmap_arcgis.module b/gmap_arcgis.module
new file mode 100644
index 0000000..9988676
--- /dev/null
+++ b/gmap_arcgis.module
@@ -0,0 +1,102 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Support for ArcGIS into GMap.
+ *
+ * This module implements support for ArcGIS API
+ * into a GMap.
+ */
+
+/**
+ * Implementation of hook_install().
+ */
+function gmap_install() {
+ /**
+ * We need to make sure that this module be the last one
+ * in the hook execution order.
+ */
+ db_query("UPDATE {system} SET weight = 10 WHERE name = 'gmap_arcgis'");
+}
+
+/**
+ * Implementation of hook_gmap().
+ */
+function gmap_arcgis_gmap($op, &$map) {
+ if ($op == 'pre_theme_map') {
+ /**
+ * Use $map to change and add custom overlays into
+ * a given map instance.
+ */
+ if (isset($map['arcgis'])) {
+ /**
+ * Make sure that shapes js code are loaded.
+ *
+ * This is needed as a workaround to the current GMap
+ * module that doesn't add shapes js if $map['shapes']
+ * wasn't previously defined.
+ */
+ if (!empty($map['shapes'])) {
+ $gmap_path = drupal_get_path('module', 'gmap') .'/js/';
+ drupal_add_js($gmap_path .'shapeloader_static.js');
+ drupal_add_js($gmap_path .'gmap_shapes.js');
+ }
+
+ /**
+ * The order to load the following js code is important.
+ */
+
+ // Add Google js API
+ $key = variable_get('googlemap_api_key', '');
+ $script = '<script type="text/javascript" ';
+ drupal_set_html_head($script .'src="http://www.google.com/jsapi?key='. $key .'"></script>');
+
+ // Add ArcGIS js API
+ drupal_set_html_head($script .'src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.4"></script>');
+
+ // Setup Map Id
+ drupal_add_js(array('gmap_arcgis' => array('id' => $map['id'])), 'setting');
+
+ /**
+ * Setup polygons and labels. Labels have the following format:
+ *
+ * $map['arcgis']['labels'] = array($layer1 [, $layer2 [,... $layerN]]);
+ *
+ * Where $layer is
+ *
+ * $layer = array($layer_uri, $fields, $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
+ * with parameteres from a GIcon class
+ *
+ * $icon = array($shadow, $image, $info_size, $shadow_size,
+ * $info_anchor, $info_window_anchor);
+ *
+ * For more info on the GIcon class, see
+ * http://code.google.com/intl/pt-BR/apis/maps/documentation/reference.html#GIcon
+ *
+ * Example:
+ * $labels = array(
+ * array("http://mapservice/layer1", array('id', 'name'), array(
+ * NULL, 'http://path/to/icon.png',
+ * array(20, 34), array(37, 34), array(9, 34), array(9, 2)
+ * )
+ * ),
+ * array("http://mapservice/layer2"),
+ * );
+ */
+ if (isset($map['arcgis']['polygons'])) {
+ drupal_add_js(array('gmap_arcgis' => array('polygons' => $map['arcgis']['polygons'])), 'setting');
+ }
+ if (isset($map['arcgis']['labels'])) {
+ drupal_add_js(array('gmap_arcgis' => array('labels' => $map['arcgis']['labels'])), 'setting');
+ }
+
+ // Add custom js
+ $gmap_arcgis_path = drupal_get_path('module', 'gmap_arcgis') .'/';
+ drupal_add_js($gmap_arcgis_path .'gmap_arcgis.js');
+ }
+ }
+}