So, this is basically two big things:

  • OpenLayers Data views should generate GeoJSON instead of the arbitrary format they currently do
  • OpenLayers Data views should support feed output in order to dynamically load points as GeoJSON layers (which also need to be added

I've currently implemented the latter and it works quite well, although in a very limited use-case. This change could really assist dynamic point loading and rendering of points via Mapnik etc. Obviously there are big questions of access control and filtering, which can't be addressed 100% when the consumer of the GeoJSON isn't always a drupal-session user, but at the very least these changes are backwards-compatible with javascript-on-a-page.

CommentFileSizeAuthor
#1 889190_openlayers_geojson.patch16.52 KBtmcw
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tmcw’s picture

Initial patch introducing a feeds plugin that's configured the same way as OpenLayers Data but outputs GeoJSON.

zzolo’s picture

This seems like a great direction.

My only concern with the patch is that it looks like it creates a lot of duplicate code. Maybe there is someway to reduce this.

tmcw’s picture

Yeah; this will eventually just output GeoJSON on both sides, and also make the grouped-nongrouped logic less of a beesnest. The major challenge is converting the full range of WKT into GeoJSON.

jantoine’s picture

This is something I am interested in. I am currently testing with 6.x-2.x-dev. I applied the patch in #1 and was able to create a feed. I think I am supposed to be able to turn this into a layer, but I'm not quite sure how to do that. The OpenLayers Data used a display that automatically created the layer. I didn't see a new OpenLayers GeoJSON display in views or in the patch. I went to create a new OpenLayers_Views layer manually but I ran into the following error when I tried doing that:

Fatal error: Call to undefined method stdClass::save() in /var/www/drupal6/drupal/sites/all/modules/openlayers/modules/openlayers_ui/includes/openlayers_ui.layers.inc on line 59

I also tried attaching the feed to different displays via the views "Attach to" link, but received the following error when visiting the path associated with the attached display:

Fatal error: Call to undefined method openlayers_views_style_geojson::attach_to() in /var/www/drupal6/drupal/sites/all/modules/views/plugins/views_plugin_display_feed.inc on line 195

Thanks for all the work you guys are doing with OpenLayers, it's fantastic.

Cheers,

Antoine

tmcw’s picture

This patch currently does not implement the other side of the equation, making the output part of an openlayers map. It simply outputs GeoJSON. There's also no geojson layer implementation currently, although it would be simple to write. And, yes, there should be a warning on the creation page for OpenLayers_Views layers telling you that manual creation isn't possible. The only current way to connect views output to map input is via the normal layer process, creating an OpenLayers Data view and adding it to the map.

wwhurley’s picture

One thing I noticed is the GeoJSON view style outputs the point coordinates as latitude,longitude when the GeoJSON spec (http://geojson.org/geojson-spec.html#coordinate-reference-system-objects) calls for longitude,latitude.

jeffschuler’s picture

I used @tmcw's patch here to make a module for D7 that exports GeoJSON... because I needed it and didn't want to hack OL.

It's in my sandbox, currently: Views GeoJSON. Not sure if it merits a "real" project on d.o.? (Maybe it should become a sub-module of Views Datasource...) Grateful for feedback/assistance.

I don't have a great handle on the architecture of the OL module yet, but I wonder whether it should include responsibility for generation of input data at all, rather than just consuming it...?

zzolo’s picture

Hi @ jeffschuler. Cool work.

It looks like you are just kind of copying this modules Views style Implementation, so in that regard, it might make sense to put in here. But then we would need some sort of layer type to handle, which I don't think we currently fully support.

But, Views Datasource is a pretty good place for it as well, and actually makes a bit more sense as there are probably other places that could use it.

Happy to support either direction.

jeffschuler’s picture

Thanks zzolo.

Yeah, I pulled code wholesale from tmcw's patch in #1 which, it looks like, follows this module's existing data overlay views style.

I'll probably pursue the views_datasource angle, as it seems this deserves to live outside OL -- so that it can be used independently, and to keep OL focused -- but I don't yet have a very complete picture of present-and-future geospatial in Drupal, and would gladly defer.

tema’s picture

Component: OpenLayers Views » OL API

Ugh! Subscribing.

zzolo’s picture

I would love to see this in a separate module (and views_datasource is a great candidate). Every mapping module could utilize this. As far as the current state of geospatial-ness in Drupal, you can look at the Location and mapping group (http://groups.drupal.org/mapping), but its hard to say what the state is. Overall, the more general a solution can be, the better. OpenLayers should focus on visualization and not data storage or even generating feeds.

jeffschuler’s picture

Cool. Thanks for the support of this route, zzolo.

I'll work on releasing and maintaining Views GeoJSON as a standalone module... and eventually move into views_datasource if appropriate.

jeffschuler’s picture

I've revamped the module to follow Views Datasource's model, and submitted a project application: Views GeoJSON

Grateful for reviews.

jeffschuler’s picture

Views GeoJSON is full-fledged module.

zzolo, I'm glad for input/direction on how it could become more useful as data producer for OpenLayers.

zzolo’s picture

Hi @jeffschuler. Yeah, I just noticed that you had released this the other day. Very awesome! Time is pretty limited for me, but I would love to get something in the OL module for this (maybe just in parallel with current Views integration for now).

Dave-B’s picture

Subscribing

nod_’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
jeffschuler’s picture

Is it fair to close this issue, as work is now proceeding at #1370448: Provide GeoJSON Layers from Views (integrating with views_geojson)?

zzolo’s picture

Status: Active » Closed (duplicate)

Yep, moving over to that issue.