I'm planning on / attempting to use OpenLayers for a project I'm working on. The 2.x version seems rather powerful and seems like it has a lot of potential to be a flexible, useful, open, and free mapping solution for Drupal. However, the architecture of the module itself and the integration with Views seem fairly problematic, from where I stand.

Let's start with the Views integration: Currently, you have to create Views with OpenLayers data displays. The user then creates a preset, and the OpenLayers module discovers and makes available all the possible data displays so that they can be added to the "preset" as layers. Then you create a view that uses the OpenLayers map display style, and select the proper preset in the display style's settings.

To my addled brain, this behavior and methodology is highly non-obvious.

First, calling such an entity (map settings, base layer(s), and Drupal-provided data layers) a preset is misleading. I expected a preset to correspond to a set of default settings on top of which I might wish to layer my own data. I suspect others may have a similar reaction when they see the word “preset”.

Second, having to leave the Views UI, creating a preset, and then wiring it up with the data layer you created, and then going back to Views is cumbersome and most definitely violates the principle of least surprise: The neophyte developer or user is NOT likely to expect this behavior.

Third, this behavior also seems very counter-intuitive and technically limiting from a Views standpoint. For example, given the current structure, how one possibly expose filters for the data layers, or sanely handle arguments? With the current structure, the data layers and final display need not even live in the same View. While that may have some advantages, I don't think it should be the default behavior.

The alternative method would be that the user creates OpenLayers data layer attachments that can then be attached to an OpenLayers map display in the same view. The data layers could inherit the parent display's arguments (optionally, just like regular attachment), configure some of their own styles and behaviors, and provide exposed filters to the parent map. I asked a random sample of a couple of Drupal developers and asked how they might expect such a module to work, and everyone had some variation of this same idea.

I've written a Views integration module of my own (attached) which is hacky but serves as a decent proof of concept: The “data layers as attachments” model for Views integration is eminently do-able. It also reveals how deeply embedded the notion of "presets" is within the 2.x version of the OpenLayers module.

While writing the module and wrestling with the OpenLayers module's functions, it became clear how much the module currently hinges on the idea of presets as the primary container of layer data. Why should the rendering function go through a build process that goes out and fetches the data? Shouldn't the rendering function just take data directly and render it instead of doing a stealth lookup?

It seems to me like the idea of the preset could be whittled down: A “preset” or “basemap present” could contain most of the settings currently provided by the current preset system, but without any of the additional data layering stuff: These presets would define the basic behaviors of the map itself, but leave the other data layers elsewhere.

I understand, based on reading the issue queue, that map portability is a major goal of the 2.x branch. As far as I can tell, my approach shouldn't significantly affect portability of maps insofar as Views provides native import/export functionality.

If the current functionality of “presets” is still desired, the module could introduce an additional concept of a “map” which could work very similarly to how the data layer selection process for presets works now. These “maps” themselves could be made exportable. The user interface would be far cleaner (select a preset, select a couple of layers provided by Views OpenLayers data displays or from non-Views sources), and such a system could potentially allow for maps that are
more sophisticated than those provided by Views.

I know this module is already in alpha, but the current architecture choices seem likely to cause pain and trouble in the future – users are going to be frustrated, and the Views integration will have a hard time taking advantage of Views' featureset and API.

CommentFileSizeAuthor
ol_views.tgz26.85 KBdavideads
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tmcw’s picture

Hey David,

It's good to hear that another person's thinking about the module architecture on a complete level. I agree that there are some difficult choices here, and there's certainly a lot of work to be done before this module is generally consumable. I'll try to respond to this ticket - not that your observations are in any invalid, but a lot of the architecture choices have a bunch of thinking behind them which is non-obvious.

Let's start with the Views integration: Currently, you have to create Views with OpenLayers data displays. The user then creates a preset, and the OpenLayers module discovers and makes available all the possible data displays so that they can be added to the "preset" as layers. Then you create a view that uses the OpenLayers map display style, and select the proper preset in the display style's settings.

To my addled brain, this behavior and methodology is highly non-obvious.

Yes: this behavior is not obvious. It's the kind of thing that people do need to read the documentation for in order to understand. What we've made recently are baby steps - alpha7 gives a helpful note to people trying to create Openlayers Data layers via the OpenLayers interface, for example, but it's far from point and click.

First, calling such an entity (map settings, base layer(s), and Drupal-provided data layers) a preset is misleading. I expected a preset to correspond to a set of default settings on top of which I might wish to layer my own data. I suspect others may have a similar reaction when they see the word “preset”.

