openlayers.layers.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <?php
  2. /**
  3. * @file
  4. *
  5. * OpenLayers default packaged layers
  6. */
  7. function _openlayers_openlayers_layers() {
  8. global $is_https;
  9. $mapquest_host = $is_https ? '-s.mqcdn.com' : '.mqcdn.com';
  10. $layers = array();
  11. $layer = new stdClass();
  12. $layer->api_version = 1;
  13. $layer->name = 'google_satellite';
  14. $layer->title = 'Google Maps Satellite';
  15. $layer->description = 'Google Maps Satellite Imagery.';
  16. $layer->data = array(
  17. 'isBaseLayer' => TRUE,
  18. 'type' => 'satellite',
  19. 'projection' => array('900913'),
  20. 'layer_type' => 'openlayers_layer_type_google',
  21. );
  22. $layers[$layer->name] = $layer;
  23. $layer = new stdClass();
  24. $layer->api_version = 1;
  25. $layer->name = 'google_hybrid';
  26. $layer->title = 'Google Maps Hybrid';
  27. $layer->description = 'Google Maps with roads and terrain.';
  28. $layer->data = array(
  29. 'isBaseLayer' => TRUE,
  30. 'type' => 'hybrid',
  31. 'projection' => array('900913'),
  32. 'layer_type' => 'openlayers_layer_type_google',
  33. );
  34. $layers[$layer->name] = $layer;
  35. $layer = new stdClass();
  36. $layer->api_version = 1;
  37. $layer->name = 'google_normal';
  38. $layer->title = 'Google Maps Normal';
  39. $layer->description = 'Standard Google Maps Roads';
  40. $layer->data = array(
  41. 'isBaseLayer' => TRUE,
  42. 'type' => 'normal',
  43. 'projection' => array('900913'),
  44. 'layer_type' => 'openlayers_layer_type_google',
  45. );
  46. $layers[$layer->name] = $layer;
  47. $layer = new stdClass();
  48. $layer->api_version = 1;
  49. $layer->name = 'google_physical';
  50. $layer->title = 'Google Maps Physical';
  51. $layer->description = 'Google Maps Hillshades';
  52. $layer->data = array(
  53. 'isBaseLayer' => TRUE,
  54. 'type' => 'physical',
  55. 'projection' => array('900913'),
  56. 'layer_type' => 'openlayers_layer_type_google',
  57. );
  58. $layers[$layer->name] = $layer;
  59. $layer = new stdClass();
  60. $layer->api_version = 1;
  61. $layer->name = 'mapquest_osm';
  62. $layer->title = 'MapQuest OSM';
  63. $layer->description = 'MapQuest’s rendering of OpenStreetMap.';
  64. $layer->data = array(
  65. 'isBaseLayer' => TRUE,
  66. 'attribution' => t('&copy;<a href="@ccbysa">CCBYSA</a> '.
  67. '<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
  68. array(
  69. '@openstreetmap' => 'http://www.openstreetmap.org/copyright',
  70. '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
  71. )
  72. ) . '. '. t('Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a>.'),
  73. 'projection' => array('900913'),
  74. 'layer_type' => 'openlayers_layer_type_xyz',
  75. 'url' => array(
  76. '//otile1' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png',
  77. '//otile2' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png',
  78. '//otile3' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png',
  79. '//otile4' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png',
  80. ),
  81. 'wrapDateLine' => FALSE,
  82. 'resolutions' => openlayers_get_resolutions('900913', 0, 19)
  83. );
  84. $layers[$layer->name] = $layer;
  85. $layer = new stdClass();
  86. $layer->api_version = 1;
  87. $layer->name = 'mapquest_openaerial';
  88. $layer->title = 'MapQuest Open Aerial';
  89. $layer->description = 'MapQuest’s aerial photo map.';
  90. $layer->data = array(
  91. 'isBaseLayer' => TRUE,
  92. 'attribution' => t('Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency.')
  93. . ' '. t('Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a>.'),
  94. 'projection' => array('900913'),
  95. 'layer_type' => 'openlayers_layer_type_xyz',
  96. 'url' => array(
  97. '//oatile1' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
  98. '//oatile2' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
  99. '//oatile3' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
  100. '//oatile4' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
  101. ),
  102. 'wrapDateLine' => TRUE,
  103. );
  104. $layers[$layer->name] = $layer;
  105. $layer = new stdClass();
  106. $layer->api_version = 1;
  107. $layer->name = 'yahoo_satellite';
  108. $layer->title = 'Yahoo Maps Satellite';
  109. $layer->description = 'Yahoo satellite imagery tiles.';
  110. $layer->data = array(
  111. 'isBaseLayer' => TRUE,
  112. 'type' => 'satellite',
  113. 'projection' => array('900913'),
  114. 'layer_type' => 'openlayers_layer_type_yahoo',
  115. );
  116. $layers[$layer->name] = $layer;
  117. $layer = new stdClass();
  118. $layer->api_version = 1;
  119. $layer->name = 'yahoo_street';
  120. $layer->title = 'Yahoo Maps Street';
  121. $layer->description = 'Yahoo streets tiles.';
  122. $layer->data = array(
  123. 'isBaseLayer' => TRUE,
  124. 'type' => 'street',
  125. 'projection' => array('900913'),
  126. 'layer_type' => 'openlayers_layer_type_yahoo',
  127. );
  128. $layers[$layer->name] = $layer;
  129. $layer = new stdClass();
  130. $layer->api_version = 1;
  131. $layer->name = 'yahoo_hybrid';
  132. $layer->title = 'Yahoo Maps Hybrid';
  133. $layer->description = 'Yahoo hybrid of streets and satellite tiles.';
  134. $layer->data = array(
  135. 'isBaseLayer' => TRUE,
  136. 'type' => 'hybrid',
  137. 'projection' => array('900913'),
  138. 'layer_type' => 'openlayers_layer_type_yahoo',
  139. );
  140. $layers[$layer->name] = $layer;
  141. // Bing Road
  142. $layer = new stdClass();
  143. $layer->api_version = 1;
  144. $layer->name = 'bing_road';
  145. $layer->title = 'Bing Road';
  146. $layer->description = 'Bing Road tiles.';
  147. $layer->data = array(
  148. 'isBaseLayer' => TRUE,
  149. 'type' => 'Road',
  150. 'projection' => array('900913'),
  151. 'layer_type' => 'openlayers_layer_type_bing',
  152. );
  153. $layers[$layer->name] = $layer;
  154. // Bing Aerial
  155. $layer = new stdClass();
  156. $layer->api_version = 1;
  157. $layer->name = 'bing_aerial';
  158. $layer->title = 'Bing Aerial';
  159. $layer->description = 'Bing Aerial tiles.';
  160. $layer->data = array(
  161. 'isBaseLayer' => TRUE,
  162. 'type' => 'Aerial',
  163. 'projection' => array('900913'),
  164. 'layer_type' => 'openlayers_layer_type_bing',
  165. );
  166. $layers[$layer->name] = $layer;
  167. // Bing Hybrid
  168. $layer = new stdClass();
  169. $layer->api_version = 1;
  170. $layer->name = 'bing_hybrid';
  171. $layer->title = 'Bing Hybrid';
  172. $layer->description = 'Bing Hybrid tiles.';
  173. $layer->data = array(
  174. 'isBaseLayer' => TRUE,
  175. 'type' => 'AerialWithLabels',
  176. 'projection' => array('900913'),
  177. 'layer_type' => 'openlayers_layer_type_bing',
  178. );
  179. $layers[$layer->name] = $layer;
  180. // OpenStreetMap Mapnik
  181. $layer = new stdClass();
  182. $layer->api_version = 1;
  183. $layer->name = 'osm_mapnik';
  184. $layer->title = 'OSM Mapnik';
  185. $layer->description = 'The main OpenStreetMap map';
  186. $layer->data = array(
  187. 'isBaseLayer' => TRUE,
  188. 'attribution' => t('&copy;<a href="@ccbysa">CCBYSA</a> '.
  189. '<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
  190. array(
  191. '@openstreetmap' => 'http://www.openstreetmap.org/copyright',
  192. '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
  193. )
  194. ),
  195. 'projection' => array('900913'),
  196. 'layer_type' => 'openlayers_layer_type_xyz',
  197. 'url' => '//tile.openstreetmap.org/${z}/${x}/${y}.png',
  198. 'wrapDateLine' => TRUE,
  199. );
  200. $layers[$layer->name] = $layer;
  201. // OpenStreetMap Cycling Map
  202. $layer = new stdClass();
  203. $layer->api_version = 1;
  204. $layer->name = 'osm_cycle';
  205. $layer->title = 'OSM Cycling Map';
  206. $layer->description = 'OpenStreetMap with highlighted bike lanes';
  207. $layer->data = array(
  208. 'isBaseLayer' => TRUE,
  209. 'attribution' => t('&copy;<a href="@ccbysa">CCBYSA</a> '.
  210. '<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
  211. array(
  212. '@openstreetmap' => 'http://www.openstreetmap.org/copyright',
  213. '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
  214. )
  215. ),
  216. 'projection' => array('900913'),
  217. 'layer_type' => 'openlayers_layer_type_xyz',
  218. 'url' => '//a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png',
  219. 'wrapDateLine' => TRUE,
  220. );
  221. $layers[$layer->name] = $layer;
  222. // OpenStreetMap 426 hybrid overlay
  223. $layer = new stdClass();
  224. $layer->api_version = 1;
  225. $layer->name = 'osm_4326_hybrid';
  226. $layer->title = 'OSM Overlay';
  227. $layer->description = 'Semi-transparent hybrid overlay. Projected into
  228. WSG84 for use on non spherical-mercator maps.';
  229. $layer->data = array(
  230. 'isBaseLayer' => FALSE,
  231. 'attribution' => t('&copy;<a href="@ccbysa">CCBYSA</a> '.
  232. '<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
  233. array(
  234. '@openstreetmap' => 'http://www.openstreetmap.org/copyright',
  235. '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
  236. )
  237. ),
  238. 'projection' => array('4326'),
  239. 'layer_type' => 'openlayers_layer_type_wms',
  240. 'url' => 'http://oam.hypercube.telascience.org/tiles',
  241. 'params' => array(
  242. 'isBaseLayer' => FALSE,
  243. 'layers' => 'osm-4326-hybrid',
  244. ),
  245. 'options' => array(
  246. 'buffer' => 1,
  247. ),
  248. );
  249. $layers[$layer->name] = $layer;
  250. /* Example with KML layer */
  251. $layer = new stdClass();
  252. $layer->disabled = FALSE; /* Edit this to true to make a default openlayers_layers disabled initially */
  253. $layer->api_version = 1;
  254. $layer->name = 'openlayers_kml_example';
  255. $layer->title = 'KML Example Layer';
  256. $layer->description = 'A simple example of KML Layer Type.';
  257. $layer->data = array(
  258. 'method' => 'raw',
  259. 'raw' => '<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Placemark><name>Simple placemark</name><description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description><Point><coordinates>-122.0822035425683,37.42228990140251,0</coordinates></Point></Placemark></kml>',
  260. 'formatOptions' => array(
  261. 'extractStyles' => TRUE,
  262. 'extractTracks' => FALSE,
  263. 'extractAttributes' => TRUE,
  264. ),
  265. 'projection' => array(
  266. 0 => '4326',
  267. ),
  268. 'isBaseLayer' => 0,
  269. 'layer_type' => 'openlayers_layer_type_kml',
  270. 'layer_handler' => 'kml',
  271. 'vector' => TRUE,
  272. );
  273. $layers[$layer->name] = $layer;
  274. // MetaCarts base map
  275. $layer = new stdClass();
  276. $layer->api_version = 1;
  277. $layer->name = 'wms_default';
  278. $layer->title = 'Default OpenLayers WMS';
  279. $layer->description = 'MetaCarta basemap of province and water boundaries';
  280. $layer->data = array(
  281. 'projection' => array('4326'),
  282. 'isBaseLayer' => TRUE,
  283. 'layer_type' => 'openlayers_layer_type_wms',
  284. 'base_url' => '//labs.metacarta.com/wms-c/Basic.py',
  285. 'params' => array(
  286. 'isBaseLayer' => TRUE,
  287. ),
  288. 'options' => array(
  289. 'layers' => array('basic'),
  290. 'maxExtent' => openlayers_get_extent('4326'),
  291. ),
  292. );
  293. $layers[$layer->name] = $layer;
  294. // GeoJSON example with direct data
  295. $layer = new stdClass();
  296. $layer->api_version = 1;
  297. $layer->name = 'openlayers_geojson_picture_this';
  298. $layer->title = t('Example GeoJSON, "Picture This"');
  299. $layer->description = t('Example that puts GeoJSON directly in layer without Views.');
  300. $layer->data = array(
  301. 'resolutions' => openlayers_get_resolutions('900913'),
  302. 'serverResolutions' => openlayers_get_resolutions('4326'),
  303. 'layer_type' => 'openlayers_layer_type_geojson',
  304. 'layer_handler' => 'geojson',
  305. 'projection' => array('4326'),
  306. 'isBaseLayer' => FALSE,
  307. 'vector' => TRUE,
  308. 'geojson_data' => '
  309. {
  310. "type": "Feature",
  311. "properties": {
  312. "name": "' . t('Picture This') . '",
  313. "description": "' . t('Outside of the North Carolina Museum of Art.') . '"
  314. },
  315. "geometry": {
  316. "type": "Point",
  317. "coordinates": [
  318. -78.702798,
  319. 35.809411
  320. ]
  321. },
  322. "crs": {
  323. "type": "name",
  324. "properties": {
  325. "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
  326. }
  327. }
  328. }
  329. ',
  330. );
  331. $layers[$layer->name] = $layer;
  332. $info = _mapbox_layers_info();
  333. $resolutions = array_combine(range(0, 21), openlayers_get_resolutions('900913'));
  334. foreach ($info as $key => $item) {
  335. $openlayers_layers = new stdClass;
  336. $openlayers_layers->disabled = FALSE; /* Edit this to true to make a default openlayers_layers disabled initially */
  337. $openlayers_layers->api_version = 1;
  338. $openlayers_layers->name = $key;
  339. $openlayers_layers->title = $item['name'];
  340. $openlayers_layers->description = $item['description'];
  341. $openlayers_layers->data = array(
  342. 'url' => array(
  343. 0 => 'http://a.tiles.mapbox.com/',
  344. 1 => 'http://b.tiles.mapbox.com/',
  345. 2 => 'http://c.tiles.mapbox.com/',
  346. 3 => 'http://d.tiles.mapbox.com/',
  347. ),
  348. 'layername' => $item['layername'],
  349. 'layer_type' => 'openlayers_layer_type_mapbox',
  350. 'osm' => FALSE,
  351. 'isBaseLayer' => TRUE,
  352. 'type' => 'png',
  353. 'resolutions' => array_intersect_key($resolutions, array_flip(range($item['minzoom'], $item['maxzoom']))),
  354. 'projection' => array('900913'),
  355. );
  356. $layers[$key] = $openlayers_layers;
  357. }
  358. return $layers;
  359. }
  360. /**
  361. * This function is for the po editor to be able to find these strings,
  362. * since in the codebase they are not in t()'s, because they are later
  363. * run through t() in the layer loader function
  364. */
  365. function _openlayers_openlayers_layers_i18n() {
  366. $translatable_strings = array(
  367. // titles
  368. t('Google Maps Satellite'),
  369. t('Google Maps Hybrid'),
  370. t('Google Maps Normal'),
  371. t('Google Maps Physical'),
  372. t('Bing Road'),
  373. t('Bing Aerial'),
  374. t('Bing Hybrid'),
  375. t('Yahoo Maps Street'),
  376. t('Yahoo Maps Hybrid'),
  377. t('Yahoo Maps Satellite'),
  378. t('OSM Mapnik'),
  379. t('OSM Cycling Map'),
  380. t('OSM Overlay'),
  381. t('Default OpenLayers WMS'),
  382. // descriptions
  383. t('Alternative, community-rendered OpenStreetMap'),
  384. t('Google Maps Hillshades'),
  385. t('Google Maps Satellite Imagery.'),
  386. t('Google Maps with roads and terrain.'),
  387. t('MetaCarta basemap of province and water boundaries'),
  388. t('OpenStreetMap with highlighted bike lanes'),
  389. t('Semi-transparent hybrid overlay. Projected into
  390. WSG84 for use on non spherical-mercator maps.'),
  391. t('Standard Google Maps Roads'),
  392. t('The main OpenStreetMap map'),
  393. t('Bing Road tiles.'),
  394. t('Bing Aerial tiles.'),
  395. t('Bing Hybrid tiles.'),
  396. t('Yahoo hybrid of streets and satellite tiles.'),
  397. t('Yahoo satellite imagery tiles.'),
  398. t('Yahoo streets tiles.'),
  399. t('MapQuest’s rendering of OpenStreetMap.'),
  400. t('MapQuest’s aerial photo map.'),
  401. );
  402. }
  403. function _mapbox_layers_info() {
  404. $info = array();
  405. $info['mapbox_streets'] = array(
  406. 'name'=> t('MapBox Streets'),
  407. 'description' => t('MapBox Streets'),
  408. 'layername' => 'mapbox-streets',
  409. 'minzoom' => 0,
  410. 'maxzoom' => 16
  411. );
  412. $info['mapbox_world_bright'] = array(
  413. 'name' => t('MapBox World Bright'),
  414. 'description' => t('MapBox World Bright'),
  415. 'layername' => 'world-bright',
  416. 'minzoom' => 0,
  417. 'maxzoom' => 11,
  418. );
  419. $info['mapbox_world_dark'] = array(
  420. 'name' => t('MapBox World Dark'),
  421. 'description' => t('MapBox World Dark'),
  422. 'layername' => 'world-dark',
  423. 'minzoom' => 0,
  424. 'maxzoom' => 11,
  425. );
  426. $info['mapbox_world_light'] = array(
  427. 'name' => t('MapBox World Light'),
  428. 'description' => t('MapBox World Light'),
  429. 'layername' => 'world-light',
  430. 'minzoom' => 0,
  431. 'maxzoom' => 11,
  432. );
  433. $info['mapbox_world_print'] = array(
  434. 'name' => t('MapBox World Print'),
  435. 'description' => t('MapBox World Print'),
  436. 'layername' => 'world-print',
  437. 'minzoom' => 0,
  438. 'maxzoom' => 9,
  439. );
  440. $info['mapbox_world_black'] = array(
  441. 'name' => t('MapBox World Black'),
  442. 'description' => t('MapBox World Black'),
  443. 'layername' => 'world-black',
  444. 'minzoom' => 0,
  445. 'maxzoom' => 11,
  446. );
  447. return $info;
  448. }