Please note that the upgrade path will not be stable until the OpenLayers 2.x branch is stable, and this page will probably not be 100% accurate until that time as well. BACKUP before upgrading!

These instructions are for users upgrading their OpenLayers modules from 1.x (1.0) to the newer 2.x (2.0) versions. The 2.x version of the module is much more powerful and will have longer term support and development for it. Upgrading from 0.x (0.1-alpha) is a different process than this.

Prepare

  1. Please, for your piece of mind, backup your database and your code before doing any upgrades. If something goes wrong, you will be very disappointed if you had not backed-up.
  2. Ensure that you have newest 1.x version and have run all the updates. This is necessary so that the 2.x version knows you are upgrading from the 1.x version.
  3. Put your site into offline/maintenance mode.
  4. Disable OpenLayers Preset UI module. This module is renamed in the 2.x version.

Note that the automatic part of the upgrade will only encompass the data that is contained in the database, specifically the presets. This means that any objects (such as layers, styles, presets, etc.) that you may have put in a custom module will not be upgraded; these will need to be manually upgraded.

Module Update

The following is the normal upgrade mechanism for Drupal. This handles the automatic part of the upgrade. Note that only objects in the database can be automatically upgraded; meaning that if you have objects in code, they will not be upgraded.

  1. Remove any 1.x code.
  2. Download the 2.x code.
  3. Go to update.php and run database updates.

Manual Changes

There are still some steps that need to be taken to ensure that everything is working correctly.

Preset Changes

It is suggested that you look over your map presets to ensure that all the settings are correct. Some properties, layers, etc. are automatically

OpenLayers CCK

  • OpenLayers WKT Map widget:
    • The settings of the field/widget are not transferred, so you will have to set these back up.
    • The format of the WKT is different in the 2.x module. The main thing is that in the 2.x version, everything is in a GEOMETRYCOLLECTION(). For instance:
      • POINT(12 12) becomes GEOMETRYCOLLECTION(POINT(12 12))
      • MULTIPOINT((3.5 5.6),(4.8 10.5)) becomes GEOMETRYCOLLECTION(POINT(3.5 5.6),POINT(4.8 10.5))
    • This change in the WKT format is not addressed to ensure that the behavior of the fields will remain the same, and OpenLayers can handle either format without any problem. You do not need to update the data.
  • Support for the Geo module has been removed, if you were using Openlayers to provide widgets for Geo fields you will need to find an alternative.

OpenLayers Views

Due to structural changes in how we use views in 2.x, there is no way to provide an automatic upgrade for your OpenLayers views. You may end up with Views that use the OpenLayers style, but they will not have data in them, nor will they have the same behaviors.

You should rebuild all your OpenLayers Views. Please read the 2.x tutorial on Views that explains how this new structure works. The biggest concept change is that there is a separate between providing data Views to maps and displaying maps with Views.

API Change

There are some large architectural changes in 2.x and thus some significant API changes. Please see the 2.x documentation for how the new data structures and objects work.

Hook Changes

1.x 2.x
hook_openlayers_map_preprocess_alter(&$map = array()) (same)
hook_openlayers_map_alter(&$map = array()) (same)
hook_openlayers_behaviors_info() hook_openlayers_behaviors()
<code>hook_openlayers_layers_handler_info($map = array()) hook_openlayers_layer_types()
hook_openlayers_layers_info() hook_openlayers_layers
hook_openlayers_presets() (same)
hook_openlayers_styles_info() hook_openlayers_styles()

API Changes

Needs work:

BECAME openlayers_include(): openlayers_initialize()
openlayers_render_map($map = array(), $render = TRUE)
openlayers_layers_get_info($reset = FALSE)
openlayers_behaviors_get_info($reset = FALSE)
openlayers_styles_get_info($reset = FALSE)
BECAME openlayers_preset_save($preset = array()): openlayers_save_preset($preset = array())
openlayers_get_preset($name = '', $reset = FALSE)
openlayers_get_map($id = '')
openlayers_presets($reset = FALSE)
openlayers_get_presets($format = 'simple', $reset = FALSE)
openlayers_get_default_map($reset = FALSE)
REMOVED: openlayers_merge_maps($map1 = array(), $map2 = array())
openlayers_error_check_map($map, $log_errors = TRUE)

Theme Changes

  • theme_openlayers_map($map = array()) => (remains same)
  • theme_openlayers_vector_styles($styles = array(), $map = array()) => theme_openlayers_styles($styles = array(), $map = array())
  • theme_openlayers_behaviors_tooltip_container($behavior = array(), $map = array()) => ??
  • theme_openlayers_presets_ui_form_layer_description($layer_title = '', $layer_description = '') => (remains same)
  • theme_openlayers_presets_ui_form_projection_description($projection_title = '', $available_layers = array(), $layers = array()) => (remains same)
  • theme_openlayers_views_feature_style($view = NULL, $row = NULL, $group = NULL) => ??

Menu Change

Instead of living under Site Configuration (admin/settings), the OpenLayers menu items are now under Site Building (admin/build).

Any bug reports and support requests should be reported in the OpenLayers issue queue.

Comments

tmcw’s picture

Please post on the OpenLayers Issue queue with any bug reports and support requests. We cannot provide support on Book Pages.