Yes - I would like to see the term 'preset' changed to 'map' in future versions. Since this isn't a bug, it's been prioritized behind bugs, but it needs to be done eventually. It was also reliant on a bit of the architecture that has been late in arrival - self-powered maps, without views.

Third, this behavior also seems very counter-intuitive and technically limiting from a Views standpoint. For example, given the current structure, how one possibly expose filters for the data layers, or sanely handle arguments?

Currently arguments are passed down from the OpenLayers Map view to the OpenLayers Data views - this can, and has, enabled users to do, say, a view in a block that shows the current node. There is a ticket for supporting exposed filters: #789668: Support exposed filters from OpenLayers Data displays, but the implementation of that feature is tricky so it hasn't been written yet.

With the current structure, the data layers and final display need not even live in the same View. While that may have some advantages, I don't think it should be the default behavior.

This has rather huge advantages, actually. Pushing data views into their own area is big, because with Views modes, one can present an OpenLayers Data view as a map, and then one of its attachments as a table - or allow KML or WFS download of the displayed map. It also has the benefit that OpenLayers Data Views can have different base tables - a map can display layers from nodes, taxonomy, data, and whatever else, without a hitch.

The alternative method would be that the user creates OpenLayers data layer attachments that can then be attached to an OpenLayers map display in the same view. The data layers could inherit the parent display's arguments (optionally, just like regular attachment), configure some of their own styles and behaviors, and provide exposed filters to the parent map. I asked a random sample of a couple of Drupal developers and asked how they might expect such a module to work, and everyone had some variation of this same idea.

I'm not sure how this differs from the current behavior: one can easily create an OpenLayers Map view with OpenLayers Data views as attachments. Is the difference that OpenLayers Views acquire their own styles and behaviors? It seems like there would also be very large blind spots to this system - in that a data layer can't be shared between maps, for instance.

While writing the module and wrestling with the OpenLayers module's functions, it became clear how much the module currently hinges on the idea of presets as the primary container of layer data. Why should the rendering function go through a build process that goes out and fetches the data? Shouldn't the rendering function just take data directly and render it instead of doing a stealth lookup?

Could you clarify this? The institution of layer types and the render() method is simple encapsulation, and personally it doesn't seem like a major stumbling block. Rendering functions shouldn't 'take data directly' when the taking of data directly can be cleanly encapsulated, it seems.

I know this module is already in alpha, but the current architecture choices seem likely to cause pain and trouble in the future – users are going to be frustrated, and the Views integration will have a hard time taking advantage of Views' featureset and API.

This module is in alpha because I, and a bunch of other module maintainers, feel like version numbers are a weak indication of status. Very mature modules like Feeds are in alpha - alpha15 to be specific. This isn't to say that OpenLayers 2.x is a very mature branch - it won't be that until many bugs are ironed out. But it's widely deployed - more deployed than the release candidate-quality 1.x version - and all compatibility-breaking changes are noted and avoided.

If the current functionality of “presets” is still desired, the module could introduce an additional concept of a “map” which could work very similarly to how the data layer selection process for presets works now. These “maps” themselves could be made exportable. The user interface would be far cleaner (select a preset, select a couple of layers provided by Views OpenLayers data displays or from non-Views sources), and such a system could potentially allow for maps that are
more sophisticated than those provided by Views.

You'll need to clarify how this could allow for more complex maps than are currently possible. I also think that one of the current faults of this module is that it provides two routes to map display - Views and CCK, of which the latter suffers because the developers (myself included) don't use or prefer CCK displays. Increasing, rather than decreasing, these routes, is not the direction of current development.

So, in conclusion:

I agree entirely that the current views-based setup is convoluted and nearly impossible to understand without reading the documentation: currently this module comes with the semi-requirement that users need to read documentation, which is very rare amongst Drupal modules (the rest just require you to write patches).

The solution to this problem which has been floating around for a while is to have self-sustaining maps. This means that presets are renamed maps, and they can present themselves on pages, blocks, etc., without requiring an extra view. This functionality will be made possible by CTools page management - which has recently become stable enough to be used.

It would also make a lot of sense to have a module that makes 'map making' easier by abstracting away the additional functionality to generate views based around common use cases.

However, the reasons behind the current complexity come into play often in real-world situations - there are use cases in which your module would make your life a lot easier, but there are others in which it would be impossible to do what this module does currently without a complete architectural rewrite. So, I'd rather the interface become simpler and the 'preset' dillema be clarified than to switch strategy at the level you're suggesting.

