1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?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, $content, $icon);
*
* 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,
* $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');
}
}
}
|