You are here

JAVASCRIPT.txt in Openlayers 6.2

Same filename and directory in other branches
  1. 7.2 docs/JAVASCRIPT.txt
Current for 6.x-2.0-alpha3

The OpenLayers module aims to add minimal abstraction in Javascript to what is
already provided by the [OpenLayers](http://openlayers.org/) Javascript library.
However, it does create certain structures that may not be immediately obvious.

# Data Storage

The module stores all settings initially under Drupal.settings.openlayers. It
does this in a slightly modified way if your server supports native JSON writing
- this basically means that, instead of using Drupal to encode the settings
array, it uses a PHP extension (written in C). This greatly increases
performance for displaying many points on maps.

# Keeping Track of Maps

The OpenLayers map object, which contains pointers to all layers, etc., is
stored with the [jQuery data() method](http://api.jquery.com/jQuery.data/),
which provides the phenomenal convenience of storing arbitrary data within the
DOM itself. This means that the map object is attached to the openlayers-map-0,
or so on, div element in your page. So, to access it, one could use a line like

    $('#openlayers-map-0').data('openlayers')

In FireBug, Safari, or Chrome.

Note that the 2.x branch strives to not duplicate map information: it exists in
the Drupal settings array and then is transformed into a map object, but after
that point, the canonical location for data about maps is in the map object.
This is for purposes of both flexibility, since the map object lets developers
access objects by better getter methods, and for the purpose of keeping
OpenLayers behaviors and layer initialization code less tied to Drupal than
before.

File

docs/JAVASCRIPT.txt
View source
  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.