The 6 port is now in a working state apart from Views 2.x support. In particular, we need to allow KML to be used as a style for Views 2.x.

CommentFileSizeAuthor
#16 kml_default_views.patch6.83 KBrsoden
#11 kml.tgz7.58 KBrsoden

Comments

jeanpierre’s picture

Hello,
I would love to have the Views 2.x support, if someone tells me where I can find information about porting a plugin from Views 1.x to Views 2.x, I can help !
Thanks in advance.
--
Jean-Pierre

jcamfield’s picture

I'm interested in Views 2 functionality as well!

jcamfield’s picture

Until this is updated; has anyone found a workaround to export a filtered (by content type?) list of locations as KML?

jcamfield’s picture

Answering my own questions, XML to KML (http://drupal.org/project/xmltokml) can take a feed or XML view (views_datasource, from http://drupal.org/node/307223#comment-1040887 until the main code is updated (the July 2008 release is broken with the Views2) and output it as KML (to download, could probably work as a network link/feed with permissions set correctly, I haven't gotten back to that yet)

geodaniel’s picture

I'm hoping to get back to this soon, sorry for the delay. The plan is to rewrite much of kml module to make it a views style plugin instead of re-implementing that functionality, so then we should be able to let it work with other modules too. The module should be much leaner when finished.

milos1234’s picture

dont mean to rush, but is there a new version soon?
cheers

geodaniel’s picture

I'm going to try and devote some time to kick-starting this next week.

milos1234’s picture

cool thanks! cant wait

raintonr’s picture

+1 for this... will have a crack at a patch this weekend (erm... I hope).

raintonr’s picture

Tricky.

Hmmm... I looked at views2 for 3-4 hours last night. Got somewhere (see http://groups.drupal.org/node/23890) but no-where near enough. This morning decided this was going to take a long time to do properly so hard-coded a custom module solution for my D6 site.

Here's the .module file for those that are interested, it's a quick and dirty fix until views integration is working. Note the hook_load as part of named menu argument that checks the content type and only implements this menu for those node types. On our site 'node/%ride_story/tracks' is a standard view showing related nodes in a tab and works just fine. One could use node_load inside there but I believe the menu system calls that load function for each request to a matching path and didn't want to do a full load for those when checking the content type was all that was required.


/* Temporary module until views integration is done */

function track_kml_menu() {
  $items['node/%ride_story/tracks/kml'] = array(
    'title' => 'KML',
    'type' => MENU_CALLBACK,
    'page callback' => '_track_kml_generate',
    'page arguments' => array(1),
    'access callback' => TRUE,
  );

  return $items;
}

function _track_kml_generate($nid) {
  /* Just load a list of nodes and pass to KML module's functions */

  $sql = "SELECT n.nid, n.changed FROM {content_field_ride_database_entry} c, {node} n WHERE c.field_ride_database_entry_nid = %d AND n.nid = c.nid AND n.type = 'track' and n.status = 1 order by n.title";
  $result = db_query($sql, $nid);
  $nodes = array();
  $max_changed = 0;
  while ($node = db_fetch_object($result)) {
    $nodes[] = $node;
    $hash_list[] = $node->nid;
    if ($node->changed > $max_changed) {
      $max_changed = $node->changed;
    }
  }
  $attributes['title'] = 'Tracks';
  $attributes['description'] = "Tracks for $nid";
  sort($hash_list);
  $cache_name = 'kml:tracks';
  $cid = $cache_name .':'. md5(join('+', $hash_list));
  _kml_feed_check_cache($nodes, $attributes, $cid, $max_changed);

}

rsoden’s picture

Status: Active » Needs review
StatusFileSize
new7.58 KB

The attached module provides barebones views integration for KML. It handles lat/lon point data from CCK fields provided by Location CCK or simple text/numeric fields.

Could be extended to work with lines/polygons, allow themable style output, generate linestrings from a list of rows within the view, and in a number of other directions but I wanted to post the simple version first to get feedback.

looplog’s picture

+ 1 for views 2 ...

geodaniel’s picture

Robert, thanks for posting that, and sorry for the delay in trying it out and giving feedback. Putting this in as a 2.x branch sounds like the best idea as it's quite a departure (and definitely a welcome one) from the original version.

Trying it out, it worked well, and I think it's ready for an initial dev release on a 2.x branch, though I did notice a couple of things I'd like to add to it to bring it back to the capabilities of the original, like:

  • default views to give out-of-the box behaviour - though I'm not sure how easy that will be considering we're now supporting locations from any source (no reliance on location module any more)
  • network links to give self-updating feeds for each view
  • individual node links to let users download a kml feed for a node (this would probably tie into a default view with an argument)
  • link back to item as part of the default theming of the kml item
  • structured address data with mapping from arbitrary fields (as per your current setup) to address fields
  • icon styling

Robert, Robin, and anyone else interested in this issue, what are your thoughts on these points?

geodaniel’s picture

I've committed this initial version to HEAD, slightly modified to include $Id$ tags.

rsoden’s picture

Hi Dan,

Thanks for the review. Most of this stuff seems reasonable. I'd also add that I need to make sure grouping works (my guess is it doesn't at the moment but it's a quick fix).

In terms of default views - should we do something at admin/settings/kml that lets people pick their primary sources of geographic data and then run the defaults through hook_views_defaults_alter? This seems feasible with a limited amount of trickery.

What are the needs around icon styling? Lots of options here, how would we like this to work?

Will post patches for these requests when I can.

Cheers,
Robert

rsoden’s picture

StatusFileSize
new6.83 KB

The attached patch implements the default views via the approach discussed above. At admin/settings/kml you can choose fields as data sources for geo information as well as choose the relevant content types. The default view lives at /kml.

Frankly I think this is a lot of code for not that much win....

rsoden’s picture

Hit submit too fast.

Meant to end with I'd rather see this not committed, but am posting to give you a sense of what a default KML view feature would entail.

kubajs’s picture

+ 1 for views 2 ...

geodaniel’s picture

I was taking another look at this yesterday and I agree with you Robert, adding that default view is probably overkill as it's likely to just be overridden by users anyway. As long as we explain to users how to set up their first KML feed(s), I think we should be good.

I think we may still want a settings page to let users choose their location source (e.g. lat/long fields, location module or geo module) so we can use it for non-views powered parts, like adding a link to the node to view a KML file of its location.

tmcw’s picture

Is this getting committed? The patch has been in the queue for a long time now.

tmcw’s picture

Is this still active? The OpenLayers project is thinking about dynamic point loading, and a KML/Views situation would be the only way to accomplish that.

jeffschuler’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Fixed

KML 6.x-2.x-dev includes Views support.

Status: Fixed » Closed (fixed)

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