geofield.openlayers.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /**
  3. * @file
  4. * Provides hooks for integration with OpenLayers (http://drupal.org/project/openlayers)
  5. */
  6. /**
  7. * Implements hook_openlayers_maps().
  8. */
  9. function geofield_openlayers_maps() {
  10. // Create full preset array
  11. $widget = new stdClass;
  12. $widget->disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */
  13. $widget->api_version = 1;
  14. $widget->name = 'geofield_widget_map';
  15. $widget->title = 'Geofield Widget Map';
  16. $widget->description = 'A Map Used for Geofield Input';
  17. $widget->data = array(
  18. 'width' => '600px',
  19. 'height' => '400px',
  20. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  21. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  22. 'proxy_host' => '',
  23. 'hide_empty_map' => 0,
  24. 'center' => array(
  25. 'initial' => array(
  26. 'centerpoint' => '0, 0',
  27. 'zoom' => '1',
  28. ),
  29. 'restrict' => array(
  30. 'restrictextent' => 0,
  31. 'restrictedExtent' => '',
  32. ),
  33. ),
  34. 'behaviors' => array(
  35. 'openlayers_behavior_geofield' => array(
  36. 'feature_types' => array(
  37. 'point' => 'point',
  38. 'path' => 'path',
  39. 'polygon' => 'polygon',
  40. ),
  41. 'allow_edit' => 1,
  42. ),
  43. 'openlayers_behavior_keyboarddefaults' => array(),
  44. 'openlayers_behavior_navigation' => array(
  45. 'zoomWheelEnabled' => 0,
  46. 'zoomBoxEnabled' => 1,
  47. 'documentDrag' => 0,
  48. ),
  49. 'openlayers_behavior_panzoombar' => array(
  50. 'zoomWorldIcon' => 0,
  51. 'panIcons' => 1,
  52. ),
  53. ),
  54. 'default_layer' => 'mapquest_osm',
  55. 'layers' => array(
  56. 'mapquest_osm' => 'mapquest_osm',
  57. ),
  58. 'layer_weight' => array(
  59. 'openlayers_geojson_picture_this' => '0',
  60. 'geofield_formatter' => '0',
  61. ),
  62. 'layer_styles' => array(
  63. 'geofield_formatter' => '0',
  64. 'openlayers_geojson_picture_this' => '0',
  65. ),
  66. 'layer_styles_select' => array(
  67. 'geofield_formatter' => '0',
  68. 'openlayers_geojson_picture_this' => '0',
  69. ),
  70. 'layer_activated' => array(
  71. 'geofield_formatter' => 0,
  72. 'openlayers_geojson_picture_this' => 0,
  73. ),
  74. 'layer_switcher' => array(
  75. 'geofield_formatter' => 0,
  76. 'openlayers_geojson_picture_this' => 0,
  77. ),
  78. 'projection' => '900913',
  79. 'displayProjection' => '4326',
  80. 'styles' => array(
  81. 'default' => 'default',
  82. 'select' => 'default',
  83. 'temporary' => 'default',
  84. ),
  85. 'map_name' => 'geofield_widget_map',
  86. );
  87. $formatter = new stdClass();
  88. $formatter->api_version = 1;
  89. $formatter->name = 'geofield_formatter_map';
  90. $formatter->title = t('Geofield Formatter Map');
  91. $formatter->description = t('A Map Used for Geofield Output');
  92. $formatter->data = array(
  93. 'width' => '600px',
  94. 'height' => '400px',
  95. 'image_path' => 'sites/all/modules/openlayers/themes/default_dark/img/',
  96. 'css_path' => 'sites/all/modules/openlayers/themes/default_dark/style.css',
  97. 'proxy_host' => '',
  98. 'hide_empty_map' => 0,
  99. 'center' => array(
  100. 'initial' => array(
  101. 'centerpoint' => '0, 0',
  102. 'zoom' => '1',
  103. ),
  104. 'restrict' => array(
  105. 'restrictextent' => 0,
  106. 'restrictedExtent' => '',
  107. ),
  108. ),
  109. 'behaviors' => array(
  110. 'openlayers_behavior_keyboarddefaults' => array(),
  111. 'openlayers_behavior_navigation' => array(
  112. 'zoomWheelEnabled' => 0,
  113. 'zoomBoxEnabled' => 1,
  114. 'documentDrag' => 0,
  115. ),
  116. 'openlayers_behavior_panzoombar' => array(
  117. 'zoomWorldIcon' => 0,
  118. 'panIcons' => 1,
  119. ),
  120. ),
  121. 'default_layer' => 'mapquest_osm',
  122. 'layers' => array(
  123. 'mapquest_osm' => 'mapquest_osm',
  124. 'geofield_formatter' => 'geofield_formatter',
  125. ),
  126. 'layer_weight' => array(
  127. 'geofield_formatter' => '0',
  128. 'openlayers_geojson_picture_this' => '0',
  129. ),
  130. 'layer_styles' => array(
  131. 'openlayers_geojson_picture_this' => '0',
  132. 'geofield_formatter' => '0',
  133. ),
  134. 'layer_styles_select' => array(
  135. 'openlayers_geojson_picture_this' => '0',
  136. 'geofield_formatter' => '0',
  137. ),
  138. 'layer_activated' => array(
  139. 'geofield_formatter' => 'geofield_formatter',
  140. 'openlayers_geojson_picture_this' => 0,
  141. ),
  142. 'layer_switcher' => array(
  143. 'geofield_formatter' => 0,
  144. 'openlayers_geojson_picture_this' => 0,
  145. ),
  146. 'projection' => '900913',
  147. 'displayProjection' => '4326',
  148. 'styles' => array(
  149. 'default' => 'default',
  150. 'select' => 'default',
  151. 'temporary' => 'default',
  152. ),
  153. 'map_name' => 'geofield_formatter_map',
  154. );
  155. return array(
  156. 'geofield_widget_map' => $widget,
  157. 'geofield_formatter_map' => $formatter,
  158. );
  159. }
  160. /**
  161. * Implements hook_openlayers_behaviors().
  162. */
  163. function geofield_openlayers_behaviors() {
  164. return array(
  165. 'openlayers_behavior_geofield' => array(
  166. 'title' => t('Geofield'),
  167. 'description' => t('Fuels the geofield map-input form.'),
  168. 'type' => 'layer',
  169. 'behavior' => array(
  170. 'path' => drupal_get_path('module', 'geofield') . '/includes/behaviors',
  171. 'file' => 'openlayers_behavior_geofield.inc',
  172. 'class' => 'openlayers_behavior_geofield',
  173. 'parent' => 'openlayers_behavior',
  174. ),
  175. ),
  176. );
  177. }
  178. /**
  179. * Formatter layers
  180. */
  181. function geofield_openlayers_layers() {
  182. $layers = array();
  183. $layer = new stdClass();
  184. $layer->api_version = 1;
  185. $layer->name = 'geofield_formatter';
  186. $layer->title = 'Placeholder for Geofield Formatter';
  187. $layer->description = '';
  188. $layer->data = array(
  189. 'layer_type' => 'openlayers_layer_type_raw',
  190. 'projection' => array('900913'),
  191. 'features' => array()
  192. );
  193. $layers[$layer->name] = $layer;
  194. return $layers;
  195. }