leaflet.api.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * API documentation for Administration menu.
  5. */
  6. /**
  7. * Define one or map definitions to be used when rendering a map.
  8. *
  9. * leaflet_map_get_info() will grab every defined map, and the returned
  10. * associative array is then passed to leaflet_render_map(), along with a
  11. * collection of features.
  12. *
  13. * The settings array maps to the settings available to leaflet map object,
  14. * http://leaflet.cloudmade.com/reference.html#map-properties
  15. *
  16. * Layers are the available base layers for the map and, if you enable the
  17. * layer control, can be toggled on the map.
  18. *
  19. * @return array
  20. * Associative array containing a complete leaflet map definition.
  21. */
  22. function hook_leaflet_map_info() {
  23. return array(
  24. 'OSM Mapnik' => array(
  25. 'label' => 'OSM Mapnik',
  26. 'description' => t('Leaflet default map.'),
  27. 'settings' => array(
  28. 'dragging' => TRUE,
  29. 'touchZoom' => TRUE,
  30. 'scrollWheelZoom' => TRUE,
  31. 'doubleClickZoom' => TRUE,
  32. 'zoomControl' => TRUE,
  33. 'attributionControl' => TRUE,
  34. 'trackResize' => TRUE,
  35. 'fadeAnimation' => TRUE,
  36. 'zoomAnimation' => TRUE,
  37. 'closePopupOnClick' => TRUE,
  38. 'layerControl' => TRUE,
  39. // 'minZoom' => 10,
  40. // 'maxZoom' => 15,
  41. // 'zoom' => 15, // set the map zoom fixed to 15
  42. ),
  43. 'layers' => array(
  44. 'earth' => array(
  45. 'urlTemplate' => '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  46. 'options' => array(
  47. 'attribution' => 'OSM Mapnik',
  48. // The switchZoom controls require multiple layers, referencing one
  49. // another as "switchLayer".
  50. 'switchZoomBelow' => 15,
  51. 'switchLayer' => 'satellite',
  52. ),
  53. ),
  54. 'satellite' => array(
  55. 'urlTemplate' => '//otile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png',
  56. 'options' => array(
  57. 'attribution' => 'OSM Mapnik',
  58. 'subdomains' => '1234',
  59. 'switchZoomAbove' => 15,
  60. 'switchLayer' => 'earth',
  61. ),
  62. ),
  63. ),
  64. // Uncomment the lines below to use a custom icon
  65. // 'icon' => array(
  66. // 'iconUrl' => '/sites/default/files/icon.png',
  67. // 'iconSize' => array('x' => '20', 'y' => '40'),
  68. // 'iconAnchor' => array('x' => '20', 'y' => '40'),
  69. // 'popupAnchor' => array('x' => '-8', 'y' => '-32'),
  70. // 'shadowUrl' => '/sites/default/files/icon-shadow.png',
  71. // 'shadowSize' => array('x' => '25', 'y' => '27'),
  72. // 'shadowAnchor' => array('x' => '0', 'y' => '27'),
  73. // ),
  74. ),
  75. );
  76. }
  77. /**
  78. * Alters the js settings passed to the leaflet map.
  79. *
  80. * This hook is called when the leaflet map is being rendered and attaching the
  81. * client side javascript settings.
  82. *
  83. * @param $settings
  84. * A javascript settings array used for building the leaflet map.
  85. *
  86. * @see leaflet_map_get_info()
  87. * @see hook_leaflet_map_info()
  88. */
  89. function hook_leaflet_map_prebuild_alter(&$settings) {
  90. $settings['mapId'] = 'my-map-id';
  91. $settings['features']['icon'] = 'my-icon-url';
  92. }