openlayers.api.php 7.6 KB

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