openlayers_test.layers.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * @file
  4. *
  5. * OpenLayers default packaged layers
  6. */
  7. function _openlayers_test_openlayers_layers() {
  8. $layers = array();
  9. // KML example with URL
  10. $layer = new stdClass();
  11. $layer->api_version = 1;
  12. $layer->name = 'test_kml_url';
  13. $layer->title = t('KML Test URL');
  14. $layer->description = t('Testing KML layer via an URL.');
  15. $layer->data = array(
  16. 'layer_type' => 'openlayers_layer_type_kml',
  17. 'layer_handler' => 'kml',
  18. 'projection' => array('4326'),
  19. 'isBaseLayer' => FALSE,
  20. 'vector' => TRUE,
  21. 'url' => url(drupal_get_path('module', 'openlayers_test') . '/data/openlayers_test.kml'),
  22. );
  23. $layers[$layer->name] = $layer;
  24. // GeoJSON example with URL
  25. $layer = new stdClass();
  26. $layer->api_version = 1;
  27. $layer->name = 'test_geojson_url';
  28. $layer->title = t('GeoJSON Test URL');
  29. $layer->description = t('Testing GeoJSON layer via an URL.');
  30. $layer->data = array(
  31. 'layer_type' => 'openlayers_layer_type_geojson',
  32. 'layer_handler' => 'geojson',
  33. 'projection' => array('4326'),
  34. 'isBaseLayer' => FALSE,
  35. 'vector' => TRUE,
  36. 'url' => url(drupal_get_path('module', 'openlayers_test') . '/data/openlayers_test.json'),
  37. );
  38. $layers[$layer->name] = $layer;
  39. // GeoJSON example with direct data
  40. $layer = new stdClass();
  41. $layer->api_version = 1;
  42. $layer->name = 'test_geojson_direct_data';
  43. $layer->title = t('GeoJSON Test Direct Data');
  44. $layer->description = t('Testing putting GeoJSON directly in layer.');
  45. $layer->data = array(
  46. 'layer_type' => 'openlayers_layer_type_geojson',
  47. 'layer_handler' => 'geojson',
  48. 'projection' => array('4326'),
  49. 'isBaseLayer' => FALSE,
  50. 'vector' => TRUE,
  51. 'geojson_data' => '
  52. {
  53. "type": "Feature",
  54. "properties": {
  55. "name": "Hello, World",
  56. "description": "This is a GeoJSON test with data directly in the layer."
  57. },
  58. "geometry": {
  59. "type": "Polygon",
  60. "coordinates": [
  61. [
  62. [
  63. -17.578125,
  64. -1.0546875
  65. ],
  66. [
  67. -37.265625,
  68. 3.1640625
  69. ],
  70. [
  71. -54.140625,
  72. -3.8671875
  73. ],
  74. [
  75. -48.515625,
  76. -20.0390625
  77. ],
  78. [
  79. -30.9375,
  80. -24.9609375
  81. ],
  82. [
  83. -21.796875,
  84. -29.1796875
  85. ],
  86. [
  87. -23.90625,
  88. -36.9140625
  89. ],
  90. [
  91. -39.375,
  92. -42.5390625
  93. ],
  94. [
  95. -51.328125,
  96. -44.6484375
  97. ],
  98. [
  99. -50.625,
  100. -52.3828125
  101. ],
  102. [
  103. -28.125,
  104. -48.8671875
  105. ],
  106. [
  107. -13.359375,
  108. -41.1328125
  109. ],
  110. [
  111. -11.953125,
  112. -24.9609375
  113. ],
  114. [
  115. -28.125,
  116. -15.8203125
  117. ],
  118. [
  119. -44.296875,
  120. -11.6015625
  121. ],
  122. [
  123. -35.859375,
  124. -1.7578125
  125. ],
  126. [
  127. -23.203125,
  128. -9.4921875
  129. ],
  130. [
  131. -17.578125,
  132. -1.0546875
  133. ]
  134. ]
  135. ]
  136. },
  137. "crs": {
  138. "type": "name",
  139. "properties": {
  140. "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
  141. }
  142. }
  143. }
  144. ',
  145. );
  146. $layers[$layer->name] = $layer;
  147. return $layers;
  148. }