source: sipes/modules_contrib/openlayers/docs/openlayers.api.php @ c43ea01

stableversion-3.0
Last change on this file since c43ea01 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100644
File size: 8.5 KB
Línea 
1<?php
2
3/**
4 * @file
5 * Hooks provided by the OpenLayers suite of modules.  This file allows
6 * hooks to be documented automatically with Doxygen, like on api.drupal.org.
7 *
8 * @ingroup openlayers
9 */
10
11/**
12 * OpenLayers Map Preprocess Alter
13 *
14 * Map array alter.  Fired before processing the array, and
15 * before checking for errors.  The whole array is passed
16 * along and will allow you to alter it in any way.  This
17 * is a good place to alter the map, if the other hooks
18 * do not provide the functionality you need.
19 *
20 * @param $map
21 *   Map array
22 */
23function hook_openlayers_map_preprocess_alter(&$map = array()) {
24  // Do something to the $map
25}
26
27/**
28 * OpenLayers Map Alter
29 *
30 * Post-processing Map array alter.  Fired after processing the array, and
31 * before checking for errors.  The whole array is passed
32 * along and will allow you to alter it in any way.  Adding behaviors,
33 * pre-defined layers here will not work. This is good for minor tweaks
34 * after the map has been processed.
35 *
36 * @param $map
37 *   Map array
38 */
39function hook_openlayers_map_alter(&$map = array()) {
40  // Do something to the $map
41}
42
43/**
44 * OpenLayers Layer Types
45 *
46 * Provides information on layer types.  This is a CTools plugin.  Please
47 * see LAYER_TYPES.txt in the module for more information.
48 *
49 * @return
50 *   Return a nested associative array with the top level
51 *   being a unique string identifier key which corresponds to the
52 *   layers' types.  The next level being an array of key/value
53 *   pairs:
54 *   - "description":
55 *   - "layer_type":
56 */
57function hook_openlayers_layer_types() {
58  // Take from openlayers.layer_types.inc
59
60  return array(
61    'openlayers_layer_type_google' => array(
62      'title' => t('Google'),
63      'description' => t('Google Maps API Map'),
64      'layer_type' => array(
65        'path' => drupal_get_path('module', 'openlayers') .'/includes/layer_types',
66        'file' => 'google.inc',
67        'class' => 'openlayers_layer_type_google',
68        'parent' => 'openlayers_layer_type',
69      ),
70    ),
71  );
72}
73
74/**
75 * CTools Registration Hook
76 *
77 * IMPORTANT:
78 *
79 * In order to support styles, presets, and layers in an external module,
80 * one must notify the CTools module that that module provides implementations
81 * of the hooks for styles, presets, and/or layers.
82 *
83 * This function is just an example implementation of
84 * hook_ctools_plugin_api() and should be alter according to
85 * your module's name.
86 *
87 * @param $module
88 *   Name of a module that supports CTools exportables.
89 * @param $api
90 *   Name of the kind of exportable supported.
91 * @return
92 *  If $module is 'openlayers', and $api is a type of exportable that
93 *  your module provides, and you are using Openlayers 2.x, then
94 *  return array with the following values:
95 *  - version => 1
96 */
97function openlayers_example_ctools_plugin_api($module, $api) {
98  if ($module == "openlayers") {
99    switch ($api) {
100      case 'openlayers_presets':
101        return array('version' => 1);
102
103      case 'openlayers_layers':
104        return array('version' => 1);
105
106      case 'openlayers_styles':
107        return array('version' => 1);
108
109    }
110  }
111}
112
113/**
114 * OpenLayers Layers
115 *
116 * This hook tells OpenLayers about the available layers
117 * that can be used by name in maps.
118 *
119 * Ensure that you are telling CTools about this as well.
120 * @see openlayers_example_ctools_plugin_api().
121 *
122 * Please note, that to support translation for exportable
123 * code for potx extraction, you should include separate code
124 * of translatable string.
125 *
126 * @return
127 *   Return an associative array with index being a unique string
128 *   identifier, and simple objects with the following properties:
129 *   - "api_version":
130 *   - "name":
131 *   - "title":
132 *   - "data":
133 */
134function hook_openlayers_layers() {
135  // Taken from openlayers.layers.inc
136
137  $layers = array();
138  $layer = new stdClass();
139  $layer->api_version = 1;
140  $layer->name = 'google_satellite';
141  $layer->title = 'Google Maps Satellite';
142  $layer->description = 'Google Maps Satellite Imagery.';
143  $layer->data = array(
144    'baselayer' => TRUE,
145    'type' => 'satellite',
146    'projection' => array('900913'),
147    'layer_type' => 'openlayers_layer_type_google',
148  );
149  $layers[$layer->name] = $layer;
150  return $layers;
151 
152  // Extra code to support potx extractors
153  $potx = array(
154    t('Google Maps Satellite'),
155    t('Google Maps Satellite Imagery.'),
156  );
157}
158
159/**
160 * OpenLayers Behaviors
161 *
162 * This hook tells OpenLayers about the available behaviors
163 * that can be used in maps.
164 *
165 * Ensure that you are telling CTools about this as well.
166 * @see openlayers_example_ctools_plugin_api().
167 *
168 * @return
169 *   Return a nested associative array with the top level
170 *   being a unique string identifier, and the nested array
171 *   containing the following key/pairs:
172 *   - "title":
173 *   - "description":
174 *   - "file":
175 *   - "type":
176 *   - "behavior":
177 */
178function hook_openlayers_behaviors() {
179  // Taken from openlayers.behaviors.inc
180
181  return array(
182    'openlayers_behavior_attribution' => array(
183      'title' => t('Attribution'),
184      'description' => t('Allows layers to provide attribution to the map if it exists.'),
185      'type' => 'layer',
186      'path' => drupal_get_path('module', 'openlayers') .'/includes/behaviors',
187      'file' => 'openlayers_behavior_attribution.inc',
188      'behavior' => array(
189        'class' => 'openlayers_behavior_attribution',
190        'parent' => 'openlayers_behavior',
191      ),
192    ),
193  );
194}
195
196/**
197 * OpenLayers Styles
198 *
199 * This hook tells OpenLayers about the available styles
200 * that can be used in maps.
201 *
202 * Ensure that you are telling CTools about this as well.
203 * @see openlayers_example_ctools_plugin_api().
204 *
205 * @return
206 *   Return an associative array with index being a unique string
207 *   identifier, and simple objects with the following properties:
208 *   - "api_version":
209 *   - "name":
210 *   - "title":
211 *   - "data":
212 */
213function hook_openlayers_styles() {
214  // Taken from openlayers.styles.inc
215
216  $styles = array();
217
218  $style = new stdClass();
219  $style->api_version = 1;
220  $style->name = 'default';
221  $style->title = t('Default style');
222  $style->description = t('Basic default style.');
223  $style->data = array(
224    'pointRadius' => '5',
225    'fillColor' => '#FFCC66',
226    'strokeColor' => '#FF9933',
227    'strokeWidth' => '4',
228    'fillOpacity' => '0.5'
229  );
230  $styles[$style->name] = $style;
231
232  return $styles;
233}
234
235/**
236 * OpenLayers Presets
237 *
238 * Define map presets.
239 *
240 * @return
241 *   Return an associative array with index being a unique string
242 *   identifier, and simple objects with the following properties:
243 *   - "api_version":
244 *   - "name":
245 *   - "title":
246 *   - "data":
247 */
248function hook_openlayers_presets() {
249  // Taken from openlayers.presets.inc
250
251  $default = new stdClass();
252  $default->api_version = 1;
253  $default->name = 'default';
254  $default->title = t('Default Map');
255  $default->description = t('This is the default map preset that comes with the OpenLayers module.');
256  $default->data = array(
257    'projection' => '900913',
258    'width' => 'auto',
259    'default_layer' => 'osm_mapnik',
260    'height' => '400px',
261    'center' => array(
262      'initial' => array(
263        'centerpoint' => '0,0',
264        'zoom' => '2'
265      )
266    ),
267    'options' => array(
268      'displayProjection' => '4326',
269      'maxExtent' => openlayers_get_extent('4326'),
270    ),
271    'behaviors' => array(
272      'openlayers_behavior_panzoombar' => array(),
273      'openlayers_behavior_layerswitcher' => array(),
274      'openlayers_behavior_attribution' => array(),
275      'openlayers_behavior_keyboarddefaults' => array(),
276      'openlayers_behavior_navigation' => array(),
277    ),
278    'layers' => array(
279      'osm_mapnik' => 'osm_mapnik',
280    )
281  );
282  return array('default' => $default);
283}
284
285/**
286 * CTools Registration Hook (Style Plugins)
287 *
288 * IMPORTANT:
289 *
290 * In order to support style plugins, the first step is to
291 * tell CTools where to find the plugin.
292 *
293 * This function is just an example implementation of
294 * hook_ctools_plugin_directory() and should be alter according to
295 * your module's name.
296 *
297 * For an example, please see the openlayers_test.module
298 *
299 * @param $module
300 *   Name of a module that supports CTools exportables.
301 * @param $plugin
302 *   Name of the kind of plugin supported.
303 * @return
304 *  If $module is 'openlayers', and $api is a type of exportable that
305 *  your module provides, and you are using Openlayers 2.x, then
306 *  return the directory relative to a module to look for this
307 *  particular plugin.
308 */
309function openlayers_ctools_plugin_directory($module, $plugin) {
310  if ($module == 'openlayers' && $plugin == 'style_plugin') {
311    return 'plugins/style_plugin';
312  }
313}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.