Currently, this module defaults to using version 3.11.2 of the Openlayers Javascript library. The latest release is 4.3.3 (the "4" does not designate a major version change, just a switch to using semantic versioning - see https://github.com/openlayers/openlayers/releases/tag/v4.0.0).

I am testing the latest version on my local development site. I will outline any necessary changes I come across here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m.stenta created an issue. See original summary.

m.stenta’s picture

So far, the only immediate issue I found that will require changes on our end is that map.beforeRender() and ol.animation were deprecated in 3.20, and removed in 4.0.0.

We use map.beforeRender() and ol.animation in the following places:

  • Geolocation component
  • ZoomToSource component
  • AutoZoom control
  • JSGeocoder control
  • Autopopup control
  • Inside a custom component provided by openlayers_default_openlayers_components() (using InlineJS)
m.stenta’s picture

m.stenta’s picture

Status: Active » Needs work
FileSize
6.41 KB

I've started an "ol4" branch in my Github repository: https://github.com/mstenta/openlayers/compare/7.x-3.x...mstenta:ol4

Two changes so far:

  1. Update default Openlayers JS library version from 3.11.2 to 4.3.3.
  2. Update ZoomToSource Component: use new view.animate() method.

I modified the settings of the ZoomToSource component slightly: I merged the two separate "pan" and "zoom" duration settings into a single "duration" setting, and removed the "enableAnimations". This is because the new view.animate() method is the only way to perform the zoom-to-source, so animations are a must. If you don't want it to be animated, you can simply set the duration to 0. Also, there doesn't appear to be a way to have separate durations for "pan" and "zoom". So it's a bit more simplified now. I also updated the exported config in the openlayers_examples and openlayers_geofield modules.

I think this ZoomToSource Component is complete, so it's ready for review. This is the only one I need currently - but I might take a look at the others now as well to see if they are easy.

Attached is a patch that simply updates the ZoomToSource Component - because I need that immediately in farmOS, which is built via Drush Make currently.

Setting this to "Needs Work" because there is more to be done.

Dirkozoid’s picture

I can confirm that ZoomToLayer works again also with Openlayers JS library version 4.3.4 after applying this patch. This version of the library fixes this issue Map freezing with iOS 11 #7202.

Thank you very much for this patch!

But the problem with grey Google Maps after pinch zooming persist. It is caused by the fractional zoom levels as default introduced with library version 3.20.0. To get the old behavior set the new constrainResolution parameter to true like this:

new ol.interaction.PinchZoom({constrainResolution: true}).

The Problem is that I don't know where to put this in Drupal openlayers and I need to use Google Maps because their terms of service tell us that we have to use them if we use their geocoding service.

Dirkozoid’s picture

One more question:

Could it be that you missed a semicolon in "zoomtosource.js" on line 54?

animate_options.zoom = data.opt.zoom

Best

Dirk

m.stenta’s picture

See these release notes for other changes that will need to be made to be compatible with newer versions of the OL library:

https://github.com/openlayers/openlayers/releases/tag/v4.4.0
https://github.com/openlayers/openlayers/releases/tag/v4.5.0
https://github.com/openlayers/openlayers/releases/tag/v4.6.0

Joel MMCC’s picture

Also, OpenLayers 5 is a thing now, including 5.1 (up to 5.1.3 as I type this). It, too, seems to be relatively minor in terms of compatibility with previous versions, not the massive break-everything that OL3 was to OL2.

Big advantage in the newer versions and especially 5 is tha it’s now supposed to be much easier to load just the parts you need, rather than a massive monolithic library like in the OL2 and even OL3 days. This should solve the big advantage that Leaflet has over OpenLayers, especially since you have to add plugins to Leaflet to get even such basic functionality as full-screen zoom and marker clustering, let alone things like drawing polygons for data input into GeoFields. And, of course, with plugins, there’s always the spectre of version incompatibilities: what if some new mandatory security release of Leaflet breaks your older release of Leaflet-fullscreen?

monnerat’s picture

  • ken-g committed 020c751 on 7.x-3.x
    Issue #2911611: Update to use latest version of Openlayers JS (4.3.3)
    

  • ken-g committed 0eedfdc on 7.x-3.x
    Issue #2911611: Update to use latest version of Openlayers JS (4.3.3)
    
ken-g’s picture

Status: Needs work » Needs review

At the time of writing this comment (April 2022) the latest version of the Openlayers library is v6.14.1.

I have trawled through the Openlayers change log from v3.11.2 through to v6.14.1 and identified the following changes or deprecations that could affect our Drupal module (there may be more):

  • v3.20.0 - view.animate() instead of map.beforeRender() and ol.animation functions
  • v3.20.0 - ol.Map#forEachFeatureAtPixel and ol.Map#hasFeatureAtPixel parameters have changed
  • v4.0.0 - Simplified ol.View#fit() API
  • v4.3.0 - forEachFeatureAtPixel replaced
  • v4.5.0 - Deprecation of ol.Attribution
  • v6.0.0 - Deprecation of ol.inherits
  • v6.0.0 - New prerender and postrender layer events replace old precompose, render and postcompose events

I have now made the necessary changes to cater for all of the above, and committed these changes to 7.x-3.x-dev.

It should now be possible to use any version of the Openlayers library from 3.11.2 onwards all the way up to v6.14.1 against the 7.x-3.x-dev version.

Changing status to "Needs review".

ken-g’s picture

Component: Code » OL API
monnerat’s picture

Commits above fix the problem. Thanks.
Please note it may also obsolete issue 2678204

ken-g’s picture

Status: Needs review » Fixed

Fixed in 7.x-3.2 release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.