README.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Download the leaflet library from: http://leafletjs.com/download.html
  2. Alternatively, you can build the library from source. If so, follow the
  3. instructions at: http://leafletjs.com/download.html#leaflet-source-code
  4. Maps can be rendered via the included field formatter for Geofield, by using the
  5. API directly, or by taking advantage of an additional module, like
  6. http://drupal.org/project/ip_geoloc
  7. Installation
  8. ------------
  9. 1. Install the Drupal Leaflet module as per normal.
  10. 2. Download the Leaflet library from http://leafletjs.com. Leaflet 0.7.5 or later
  11. is recommended. Extract it to your drupal root /sites/all/libraries/leaflet.
  12. The file 'leaflet.js' must reside at /sites/all/libraries/leaflet/leaflet.js.
  13. All other files and folder(s) that come with the library are also needed.
  14. 3. Enable leaflet_views for using Views and Leaflet (see below), or use the
  15. display formatters for fields display.
  16. API Usage
  17. ---------
  18. Building a map is as simple as calling a single method, leaflet_build_map(),
  19. which takes 3 parameters.
  20. $map (array)
  21. An associative array defining a map. See hook_leaflet_map_info(). The module
  22. defines a default map with a OpenStreet Maps base layer.
  23. $features (array)
  24. This is the tricky part. This is an associative array of all the features you
  25. want to plot on the map. A feature can be a point, linestring, polygon,
  26. multilinestring, multipolygon, or json object. Additionally, features can be
  27. grouped into layer groups so they can be controlled together,
  28. http://leaflet.cloudmade.com/reference.html#layergroup. A feature will look
  29. something like:
  30. $features = array(
  31. array(
  32. 'type' => 'point',
  33. 'lat' => 12.32,
  34. 'lon' => 123.45,
  35. 'icon' => array(
  36. 'iconUrl' => 'sites/default/files/mymarker.png'
  37. ),
  38. 'popup' => l($node->title, 'node/' . $node->nid),
  39. 'leaflet_id' => 'some unique ID'
  40. ),
  41. array(
  42. 'type' => 'linestring',
  43. 'points' => array(
  44. 0 => array('lat' => 13.24, 'lon' => 123.2),
  45. 1 => array('lat' => 13.24, 'lon' => 123.2),
  46. 2 => array('lat' => 13.24, 'lon' => 123.2),
  47. 3 => array('lat' => 13.24, 'lon' => 123.2),
  48. 4 => array('lat' => 13.24, 'lon' => 123.2),
  49. ),
  50. 'popup' => l($node->title, 'node/' . $node->nid),
  51. 'leaflet_id' => 'some unique ID'
  52. ),
  53. array(
  54. 'type' => 'json',
  55. 'json' => [JSON OBJECT],
  56. 'properties' = array(
  57. 'style' => [style settings],
  58. 'leaflet_id' => 'some unique ID'
  59. )
  60. )
  61. );
  62. $height (string)
  63. Height of the map expressed in pixels. Append 'px'. Default: '400px'.
  64. Views integration
  65. -----------------
  66. To render a map using Views, enable the module leaflet_views.
  67. You need to add at least one geofield to the Fields list, and select the Leaflet Map style
  68. in Format.
  69. In the settings of the style, select the geofield as the Data Source and select a field for Title
  70. and Description (which will be rendered in the popup).
  71. As a more powerful alternative, you can use node view modes to be rendered in the popup.
  72. In the Description field, select "<entire node>" and then select a View mode.
  73. For a tutorial, please read http://marzeelabs.org/blog/2012/09/24/building-maps-in-drupal-using-leaflet-views/
  74. Roadmap
  75. -------
  76. * UI for managing maps
  77. * Better documentation
  78. Authors/Credits
  79. ---------------
  80. * [levelos](http://drupal.org/user/54135)
  81. * [pvhee](http://drupal.org/user/108811)