That said - I'm reading through this module and the workflow that it embraces is common. Currently a lot of the users who could be using this module are using Gmaps or something else instead because the learning curve is high. So I'm not trashing the idea of having an interface which supports this workflow better and doesn't require cracking open documentation to get started, but I'm suggesting that there are ways to support this workflow better and keep the flexibility of the current OpenLayers module that does actually come into play in real life. So, absolutely - I'll see if there are parts of this module which could be guides to the future UX of the OpenLayers module, and if you wish to write patches that clarify the muddy parts of the infrastructure, that that would be great - or even if you want to form a new module that hits another user segment and has some kind of compatibility with OpenLayers proper, then that would also be appreciated.

But, in this form, I think that it would help if we discussed the reasons behind the current architecture because the reasoning isn't immediately obvious but is incredibly needed in real situations.

zzolo’s picture

@davideads, thanks for the thoughts. Like @tmcw says, outside opinions are always encouraged, as it can be difficult to remove oneself from their own project enough to have a objective perspective. Some initial comments:

* Presets should definitely be called Maps. Started new issue: #806318: Rename Presets to Maps

* The current workflow is very hard for most people to grasp, even after reading the documentation. Pretty much everyone I have tried to explain how it works to has been lost until I actually demo it for them. Even using attachments, a lot of people that are basic Drupal users and site builders will probably have a hard time. The Views interface and parts are complicated no matter what.

Having an attachment approach seems like a good idea. The ability to keep things in one interface is important. As @tmcw suggest, this could be possible right now. I have not looked at the attached code yet, but there could be some good UI directions there.

I personally think focusing on utilizing another display mechanism that can be managed in the map/preset interface is pretty crucial. Unfortunately it is not necessarily best to write our own, and nothing provides a generic way to handle this outside a separate complicated interface (ctools page manager is only for pages, I believe, and its interface is just as confusing as Views). I think considering writing our own is worth that conversation; remembering that 90% of cases just want to display maps in a block or on a page, and that really isn't all that hard to do.

* As far as the API, I think it could be cleaned up, but the goal as it sort of stand is that we "build" the map data first, then "render" it. "Building" is taking a basic data structure and filling it in with all its parts. The "rendering" is taking that data and creating output from it. I think there are definite points of cleaning up for this, like naming things differently accouting for the difference between a map (which is a preset) and the data array, as well as providing a function for processing a preset name, and spearating out the data array and preset_name parts more, etc.

davideads’s picture

Hey TMCW, and Zzolo, thank you both for the thoughtful replies -- hopefully, this conversation is productive and useful for you two.

Allow me to restate what I'd like to propose in light of your comments, tell you about my own real-world use case, and then address my complaints about the rendering workflow (which directly stem from the way I envision my specific problem going).

I'd like to propose a two-method approach: where "map views" and "maps" are distinct methods for accomplishing similar goals. It is predicated on the assumption that for the foreseeable future, strong Views integration will be important to the utility of the module.

Rethink presets

Presets should be split, conceptually and architecturally, into "map defaults" and "maps", where "maps" are map defaults + data, and work exactly as presets do now -- they allow you to mix and match any data layers you want, from any source, into a single, unified map, and some day soon will power and sustain themselves.

I probably came off as too dismissive of the design choices in my initial post -- I absolutely understand the need for maps-aka-presets -- the Views base table limitation is huge (and infuriating, really) given the importance of mapping a variety of Drupal entities on the same map, and of course there's the question of how to provide wfs or kml via Views, and the Views UI is potentially more cumbersome than a streamlined UI built around presets (but which doesn't exist yet). I'm not arguing specifically with that design choice.

But, it might be worth considering further encapsulating the map concept by making it a separate module, similar to openlayers_ui. It is one way, perhaps the best way, but not the only way to exploit the OpenLayers module API. The map module could drive self-sustaining maps and do most everything presets do now.

Use data-layers-as-attachments in openlayers_views

The current openlayers_views module should allow the possibility of using the main-display + data attachments-as-layers method.

I'm going to assume that's the first thing users familiar with Drupal and Views are going to try to do, no matter how much you try to get them to read the documentation.

If the extent of the user's mapping needs really is plotting some nodes with a location field of some sort, the Views approach seems good enough to me (on two projects now in the last few months I've thrown up my hands at Drupal mapping tools, because I just needed a simple map and embedding some evil code was easier than trying to figure out what to use and how to use it). And I'm pretty sure it could make exposing filters significantly easier.

