JAVASCRIPT.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. Current for 6.x-2.0-alpha3
  2. The OpenLayers module aims to add minimal abstraction in Javascript to what is
  3. already provided by the [OpenLayers](http://openlayers.org/) Javascript library.
  4. However, it does create certain structures that may not be immediately obvious.
  5. # Data Storage
  6. The module stores all settings initially under Drupal.settings.openlayers. It
  7. does this in a slightly modified way if your server supports native JSON writing
  8. - this basically means that, instead of using Drupal to encode the settings
  9. array, it uses a PHP extension (written in C). This greatly increases
  10. performance for displaying many points on maps.
  11. # Keeping Track of Maps
  12. The OpenLayers map object, which contains pointers to all layers, etc., is
  13. stored with the [jQuery data() method](http://api.jquery.com/jQuery.data/),
  14. which provides the phenomenal convenience of storing arbitrary data within the
  15. DOM itself. This means that the map object is attached to the openlayers-map-0,
  16. or so on, div element in your page. So, to access it, one could use a line like
  17. $('#openlayers-map-0').data('openlayers')
  18. In FireBug, Safari, or Chrome.
  19. Note that the 2.x branch strives to not duplicate map information: it exists in
  20. the Drupal settings array and then is transformed into a map object, but after
  21. that point, the canonical location for data about maps is in the map object.
  22. This is for purposes of both flexibility, since the map object lets developers
  23. access objects by better getter methods, and for the purpose of keeping
  24. OpenLayers behaviors and layer initialization code less tied to Drupal than
  25. before.