I just went through the tutorial on a clean D7 install, and the result was an empty map with the following Drupal error message:

Notice: Undefined index: wkt in openlayers_views_style_data->reduce_features() (line 314 of /sites/all/modules/openlayers/modules/openlayers_views/views/openlayers_views_style_data.inc).

I understand that the tutorial doesn't exactly apply to D7, but since there is no other D7 documentation it's all I have to go on. Any tips would be appreciated.

CommentFileSizeAuthor
#29 openlayers_1006652.0.patch4.39 KBjherencia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colemanw’s picture

Version: 7.x-2.x-dev » 7.x-2.0-alpha0

By the way, I was using lat and long fields, not WKT, basically just following along the tutorial. So the missing WKT error message may not be related to my empty map.
I did apply a content type filter to the views, as was suggested by some comments on the tutorial, but the map remains empty.

dasjo’s picture

Version: 7.x-2.0-alpha0 » 7.x-2.x-dev

receiving the same error with drupal 7 dev versions + separate lat long fields

dasjo’s picture

just tried to use openlayers with geofield (https://github.com/developmentseed/geofield).

Notice: Undefined index: lon in geofield_handler_field_point->render() (line 18 of ../modules/geofield/views/geofield_handler_field_point.inc).
Notice: Undefined index: lat in geofield_handler_field_point->render() (line 18 of ../modules/geofield/views/geofield_handler_field_point.inc).

not sure if we want to split this up into separate issues, but so far i couldn't get the current openlayers dev version for drupal 7 to work. neither numeric fields nor geofield worked for me so far.

dasjo’s picture

with a little adaptation, openlayers + geofield works for me now
https://github.com/dasjo/geofield/commit/39173ceb6c2445cc135715deed9716a...

aristeides’s picture

Confirming that patch #4 works

aristeides’s picture

actually, patch on comment #4 corrects the errors on comment #3 but not the ones on comment #1

dasjo’s picture

Version: 7.x-2.0-alpha0 » 7.x-2.x-dev

true, #3 - #4 actually describe a workarround, but don't tackle the original problem #1

zzolo’s picture

This notice is caused because we are calling something like array['wkt'] when that value is not there. This is probably caused because a node or something doesn't have the value you are looking for. It could be an actual problem like a typo. Are you actually seeing a problem on the map, like things not showing up?

You probably want to make sure that these types of errors doesn't show to regular users.

dasjo’s picture

in my case, things didn't show up following #1, the map was empty and i received the error for each item that the map view was trying to display

aristeides’s picture

Same for me.... empty map with errors.

colemanw’s picture

Same here. Well, glad to hear it's not just me.

aristeides’s picture

The D6 version of OpenLayers had a module called "openlayers CCK" which is deprecated.
The way this module was storing the data on the database looks like this:

GEOMETRYCOLLECTION(POINT(23.716647 37.97918))
23.716647 is the latitude
37.97918 is the longitude

the main difference here is that the geofield module saves data in the database in a whole different way,
field_location_lat contains the latitude and
field_location_lon contains the longitude.

I guess a way around this problem for the time being would be to create a custom text field in views and just use some PHP to format these values to match GEOMETRYCOLLECTION(POINT(latitude longitude))...

aristeides’s picture

or simply use the "rewrite the output of this field" to bypass the defaults of this field.
By the way... if you change the style of the view from openlayers to unformatted you'll probably realize that the output of the geofield field is null, so actually this is not a bug of openlayers but geofield (which unfortunately is not on drupal.org but on github).

colemanw’s picture

@aristeides: Thanks for the info. I actually wasn't using geofield, I was just using a couple of number fields created by fields api (formerly CCK). Is what you said relevant to that, and if so do I need to reformat them in views to output as a single field that looks like GEOMETRYCOLLECTION(POINT(23.716647 37.97918))?

tmcw’s picture

Is what you said relevant to that, and if so do I need to reformat them in views to output as a single field that looks like GEOMETRYCOLLECTION(POINT(23.716647 37.97918)

This isn't on the user level, it's what openlayers_views exists to do. And regarding this problem, I've tested (and deployed) OpenLayers and GeoField, but not thoroughly tested bare numeric fields. I'll give it a look to see that everything's functional there... the architecture of Drupal's field system and the views system has changed dramatically and made it even harder to support mapping applications.

aristeides’s picture

@tmcw I just wanted to say a big thank you for contributing so much on this module...

colemanw’s picture

ditto to #16

pvhee’s picture

Subscribing.

What is currently recommended to start Openlayers in D7?

I have a hard time finding out what modules to use to store my geo data, is this going to be geofield (https://github.com/developmentseed/geofield, not on d.o) or geo (http://drupal.org/project/geo) (no D7 version).

I'd be willing to help out with porting/updating modules but I can't find much information about it so far.

tmcw’s picture

pvhee: Currently GeoField is the only thing that I'm sure works with OpenLayers D7. It should also work with plain lat/lon, but I haven't tested this recently (just a faint memory that I implemented it).

As with OpenLayers D6, Geo integration is not a target within this module, and given the scale of the Geo module, updating it would be difficult.

Updating OpenLayers CCK to a similar module (like "OpenLayers Field") which uses the D7 field API would be extremely helpful, since the need still exists for a map-drawing UI. Looking at GeoField would be a good idea for this porting challenge: in particular, the D7 field API makes the task of getting unrendered values extraordinarily difficult.

zirvap’s picture

It should also work with plain lat/lon, but I haven't tested this recently (just a faint memory that I implemented it).

I tested with plain lat/long fields (float numbers) in D7 a few days ago, using the latest -dev of OpenLayers and Views, and got the same errors as described in the original issue.

tmcw’s picture

Ah, yes, it looks like this is broken. I'll try to work on this, but the reality is that I'm no longer working on Drupal day-to-day. For the time being, it's better to stick with Drupal 6 given the state of this module and the (lack of) performance and stability in 7.

aristeides’s picture

On my view I tested this:
OpenLayers Data Overlay display ->Change settings for style ->Set Map Data Sources to "WKT"

This makes the errors disappear, but still no data is displayed on the map.

Then I went on my location field and chose to rewrite the output of the field.
For testing purposes I tried entering GEOMETRYCOLLECTION(POINT(23.716647 37.97918))

Now the map displays data just like it should. Of course not the correct data, but still it's a step forward.
All I need to do now is write a query to reformat the output of geofield to the above....
It would be really cool if someone could write a patch though for geofield!
If geofield was storing the data in the database in a WKT format, we could really say we have a working solution!

aristeides’s picture

Correction on #22: We don't need to change the way data is stored on the database, it works fine just the way it is. BUT what we should do is alter the way that geofield returns data in views. To be more exact, it simply doesn't return any data!
So I think that with a little fiddling around with this file https://github.com/developmentseed/geofield/blob/master/views/geofield_h... we could do it.

wietze’s picture

Subscribe!

Starting a site with lot of geographic data. I want to start it right and make it in D7, instead of making it in D6 and porting it after a year.

I also tried making a layer with seperate lon and lat fields. Same error and empty map. Looking for a future proof way to store my location/waypoint data.

grtz Wietze

tmcw’s picture

I want to start it right and make it in D7, instead of making it in D6 and porting it after a year.

If you have a serious amount of data and need performance, it will be exceedingly difficult to build in D7, OpenLayers D7 or not.

wietze’s picture

@tmcw: tnx for your reply.

I was under the assumption that D7 had better performance than D6. Am I wrong in this?

grtz Wietze

tmcw’s picture

Yes: there are isolated cases in which Drupal 7 is more performant (loading, for instance, one node), but many cases (any views query) in which it is dramatically slower than Drupal 6.

aristeides’s picture

I just updated ctools to the latest dev version, removed the patch on #4 and received this error:
Notice: Undefined index: und in geofield_handler_field_point->render() (line 14 of /sites/all/modules/geofield/views/geofield_handler_field_point.inc).

After re-applying the patch, received this:
Notice: Undefined index: object in geofield_handler_field_point->render() (line 13 of /sites/all/modules/geofield/views/geofield_handler_field_point.inc).
Warning: Invalid argument supplied for foreach() in geofield_handler_field_point->render() (line 15 of /sites/all/modules/geofield/views/geofield_handler_field_point.inc).

Confused....

jherencia’s picture

Status: Active » Needs review
FileSize
4.39 KB

Please someone review.

Now it is possible to map:

  • WKT Data from geofields and textfields.
  • Lat/Lon point from numberfields (including float fields) and texfields.
zzolo’s picture

Hey, what is the point of this issue? The title says something different than what is in #29. I am all about these goals, but want to be clear. Also, there is similar patch here: http://drupal.org/node/1048178 So, it would be nice to have collaboration there.

I'll try to test this out soon. Thanks for the work.

jherencia’s picture

The problem is that Field's field_alias value has changed in Views (specifically in branch #3). field_alias is used in opelanyers_views_data output as a unique id of the field we want to map longitude/latitude/wkt from. In D7 Field API field_alias stores the primary key of the entity a field is attached to, so it will have the same value in two different fields of an entity (e.g. a node), exactly what happens with OpenLayers.

The patch I attached uses the handler id as the unique id of a field, so this problem is solved.

Another issue is that the unrendered value (the one the user typed) of a field is loaded differently depending on the field type, the unrendered value is needed because rendered value in textfield/floatfield could be in HTML format (and in most cases they are).

In geofield this is not a problem because render method returns the raw value. But we have to handle each type of field differently. In numberfields or textfield is the same: $entity->$field[$language][0]['value'].

zzolo’s picture

Title: Notice: Undefined index: wkt » Address rendering changes in Views 3 and D7

Hi @jherencia. Thanks for the complete explanation; it really helps. I am changing the title to what I think is best represented in what is trying to be accomplished in this issue. I'll try to take a look at the patch soon.

cnolle’s picture

Patch in #29 works for me, my map is now working with points and without the notice.

cnolle’s picture

Patch in #29 works for me, my map is now working with points and without the notice.

tmcw’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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