And if OpenLayers supported this usage, it could at least alert the user to the existence and basic implications of the two approaches in help text, advanced help, etc. You could nudge the user with text like "Use the Views module if you mainly need to plot nodes, want to expose filters, and don't loathe Views, use the Map module to create sophisticated, stand-alone maps" throughout the UI.

OpenLayers data displays wouldn't suddenly become inaccessible to presets/maps -- if the map module and the views module are enabled, the map module should continue to detect and provide those data displays to maps.

I hope my module shows that there could be an architectural shift. -- detangling the concept of a "map" from the concept of a "map -built-with-views") where many common cases can be solved via a fairly straightforward use of the Views UI and/or API, without significantly changing any of the design choices you've made. I think it could be helpful in accomplishing some of your stated goals. I understand the aversion to CCK displays, but they are widely used and improvements there can only benefit a lot of the users out there. Using the CTools page manager to drive self-sustaining/self-powered maps is intriguing, and could be pretty awesome. But architecturally, it seems to me like it would be best if the map module provides self sustaining maps and the Views integration module provides views-based maps as completely distinct techniques.

This proposal runs the risk of Perl-syndrome -- "there's more than one way to do it" is often a curse. But in this case, I think a very robust OpenLayers 2.x will mean wider adoption as well as less user and developer frustration, even if it leads to some people doing crazy things with the api and/or ui in the short term.

Why do I think this way?

For my project, we need to plot nodes in a network of national labs, and allow the user to click on point A, click on point B, and get back a report on the "health" of that network segment. The current plan is to query a web service for performance data, then use the returned data to tell the user what's going on ("your throughput just dropped 25% over the past hour... would you like to create a support ticket?"). While the map is a central UI element, it is mostly being used to drive queries to the web service -- the same basic effect could be achieved with a pair of drop-down menus for source and destination.

The way I think I'd like to query it is to create a Views 3.x query plugin (I got a lot of my inspiration for this from Views 3 + Apache Solr + Acquia Drupal = The Future of Search and working with the Solr module). Let the web service handle the data, let Drupal render it, mediated by Views acting as a configuration and rendering API.

Perhaps this strategy is too complicated. My hope is that it lets the poor soul who has to maintain the site easily reorder fields, change the formatter used, alter sorts, etc. It will provide users and administrators with a consistent (if deranged) UI for interacting with the backend query service. Using field formatters to render the data seems like an ideal use case for them. Views makes me crazy and I sort of hate it for the lack of documentation, weird UI, and frustrating limitations, but the wide adoption and mature(-ish/-ing) ecosystem make it hard to avoid.

