The Geofield component seems to be a bit broken in the 7.x-3.x branch. I have the Openlayers Examples module enabled, and when I click on the "Geofield Map" that comes with Openlayers, I am unable to draw. Changing the options below the map (ie: selecting Polygon) does not seem to have any affect. My mouse is a pointer on the map... not a drawing point like it should be.

Looking at the debug info, the only unusual thing I see is an "Assertion failed":

********************* Starting building openlayers_geofield_map_geofield *********************
openlayers.debug.js?nmjp0r:12 Building map...
openlayers.debug.js?nmjp0r:20 Building sources...
openlayers.debug.js?nmjp0r:38 Building interactions...
openlayers.debug.js?nmjp0r:56 Building layers...
openlayers.debug.js?nmjp0r:65 Building components...
openlayers.debug.js?nmjp0r:74 Loading components openlayers_geofield_component_geofield...
openlayers.debug.js?nmjp0r:75 Object data
openlayers.debug.js?nmjp0r:76 Objectfs: "openlayers.component.internal.geofield"mn: "openlayers_geofield_component_geofield"opt: Object__proto__: Object
openlayers.console.js?nmjp0r:27 Assertion failed
openlayers.console.js?nmjp0r:27 AssertionError: Assertion failed
    at new goog.asserts.AssertionError (http://local.apiosinstitute.org:8080/sites/all/libraries/openlayers3/build/ol-debug.js?nmjp0r:4267:20)
    at Object.goog.asserts.doAssertFailure_ (http://local.apiosinstitute.org:8080/sites/all/libraries/openlayers3/build/ol-debug.js?nmjp0r:4324:11)
    at Object.goog.asserts.assert [as assert] (http://local.apiosinstitute.org:8080/sites/all/libraries/openlayers3/build/ol-debug.js?nmjp0r:4354:18)
    at Function.ol.interaction.Draw.getMode_ (http://local.apiosinstitute.org:8080/sites/all/libraries/openlayers3/build/ol-debug.js?nmjp0r:105204:16)
    at new ol.interaction.Draw (http://local.apiosinstitute.org:8080/sites/all/libraries/openlayers3/build/ol-debug.js?nmjp0r:104720:36)
    at addDrawInteraction (http://local.apiosinstitute.org:8080/sites/all/modules/contrib/openlayers/m…rs_geofield/src/Openlayers/Component/Geofield/js/geofield.js?nmjp0r:150:26)
    at Object.Drupal.openlayers.pluginManager.register.init (http://local.apiosinstitute.org:8080/sites/all/modules/contrib/openlayers/m…ers_geofield/src/Openlayers/Component/Geofield/js/geofield.js?nmjp0r:180:5)
    at Object.Drupal.openlayers.pluginManager.createInstance (http://local.apiosinstitute.org:8080/sites/all/modules/contrib/openlayers/js/openlayers.pluginManager.js?nmjp0r:52:43)
    at Object.Drupal.openlayers.getObject (http://local.apiosinstitute.org:8080/sites/all/modules/contrib/openlayers/js/openlayers.js?nmjp0r:191:50)
    at http://local.apiosinstitute.org:8080/sites/all/modules/contrib/openlayers/js/openlayers.js?nmjp0r:92:31

Comments

Pol’s picture

Status: Active » Fixed

Use the openlayers geofield submodule provided with openlayers. No need of other module.

m.stenta’s picture

Status: Fixed » Active

I'm not sure I understand. I have Geofield and Openlayers Geofield enabled. What other module do you mean?

I am looking at the default map that is provided by the openlayers_geofield module: openlayers_geofield_map_geofield

If I "Preview" that map, I cannot draw on it.

m.stenta’s picture

Hmm, new clue! I removed the openlayers v3.4 library, and replaced with v3.1, and it causes a difference...

With 3.1, my cursor is a point when I hover over the map, which it wasn't before. So that's good!

But as soon as I click, the point disappears and I have a pointer again, and nothing works again until page refresh.

This suggests that something in the openlayers library itself has changed and caused this...

What versions are you running currently? 7.x-3.x and v3.4?

m.stenta’s picture

Bah. Forget that... it's not true, the openlayers library version doesn't matter.

The effect I described can also be achieved with v3.4. It happens when debug mode is off.

m.stenta’s picture

Ok, I discovered that this is related to the fact that I am using the Bootstrap theme. I am continuing to debug what exactly is happening. Will update soon...

m.stenta’s picture

Status: Active » Closed (works as designed)

Ok yep: this is a bug with Bootstrap, not with Openlayers. Sorry for the false alarm.

Basically, Bootstrap is overwriting the ID attribute of the fieldset that wraps the geofield. This is causing line 5 of geofield.js component to fail:

var geofieldWrapper = jQuery('#geofield-' + jQuery(data.map.getViewport()).parent().attr('id'));

... which ultimately breaks a bunch of things.

I am going to create a new issue in the Bootstrap project queue. Closing this one.

m.stenta’s picture