Commit 0eedfdcd authored by Ken Greenslade's avatar Ken Greenslade
Browse files

Issue #2911611: Update to use latest version of Openlayers JS (4.3.3)

parent 020c7513
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -37,12 +37,21 @@ function openlayers_default_openlayers_components() {
  $ol_component->factory_service = 'openlayers.Component:InlineJS';
  $ol_component->options = array(
    'javascript' => 'data.map.on(\'click\', function(evt){
      if (ol.hasOwnProperty(\'animation\')) {
        //  Deprecated in v3.20.0 - map.beforeRender() and ol.animation functions
        var pan = ol.animation.pan({
          duration: 2000,
          source: (data.map.getView().getCenter())
        });
        data.map.beforeRender(pan);
        data.map.getView().setCenter(evt.coordinate);
      } else {
        //  Introduced in v3.20.0 - view.animate() instead of map.beforeRender() and ol.animation functions
        data.map.getView().animate({
          center: evt.coordinate,
          duration: 2000
        });
      }
    });',
  );
  $export['openlayers_component_map_edit_form_setcenter'] = $ol_component;
+9 −1
Original line number Diff line number Diff line
@@ -29,7 +29,15 @@ ol.control.OL3CesiumControl = function(opt_options, map) {
    this.options = options;
    this.button = button;
};

if (ol.hasOwnProperty('inherits')) {
  //  Deprecated in v6.0.0 - ol.inherits function.
  ol.inherits(ol.control.OL3CesiumControl, ol.control.Control);
} else {
  //  Introduced in v6.0.0 - replace with ECMAScript classes.
  ol.control.OL3CesiumControl.prototype = Object.create(ol.control.Control.prototype);
  ol.control.OL3CesiumControl.prototype.constructor = ol.control.OL3CesiumControl;
}

/**
 * @param {event} event Browser event.
+9 −1
Original line number Diff line number Diff line
@@ -239,7 +239,15 @@ ol.control.Geofield = function(opt_options) {
    target: options.target
  });
};

if (ol.hasOwnProperty('inherits')) {
  //  Deprecated in v6.0.0 - ol.inherits function.
  ol.inherits(ol.control.Geofield, ol.control.Control);
} else {
  //  Introduced in v6.0.0 - replace with ECMAScript classes.
  ol.control.Geofield.prototype = Object.create(ol.control.Control.prototype);
  ol.control.Geofield.prototype.constructor = ol.control.Geofield;
}

ol.control.Geofield.prototype.handleDrawClick_ = function(event) {
  var options = this.options;
+23 −13
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ Drupal.openlayers.pluginManager.register({
      jQuery('#' + data.opt.headingID).val(geolocation.getHeading() + ' [rad]');
      jQuery('#' + data.opt.speedID).val(geolocation.getSpeed() + ' [m/s]');

      if (ol.hasOwnProperty('animation')) {
        //  Deprecated in v3.20.0 - map.beforeRender() and ol.animation functions
        var pan = ol.animation.pan({
          duration: 2000,
          source: map.getView().getCenter()
@@ -32,6 +34,14 @@ Drupal.openlayers.pluginManager.register({
        map.beforeRender(pan, zoom);
        map.getView().setCenter(geolocation.getPosition());
        map.getView().setZoom(7);
      } else {
        //  Introduced in v3.20.0 - view.animate() instead of map.beforeRender() and ol.animation functions
        //  TODO - need to complete this section
        map.getView().animate({
          zoom: zoom,
          duration: data.opt.animations.zoom
        });
      }
    });

    geolocation.on('error', function(error) {
+10 −5
Original line number Diff line number Diff line
@@ -98,11 +98,16 @@ Drupal.openlayers.pluginManager.register({
        'Hold on a second, while I catch those butterflies for you ...';

      window.setTimeout(function() {
        var features = [];
        map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
          features.push(features);
          return false;
        if ('getFeaturesAtPixel' in map) {
          //  Introduced in v4.3.0 - new map.getFeaturesAtPixel() method.
          var features = map.getFeaturesAtPixel(evt.pixel);
        } else {
          //  Replaced in v4.3.0 - forEachFeatureAtPixel() method replaced.
          features = [];        
          map.forEachFeatureAtPixel(evt.pixel, function(feature) {
            features.push(feature);
          });
        }

        if (features.length === 1) {
          info.innerHTML = 'Got one butterfly';
Loading