What I thought would be nifty, and highly useful, would be to return OpenLayers data objects from the query backend to plop on the map. We have lat/lon data for each service that reports back network information, as well as a meta data cache that will associate any node in the network with its parent lab (not surprisingly, we know lat/lons for these, too -- shapes, even!) . So generating wkt for our map should be easy, and there are currently only 23 dots we need to put on the map. It would be nice, down the road, to provide some dynamic filtering and automatic updating to create a "network weather map" (check out http://weathermap.es.net/ -- a goal here is to re-create that map, but to make it far more simple and meaningful, at the expense of functionality).

This line of thinking prompted my initial post. It is why I was a little disappointed when I walked up to OL and was initially disoriented. I also must admit I didn't hit the docs until after I'd looked at the Views code for the map rendering ('return openlayers_render($preset->data);'), looked at the data member and didn't see any *data* as I expected it, and was all, like, "whoa, this isn't very transparent, what's going on?!"

Gritty details and other thoughts

As far as rendering goes -- I hope my comments are more clear in light of my use case. I understand the need for encapsulation, big time, but from a 3rd party development standpoint, the way it currently works is sort of chafing -- I'd just like to build my own map object, pass it to the OpenLayers render function, and see a pretty map come back -- without requiring I create a preset first, or making me know much of anything about the internals of OpenLayers except what data structure is expected of me.

The way it currently works -- pushing map building into rendering, and then layer, behavior, and style processing into building, with data retrieval happening in the {FIND OUT} step -- just seems convoluted. I know this verges on the philosophical, but doing data retrieval during building (inside of rendering!) kind of violates what many might consider to be "rendering".

My main suggestion for rendering is to allow the map object passed to the render function to directly contain data, behaviors, styles, etc, not just pointers to stuff that will be filled in later. I understand this is a design goal, but if other 3rd party developers are like me and expect similar behavior out of their render functions, the current implementation is going to be frustrating and surprising.

That said - I'm reading through this module and the workflow that it embraces is common. Currently a lot of the users who could be using this module are using Gmaps or something else instead because the learning curve is high. So I'm not trashing the idea of having an interface which supports this workflow better and doesn't require cracking open documentation to get started, but I'm suggesting that there are ways to support this workflow better and keep the flexibility of the current OpenLayers module that does actually come into play in real life. So, absolutely - I'll see if there are parts of this module which could be guides to the future UX of the OpenLayers module, and if you wish to write patches that clarify the muddy parts of the infrastructure, that that would be great - or even if you want to form a new module that hits another user segment and has some kind of compatibility with OpenLayers proper, then that would also be appreciated.

What I'm really suggesting is that by shifting the architecture a little, and decoupling a couple of the pieces, you will wind up supporting more real world use cases and significantly decrease the always alienating RTFM-factor. It will allow those of us who wish to build Views-based tools to drive OpenLayers to stay out of the way of self-sustaining maps in terms of on-going development, and vice-versa.

It seems prudent to me to use both approaches, despite the risks of too much choice, and I think it would be beneficial to everybody -- developers and end users -- if the Views technique and the preset/map technique were not as tightly coupled, and the merits and drawbacks of each approach explained in the module help strings and documentation.

tmcw’s picture

I'm somewhat convinced by the concept of a 'automap' type functionality in which attached OpenLayers Data views are automatically added to a map - and I think that this could be somewhat accomplished by simply adding an option to the OpenLayers Map style plugin. But, of course, it becomes worse and worse when you think it through and realize that this conflicts with need for style and behavior configuration, and the duplication of interface required for that to work.

Anyway, I kind of feel like, despite that being a great idea and very implementable, the concern that's causing much of your dissatisfaction with the module is not strongly connected to the changes that you're suggesting on the UI level. It seems like there are two things - an architectural change, which I must say I don't support, and a UI change, which seems more reasonable.

This line of thinking prompted my initial post. It is why I was a little disappointed when I walked up to OL and was initially disoriented. I also must admit I didn't hit the docs until after I'd looked at the Views code for the map rendering ('return openlayers_render($preset->data);'), looked at the data member and didn't see any *data* as I expected it, and was all, like, "whoa, this isn't very transparent, what's going on?!"

Render is a poorly defined word. And the preset data doesn't mean the map content, much like how a View definition does not mean the View content. However, you really need to give another shot at understanding why data is not involved at this stage.

Layer types are encapsulation of data. Creating a new layer type allows you to have one map that pulls data from a Oracle database and another map that pulls data from who knows what, and to have the custom code for pulling the different kinds of data entirely encapsulated - so that one doesn't interfere with the other, and the map doesn't need to know the exact methods of pulling. Yes - it is more straightforward to simply allow people to hack around this limitation and shove data into the map array at any point in processing. And, don't tell anyone, but it's abundantly simple to hack it that way - it's simply a whole lot worse architecturally because layers are no longer objects that can be pulled into different maps, moved to different websites, exported in code, but now live as little code hacks in random places. Yes: there is boilerplate code to write in order to implement a layer type. Perhaps it needs better documentation but the difference in difficulty between pushing data into a map object and pulling that data using a layer type is not monumental and is overshadowed by the hackishness of the former and the sustainability of the latter.

Relative to how well the module handles your use case: I was involved in a recent project that involved a Views 3 query plugin with Sphinx backend. It was quite straightforward, and didn't require any patches to OpenLayers.

The way it currently works -- pushing map building into rendering, and then layer, behavior, and style processing into building, with data retrieval happening in the {FIND OUT} step -- just seems convoluted.

As far as layer, behavior, and style processing - in the current 2.x branch, all three have been boiled down to taking the stored data, calling the defined 'render()' method on layers, and pushing it to JSON. There is no smoke and mirrors here.

Data retrieval happens in the render() method of a layer type. It's the only place it happens in PHP, ever, and it's really quite obvious how it happens if you simply read the openlayers views layer type. Yes - you'll need to read code or documentation, but if you're going to write code, I think that's a reasonable assumption.

My main suggestion for rendering is to allow the map object passed to the render function to directly contain data, behaviors, styles, etc, not just pointers to stuff that will be filled in later. I understand this is a design goal, but if other 3rd party developers are like me and expect similar behavior out of their render functions, the current implementation is going to be frustrating and surprising.

This can be accomplished by using a 'generic vector layer' - see #734702: Make Vector layer generic for details. This may be exactly what you're looking for - a way to push arbitrary data into the map object from any source.

What I'm really suggesting is that by shifting the architecture a little, and decoupling a couple of the pieces, you will wind up supporting more real world use cases and significantly decrease the always alienating RTFM-factor.

It really seems that pulling data and pushing it into the map object directly is infinitely more coupled than to have the map be agnostic to data source particulars. That said, having a more obvious method of pushing data to the map would reduce the RTFM factor for moderate hacking.

It seems prudent to me to use both approaches, despite the risks of too much choice, and I think it would be beneficial to everybody -- developers and end users -- if the Views technique and the preset/map technique were not as tightly coupled, and the merits and drawbacks of each approach explained in the module help strings and documentation.

My main concerns with having both techniques in the module are that a great amount of code would be duplicated and that it would lead to an increase in code and a decrease in stability when the module is aimed, primarily, at at stability at this point in time.

davideads’s picture

Aw man, my stupid desktop at work ate a rather long reply. Here goes... again... This may be somewhat out of order in terms of quoting.

I'm somewhat convinced by the concept of a 'automap' type functionality in which attached OpenLayers Data views are automatically added to a map - and I think that this could be somewhat accomplished by simply adding an option to the OpenLayers Map style plugin. But, of course, it becomes worse and worse when you think it through and realize that this conflicts with need for style and behavior configuration, and the duplication of interface required for that to work.

I agree and fully understand that it does requiring a duplication of interface, but I don't see how it conflicts with the need for style and behavior configuration. Couldn't some subset of the style and behavior configuration be supported by the View integration module? And beyond duplication of effort to some degree, how does that make things worse and worse or conflict with the goals of the module?

A Views-attachment style approach doesn't need to change the anything about way maps/presets handle style or behavior configuration, it would simply allow simple-minded use cases to use simple-minded techniques if that's all those cases require.

This can be accomplished by using a 'generic vector layer' - see #734702: Make Vector layer generic for details. This may be exactly what you're looking for - a way to push arbitrary data into the map object from any source.

This, if well supported, would effectively end my complaints and would allow me to write my own OpenLayers views integration that plays nice with the module's core API. I'd definitely be happy to contribute patches to see that one resolved.

My main concerns with having both techniques in the module are that a great amount of code would be duplicated and that it would lead to an increase in code and a decrease in stability when the module is aimed, primarily, at at stability at this point in time.

I can't imagine that a "great amount" of code would actually wind up being duplicated, but there definitely would be an increased burden of maintenance and documentation for a system which allows both techniques.

Also, how would supporting both techniques compromise stability of the core? Nothing I'm suggesting changes the fundamental behavior of the preset concept in any way, nor does it entail extensive changes to the OpenLayers codebase. And, having developers building on top of the OpenLayers API seems like it should have the effect of make the core functionality more stable.

I understand that maybe I was a little too willing to throw the baby out with the bathwater in my initial post. But all I'm really suggesting is an architectural shift whereby the Views integration module supports the attachment model, and the core API's rendering workflow supports generic vector layers. I personally think it would make a great deal of sense to provide a wafer thin core API module for working with the OpenLayers library and displaying a map, and then layering other techniques (your map concept, my views-as-maps concept) on the same core. On the API side, the module does that already.... almost.

I understand that "automaps" definitely entail a duplication of effort, but supporting common-case, Views-driven usage seems like it could dramatically increase adoption and encourage use of the module.

Relative to how well the module handles your use case: I was involved in a recent project that involved a Views 3 query plugin with Sphinx backend. It was quite straightforward, and didn't require any patches to OpenLayers.

I'd love to talk with you about this, outside of this thread, if you are willing.

tmcw’s picture

This, if well supported, would effectively end my complaints and would allow me to write my own OpenLayers views integration that plays nice with the module's core API. I'd definitely be happy to contribute patches to see that one resolved.

That's great - because I feel like that ticket is very close to completion. What's already implemented in CCK for vector layers and the Javascript of OpenLayers Views is pretty much what that ticket aims for, just with a standardized features structure and minimal configuration.

I can't imagine that a "great amount" of code would actually wind up being duplicated, but there definitely would be an increased burden of maintenance and documentation for a system which allows both techniques.

I would just see the interface for assigning behaviors and styles to presets being duplicated, and there's already a tricky dance of being able to assign X to Y for behaviors, styles, and layers, which falters with CCK and would also be a little tricky with this scenario. Not impossible, but it'll be different code for all three cases.

I personally think it would make a great deal of sense to provide a wafer thin core API module for working with the OpenLayers library and displaying a map, and then layering other techniques (your map concept, my views-as-maps concept) on the same core.

The core map rendering process could be a bit split up - I mean, if only openlayers_build_map wasn't called by openlayers_render_map then you'd be able to sneak in at the last minute with comparable data.

Also, how would supporting both techniques compromise stability of the core? Nothing I'm suggesting changes the fundamental behavior of the preset concept in any way, nor does it entail extensive changes to the OpenLayers codebase. And, having developers building on top of the OpenLayers API seems like it should have the effect of make the core functionality more stable.

A solid core is a great thing, and this may uncover some more bugs in it. My fear is that the core functionality of this module is not about putting a map on a page, which is relatively simple, and more about managing map components and assembling them. So, the 'core' that we'd be building off when creating a new structure based on different principles would actually be a fairly trivial bit of code, rather than the meat of the module.

davideads’s picture

That's great - because I feel like that ticket is very close to completion. What's already implemented in CCK for vector layers and the Javascript of OpenLayers Views is pretty much what that ticket aims for, just with a standardized features structure and minimal configuration.

Is there going to be a patch I can start testing? (:

I would just see the interface for assigning behaviors and styles to presets being duplicated, and there's already a tricky dance of being able to assign X to Y for behaviors, styles, and layers, which falters with CCK and would also be a little tricky with this scenario. Not impossible, but it'll be different code for all three cases.

I'm going to have to dig in the code further and look at how you assign X to Y. My initial thought was to enable/disable behaviors on the main map display, and set styles in the data layer attachment display. Is that sensible? Are there gotchas?

A solid core is a great thing, and this may uncover some more bugs in it. My fear is that the core functionality of this module is not about putting a map on a page, which is relatively simple, and more about managing map components and assembling them. So, the 'core' that we'd be building off when creating a new structure based on different principles would actually be a fairly trivial bit of code, rather than the meat of the module.

I understand that the core functionality of the module is not really about putting a map on a page and that the 'core' I'm speaking of is almost so lean as to wonder if there's any "there" there at all. But is that necessarily bad? My gut feeling is that even if the core is whisper thin, and only handles the very tip of the mapping iceberg (drawing a map and putting it in a page), creating a thin wrapper around the OpenLayers library in Drupal is good for the overall flexibility of the module, and allows people who know the underlying library to jump right in. This is very much a matter of personal philosophy, but I tend to expect a module which provides an integration with a 3rd party library to provide such a thin wrapper that exposes the basic functionality of the library, and then build off it to do fancier things.

tmcw’s picture

Okay - so here's the ticket for the generic vector layer: http://drupal.org/node/734702

Note that, although that's one way to do it, it's an inferior approach to writing a layer_type, which, for some reason, is cracked up to be difficult but truly is not.

My initial thought was to enable/disable behaviors on the main map display, and set styles in the data layer attachment display. Is that sensible? Are there gotchas?

There are a few gotchas - there are layer-specific behaviors and there are non-layer specific styles.

I understand that the core functionality of the module is not really about putting a map on a page and that the 'core' I'm speaking of is almost so lean as to wonder if there's any "there" there at all. But is that necessarily bad? My gut feeling is that even if the core is whisper thin, and only handles the very tip of the mapping iceberg (drawing a map and putting it in a page), creating a thin wrapper around the OpenLayers library in Drupal is good for the overall flexibility of the module, and allows people who know the underlying library to jump right in. This is very much a matter of personal philosophy, but I tend to expect a module which provides an integration with a 3rd party library to provide such a thin wrapper that exposes the basic functionality of the library, and then build off it to do fancier things.

Good points throughout. Yes - the core that puts a map on a page is whisper-thin, and I don't think that it should be any thicker. Duplicating the OpenLayers Javascript library - or adding a full 'translation layer' between it and PHP would be a crowd-pleaser but a thoroughly poor decision, because it would inextricably tie this module to the intricacies of the Javascript below it (and their variations and bugs), while also adding a larger Javascript translation layer - since, of course, this module will never try to write 'functional javascript' as a result of its labors.

Alas, in some places, this module basically follows what I can see somewhat as the Drupal philosophy - requests for 'maps from arrays' are kind of like requesting the Views module to work off of arbitrary arrays - it doesn't, and won't. Developers need to write query backends, display plugins, and style plugins to achieve their dreams, and the learning curve for doing so is balanced with the sustainability of the result.

davideads’s picture

Thanks, tmcw!

Good points throughout. Yes - the core that puts a map on a page is whisper-thin, and I don't think that it should be any thicker. Duplicating the OpenLayers Javascript library - or adding a full 'translation layer' between it and PHP would be a crowd-pleaser but a thoroughly poor decision, because it would inextricably tie this module to the intricacies of the Javascript below it (and their variations and bugs), while also adding a larger Javascript translation layer - since, of course, this module will never try to write 'functional javascript' as a result of its labors.

Right. If an end-developer wants to do that, they should just include the OpenLayers JS library and go to town.

Alas, in some places, this module basically follows what I can see somewhat as the Drupal philosophy - requests for 'maps from arrays' are kind of like requesting the Views module to work off of arbitrary arrays - it doesn't, and won't. Developers need to write query backends, display plugins, and style plugins to achieve their dreams, and the learning curve for doing so is balanced with the sustainability of the result.

Well, the module itself was just proof of concept, and is admittedly pretty crappy. The other issue I've run into is licensing: As far as I have been able to determine, all code I write on this project must be licensed (and only licensed) under the Fermi Tools license, a BSD-variant. I'm trying to get administrative approval to AT LEAST dual license this work, and preferably get clearance to submit code under the GPL directly to d.o projects. As soon as I get that clearance, I should be contributing more.

davideads’s picture

Still no clearance, but I've been working with OL extensively, and have to say, I'm still disappointed and frustrated by the architecture. For example -- dynamically creating a layer seems nigh impossible. Perhaps I'm just dense. I'll reply with more findings and notes, probably next week.

tmcw’s picture

You've seen that the generic layer type was committed: http://drupal.org/node/734702#comment-3030206 ? That hits the area of 'dynamically creating a layer', although really the ideal way to dynamically create a layer is to write either a layer type, a views backend, or both, so that it's not a one-off hack. Creating a layer type (as well a creating behaviors, etc.) really is not difficult.

And disappointment and frustration with the architecture is pretty commonplace. This is a module that got wonky in the 1.0 version, got a bit better in the 2.0 version, and is still attempting to solve problems that aren't solved elsewhere - complex problems in simple ways. If there are more specific concerns, post away.

davideads’s picture

I've been writing my own behaviors and styles, and writing a layer type seems easy, but I'm not sure that will solve my problem: Can a layer type dynamically create multiple layers in a single shot?

tmcw’s picture

Can you be more specific? As in, you have multiple layers on a map by clicking one? Or having layers from something? If you want layers to be provided dynamically, then implement hook_openlayers_layers like in openlayers_views.module. Actually providing layers is not in the domain of layer types.

davideads’s picture

This is the "naving layers from something" case. I'm still struggling with this, but getting closer. Some of my problems simply arose from mistakes I made in hook_openlayers_layers. I'm trying to create dynamic, arbitrary layers -- I want to build and push multiple layers into a map based on AJAX requests.

This is for a visual traceroute app. So the user queries to get all traceroutes from a given source and destination during a given time frame, and I'd like to dynamically generate a layer for each traceroute that is returned in response and create it as a layer on an OL map.

tmcw’s picture

If you're adding layers based on AJAX requests to a map, and you want to add them dynamically, then create KML or some other kind of remote point layers like GeoJSON, etc. to the map.

If the layers themselves, not just the data, need to be pulled from AJAX requests (for instance, if this traceroute all happens after a page is loaded, by some dynamic form submission), then use a behavior to create dynamic layers, since there's nowhere that the layer system would interact here.

davideads’s picture

If the layers themselves, not just the data, need to be pulled from AJAX requests (for instance, if this traceroute all happens after a page is loaded, by some dynamic form submission), then use a behavior to create dynamic layers, since there's nowhere that the layer system would interact here.

That's what I'm doing.

tmcw’s picture

Er, then that's not something that the module aims to address. Frustration with the OpenLayers Javascript library, perhaps? We've all got that (although, yes... it is the only thing that does (specifically) what it does).

davideads’s picture

It turned out I was mainly just being dense, as I suspected (:

tmcw’s picture

Status: Active » Closed (works as designed)

Closing - open tickets for specific actions and patches.