openlayers.maps.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <?php
  2. /**
  3. * @file
  4. * This file contains map implementations
  5. *
  6. * @ingroup openlayers
  7. */
  8. /**
  9. * Map definitions
  10. *
  11. * Internal callback for openlayers map implementation.
  12. *
  13. * @return
  14. * Array of maps
  15. */
  16. function _openlayers_openlayers_maps() {
  17. $items = array();
  18. // Default map with MapQuest
  19. $default = new stdClass();
  20. $default->api_version = 1;
  21. $default->name = 'default';
  22. $default->title = t('Default Map');
  23. $default->description = t('This is the default map that will be the basis for all maps, unless you have changed the !settings. This is also a good example of a basic map.', array('!settings' => l(t('OpenLayers main settings'), 'admin/structure/openlayers')));
  24. $default->data = array(
  25. 'projection' => '900913',
  26. 'width' => 'auto',
  27. 'height' => '400px',
  28. 'default_layer' => 'mapquest_osm',
  29. 'center' => array(
  30. 'initial' => array(
  31. 'centerpoint' => '0,0',
  32. 'zoom' => '0'
  33. )
  34. ),
  35. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  36. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  37. 'displayProjection' => '4326',
  38. 'maxExtent' => openlayers_get_extent('4326'),
  39. 'behaviors' => array(
  40. 'openlayers_behavior_panzoombar' => array(),
  41. 'openlayers_behavior_layerswitcher' => array(),
  42. 'openlayers_behavior_attribution' => array(),
  43. 'openlayers_behavior_keyboarddefaults' => array(),
  44. 'openlayers_behavior_navigation' => array(),
  45. ),
  46. 'layers' => array(
  47. 'mapquest_osm' => 'mapquest_osm',
  48. 'mapquest_openaerial' => 'mapquest_openaerial',
  49. ),
  50. 'styles' => array(
  51. 'default' => 'default',
  52. 'select' => 'default_select',
  53. 'temporary' => 'default',
  54. ),
  55. );
  56. $items['default'] = $default;
  57. // An example Google map
  58. $openlayers_maps = new stdClass;
  59. $openlayers_maps->disabled = FALSE;
  60. $openlayers_maps->api_version = 1;
  61. $openlayers_maps->name = 'example_google';
  62. $openlayers_maps->title = t('Example Google Map');
  63. $openlayers_maps->description = t('An example map using Google Maps API layers.');
  64. $openlayers_maps->data = array(
  65. 'width' => 'auto',
  66. 'height' => '400px',
  67. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  68. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  69. 'center' => array(
  70. 'initial' => array(
  71. 'centerpoint' => '0, 0',
  72. 'zoom' => '2',
  73. ),
  74. 'restrict' => array(
  75. 'restrictextent' => 0,
  76. 'restrictedExtent' => '',
  77. ),
  78. ),
  79. 'behaviors' => array(
  80. 'openlayers_behavior_attribution' => array(
  81. 'seperator' => '',
  82. ),
  83. 'openlayers_behavior_keyboarddefaults' => array(),
  84. 'openlayers_behavior_layerswitcher' => array(
  85. 'ascending' => 1,
  86. 'roundedCorner' => 1,
  87. 'roundedCornerColor' => '#222222',
  88. ),
  89. 'openlayers_behavior_navigation' => array(
  90. 'zoomWheelEnabled' => 1,
  91. 'zoomBoxEnabled' => 1,
  92. 'documentDrag' => 0,
  93. ),
  94. 'openlayers_behavior_permalink' => array(
  95. 'anchor' => 1,
  96. ),
  97. 'openlayers_behavior_zoompanel' => array(),
  98. ),
  99. 'default_layer' => 'google_physical',
  100. 'layers' => array(
  101. 'google_satellite' => 'google_satellite',
  102. 'google_hybrid' => 'google_hybrid',
  103. 'google_normal' => 'google_normal',
  104. 'google_physical' => 'google_physical',
  105. ),
  106. 'projection' => '900913',
  107. 'displayProjection' => '4326',
  108. 'styles' => array(
  109. 'default' => 'default',
  110. 'select' => 'default_select',
  111. 'temporary' => 'default',
  112. ),
  113. );
  114. $items['default_google'] = $openlayers_maps;
  115. // Example map with MapQuest and GeoJSON
  116. $openlayers_maps = new stdClass();
  117. $openlayers_maps->disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */
  118. $openlayers_maps->api_version = 1;
  119. $openlayers_maps->name = 'example_geojson';
  120. $openlayers_maps->title = 'Example GeoJSON Map';
  121. $openlayers_maps->description = 'A simple map with a custom GeoJSON layer with direct data. Also an example of zooming into a layer.';
  122. $openlayers_maps->data = array(
  123. 'width' => 'auto',
  124. 'height' => '400px',
  125. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  126. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  127. 'proxy_host' => '',
  128. 'hide_empty_map' => 0,
  129. 'center' => array(
  130. 'initial' => array(
  131. 'centerpoint' => '0,0',
  132. 'zoom' => '2',
  133. ),
  134. 'restrict' => array(
  135. 'restrictextent' => 0,
  136. 'restrictedExtent' => '',
  137. ),
  138. ),
  139. 'behaviors' => array(
  140. 'openlayers_behavior_keyboarddefaults' => array(),
  141. 'openlayers_behavior_layerswitcher' => array(
  142. 'ascending' => 1,
  143. 'sortBaseLayer' => '0',
  144. 'roundedCorner' => 1,
  145. 'roundedCornerColor' => '#222222',
  146. 'maximizeDefault' => 0,
  147. ),
  148. 'openlayers_behavior_navigation' => array(
  149. 'zoomWheelEnabled' => 1,
  150. 'zoomBoxEnabled' => 1,
  151. 'documentDrag' => 0,
  152. ),
  153. 'openlayers_behavior_panzoombar' => array(
  154. 'zoomWorldIcon' => 0,
  155. 'panIcons' => 1,
  156. ),
  157. 'openlayers_behavior_popup' => array(
  158. 'layers' => array(
  159. 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this',
  160. ),
  161. 'panMapIfOutOfView' => 0,
  162. 'keepInMap' => 1,
  163. ),
  164. 'openlayers_behavior_zoomtolayer' => array(
  165. 'zoomtolayer' => array(
  166. 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this',
  167. ),
  168. 'point_zoom_level' => '5',
  169. 'zoomtolayer_scale' => '1',
  170. ),
  171. ),
  172. 'default_layer' => 'mapquest_openaerial',
  173. 'layers' => array(
  174. 'mapquest_osm' => 'mapquest_osm',
  175. 'mapquest_openaerial' => 'mapquest_openaerial',
  176. 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this',
  177. ),
  178. 'layer_activated' => array(
  179. 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this',
  180. ),
  181. 'projection' => '900913',
  182. 'displayProjection' => '4326',
  183. 'styles' => array(
  184. 'default' => 'default',
  185. 'select' => 'default_select',
  186. 'temporary' => 'default',
  187. ),
  188. );
  189. $items['example_geojson'] = $openlayers_maps;
  190. // Example map with MapQuest and GeoJSON
  191. $openlayers_maps = new stdClass();
  192. $openlayers_maps->disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */
  193. $openlayers_maps->api_version = 1;
  194. $openlayers_maps->name = 'example_kml';
  195. $openlayers_maps->title = 'Example KML Map';
  196. $openlayers_maps->description = 'A simple map with a KML layer.';
  197. $openlayers_maps->data = array(
  198. 'width' => 'auto',
  199. 'height' => '400px',
  200. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  201. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  202. 'proxy_host' => '',
  203. 'hide_empty_map' => 0,
  204. 'center' => array(
  205. 'initial' => array(
  206. 'centerpoint' => '-122.0822035425683, 37.42228990140251',
  207. 'zoom' => '6',
  208. ),
  209. 'restrict' => array(
  210. 'restrictextent' => 0,
  211. 'restrictedExtent' => '',
  212. ),
  213. ),
  214. 'behaviors' => array(
  215. 'openlayers_behavior_mouseposition' => array(),
  216. 'openlayers_behavior_keyboarddefaults' => array(),
  217. 'openlayers_behavior_layerswitcher' => array(
  218. 'ascending' => 1,
  219. 'sortBaseLayer' => '0',
  220. 'roundedCorner' => 1,
  221. 'roundedCornerColor' => '#222222',
  222. 'maximizeDefault' => 0,
  223. ),
  224. 'openlayers_behavior_navigation' => array(
  225. 'zoomWheelEnabled' => 1,
  226. 'zoomBoxEnabled' => 1,
  227. 'documentDrag' => 0,
  228. ),
  229. 'openlayers_behavior_panzoombar' => array(
  230. 'zoomWorldIcon' => 0,
  231. 'panIcons' => 1,
  232. ),
  233. 'openlayers_behavior_popup' => array(
  234. 'layers' => array(
  235. 'openlayers_kml_example' => 'openlayers_kml_example',
  236. ),
  237. 'panMapIfOutOfView' => 0,
  238. 'keepInMap' => 1,
  239. ),
  240. /*
  241. 'openlayers_behavior_zoomtolayer' => array(
  242. 'zoomtolayer' => array(
  243. 'openlayers_kml_example' => 'openlayers_kml_example',
  244. ),
  245. 'point_zoom_level' => '5',
  246. 'zoomtolayer_scale' => '1',
  247. ),
  248. */
  249. ),
  250. 'default_layer' => 'mapquest_osm',
  251. 'layers' => array(
  252. 'mapquest_osm' => 'mapquest_osm',
  253. 'openlayers_kml_example' => 'openlayers_kml_example',
  254. ),
  255. 'layer_activated' => array(
  256. 'openlayers_kml_example' => 'openlayers_kml_example',
  257. ),
  258. 'projection' => '900913',
  259. 'displayProjection' => '4326',
  260. 'styles' => array(
  261. 'default' => 'default',
  262. 'select' => 'default_select',
  263. 'temporary' => 'default',
  264. ),
  265. );
  266. $items['example_kml'] = $openlayers_maps;
  267. // Example Virtual Earth map
  268. $openlayers_maps = new stdClass;
  269. $openlayers_maps->disabled = FALSE;
  270. $openlayers_maps->api_version = 1;
  271. $openlayers_maps->name = 'example_bing';
  272. $openlayers_maps->title = t('Example Microsoft Bing Map');
  273. $openlayers_maps->description = t('This map uses the Microsoft Bing map API.');
  274. $openlayers_maps->data = array(
  275. 'width' => 'auto',
  276. 'height' => '400px',
  277. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  278. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  279. 'proxy_host' => '',
  280. 'hide_empty_map' => 0,
  281. 'center' => array(
  282. 'initial' => array(
  283. 'centerpoint' => '-63.281250000007, -20.46819494553',
  284. 'zoom' => '2',
  285. ),
  286. 'restrict' => array(
  287. 'restrictextent' => 0,
  288. 'restrictedExtent' => '',
  289. ),
  290. ),
  291. 'behaviors' => array(
  292. 'openlayers_behavior_attribution' => array(
  293. 'seperator' => '',
  294. ),
  295. 'openlayers_behavior_fullscreen' => array(
  296. 'activated' => 0,
  297. ),
  298. 'openlayers_behavior_keyboarddefaults' => array(),
  299. 'openlayers_behavior_layerswitcher' => array(
  300. 'ascending' => 1,
  301. 'roundedCorner' => 1,
  302. 'roundedCornerColor' => '#222222',
  303. ),
  304. 'openlayers_behavior_navigation' => array(
  305. 'zoomWheelEnabled' => 1,
  306. 'zoomBoxEnabled' => 1,
  307. 'documentDrag' => 0,
  308. ),
  309. 'openlayers_behavior_panzoom' => array(),
  310. ),
  311. 'default_layer' => 'bing_road',
  312. 'layers' => array(
  313. 'bing_road' => 'bing_road',
  314. 'bing_hybrid' => 'bing_hybrid',
  315. 'bing_aerial' => 'bing_aerial',
  316. ),
  317. 'projection' => '900913',
  318. 'displayProjection' => '4326',
  319. 'styles' => array(
  320. 'default' => 'default',
  321. 'select' => 'default_select',
  322. 'temporary' => 'default',
  323. ),
  324. );
  325. $items['example_bing'] = $openlayers_maps;
  326. // Example OpenStreetMap
  327. $openlayers_maps = new stdClass;
  328. $openlayers_maps->disabled = FALSE;
  329. $openlayers_maps->api_version = 1;
  330. $openlayers_maps->name = 'example_osm';
  331. $openlayers_maps->title = 'Example OpenStreetMap Map';
  332. $openlayers_maps->description = 'Map to show off the OpenStreetMap layers.';
  333. $openlayers_maps->data = array(
  334. 'width' => 'auto',
  335. 'height' => '400px',
  336. 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
  337. 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
  338. 'proxy_host' => '',
  339. 'hide_empty_map' => 0,
  340. 'center' => array(
  341. 'initial' => array(
  342. 'centerpoint' => '-0.093009923589588, 51.500381463117',
  343. 'zoom' => '12',
  344. ),
  345. 'restrict' => array(
  346. 'restrictextent' => 0,
  347. 'restrictedExtent' => '',
  348. ),
  349. ),
  350. 'behaviors' => array(
  351. 'openlayers_behavior_attribution' => array(
  352. 'seperator' => '',
  353. ),
  354. 'openlayers_behavior_keyboarddefaults' => array(),
  355. 'openlayers_behavior_layerswitcher' => array(
  356. 'ascending' => 1,
  357. 'roundedCorner' => 1,
  358. 'roundedCornerColor' => '#222222',
  359. ),
  360. 'openlayers_behavior_navigation' => array(
  361. 'zoomWheelEnabled' => 1,
  362. 'zoomBoxEnabled' => 1,
  363. 'documentDrag' => 0,
  364. ),
  365. 'openlayers_behavior_zoompanel' => array(),
  366. 'openlayers_behavior_scaleline' => array(),
  367. ),
  368. 'default_layer' => 'osm_mapnik',
  369. 'layers' => array(
  370. 'osm_mapnik' => 'osm_mapnik',
  371. 'osm_cycle' => 'osm_cycle',
  372. ),
  373. 'projection' => '900913',
  374. 'displayProjection' => '4326',
  375. 'styles' => array(
  376. 'default' => 'default',
  377. 'select' => 'default_select',
  378. 'temporary' => 'default',
  379. ),
  380. );
  381. $items["example_osm"] = $openlayers_maps;
  382. // Backwards compatibilty for features presets. Since features
  383. // no longers cares about the preset hooks, we need to manually include
  384. // the preset file that stores the old hooks.
  385. $found_features = FALSE;
  386. if (module_exists('features')) {
  387. $features = features_get_features();
  388. foreach ($features as $feature) {
  389. // Only utilize enabled features and look for presets
  390. if ($feature->status > 0 && !empty($feature->info['features']['openlayers_map_presets'])) {
  391. $found_features = TRUE;
  392. // Include the file we need.
  393. $presets = $feature->info['features']['openlayers_map_presets'];
  394. $module = $feature->name;
  395. $inc = module_load_include('inc', $module, $module . '.openlayers_presets');
  396. }
  397. }
  398. }
  399. // If features found, we have to explicilty reset the implement
  400. // cache. This could be a significant performance hit on a site
  401. // that has a high number of modules installed.
  402. if ($found_features) {
  403. module_implements('openlayers_presets', FALSE, TRUE);
  404. }
  405. // Backwards compatibilty for normal presets
  406. $data = module_invoke_all('openlayers_presets');
  407. if (count($data) > 0) {
  408. $items = $items + $data;
  409. }
  410. return $items;
  411. }