geofield.openlayers.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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' => 'EPSG:900913',
  79. 'displayProjection' => 'EPSG: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' => drupal_get_path('module','openlayers') . '/themes/default_dark/img/',
  96. 'css_path' => drupal_get_path('module','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. 'openlayers_behavior_zoomtolayer' => array(
  121. 'zoomtolayer' => array(
  122. 'geofield_formatter' => 'geofield_formatter',
  123. ),
  124. 'point_zoom_level' => '5',
  125. 'zoomtolayer_scale' => '1',
  126. ),
  127. ),
  128. 'default_layer' => 'mapquest_osm',
  129. 'layers' => array(
  130. 'mapquest_osm' => 'mapquest_osm',
  131. 'geofield_formatter' => 'geofield_formatter',
  132. ),
  133. 'layer_weight' => array(
  134. 'geofield_formatter' => '0',
  135. 'openlayers_geojson_picture_this' => '0',
  136. ),
  137. 'layer_styles' => array(
  138. 'openlayers_geojson_picture_this' => '0',
  139. 'geofield_formatter' => '0',
  140. ),
  141. 'layer_styles_select' => array(
  142. 'openlayers_geojson_picture_this' => '0',
  143. 'geofield_formatter' => '0',
  144. ),
  145. 'layer_activated' => array(
  146. 'geofield_formatter' => 'geofield_formatter',
  147. 'openlayers_geojson_picture_this' => 0,
  148. ),
  149. 'layer_switcher' => array(
  150. 'geofield_formatter' => 0,
  151. 'openlayers_geojson_picture_this' => 0,
  152. ),
  153. 'projection' => 'EPSG:900913',
  154. 'displayProjection' => 'EPSG:4326',
  155. 'styles' => array(
  156. 'default' => 'default',
  157. 'select' => 'default',
  158. 'temporary' => 'default',
  159. ),
  160. 'map_name' => 'geofield_formatter_map',
  161. );
  162. return array(
  163. 'geofield_widget_map' => $widget,
  164. 'geofield_formatter_map' => $formatter,
  165. );
  166. }
  167. /**
  168. * Implements hook_openlayers_behaviors().
  169. */
  170. function geofield_openlayers_behaviors() {
  171. return array(
  172. 'openlayers_behavior_geofield' => array(
  173. 'title' => t('Geofield'),
  174. 'description' => t('Fuels the geofield map-input form.'),
  175. 'type' => 'layer',
  176. 'behavior' => array(
  177. 'path' => drupal_get_path('module', 'geofield') . '/includes/behaviors',
  178. 'file' => 'openlayers_behavior_geofield.inc',
  179. 'class' => 'openlayers_behavior_geofield',
  180. 'parent' => 'openlayers_behavior',
  181. ),
  182. ),
  183. );
  184. }
  185. /**
  186. * Formatter layers
  187. */
  188. function geofield_openlayers_layers() {
  189. $layers = array();
  190. $layer = new stdClass();
  191. $layer->api_version = 1;
  192. $layer->name = 'geofield_formatter';
  193. $layer->title = 'Placeholder for Geofield Formatter';
  194. $layer->description = '';
  195. $layer->data = array(
  196. 'layer_type' => 'openlayers_layer_type_raw',
  197. 'projection' => array('EPSG:900913'),
  198. 'features' => array()
  199. );
  200. $layers[$layer->name] = $layer;
  201. return $layers;
  202. }