Hi,
I have recently produced the trackfield.module (http://drupal.org/project/trackfield). As part of this have managed to utilise the 'kml item' hook to place paths in KML output. There is a problem with how things currently work though:
Whatever data you return is added inside the existing <Placemark> element. For example, the trackfield module can return (co-ord list mostly removed for space):
Array
(
[Linestring] => Array
(
[key] => LineString
[value] => <coordinates>151.234721,-33.768547,0 151.23741,-33.763535,0</coordinates>
)
)
Which makes KML output for this <Placemark>:
<Placemark>
<name>...snip...</name>
<description>...snip...</description>
<styleUrl>#NodeStyleMap</styleUrl>
<TimeStamp><when>2008-03-14T10:01:13Z</when></TimeStamp>
<Point>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>151.236505,-33.765448,0</coordinates>
</Point>
<LineString><coordinates>151.234721,-33.768547,0 151.23741,-33.763535,0</coordinates></LineString>
</Placemark>
This confuses Google Earth and it seems to be able to treat a <Placemark> as a point or a line, but not both. Luckily for us the <LineString> seems to take precedent over <Point> and the track is displayed, but that's not what is really required. To show both is needed so the line has a label hovering above it.
What seems to be needed is a way to have the hook be able to return something that creates another <Placemark> element inside the KML output, something like:
<Placemark>
<name>...snip...</name>
<description>...snip...</description>
<styleUrl>#NodeStyleMap</styleUrl>
<TimeStamp><when>2008-03-14T10:01:13Z</when></TimeStamp>
<Point>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>151.236505,-33.765448,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>...snip...</name>
<description>...snip...</description>
<styleUrl>#NodeStyleMap</styleUrl>
<TimeStamp><when>2008-03-14T10:01:13Z</when></TimeStamp>
<LineString><coordinates>151.234721,-33.768547,0 151.23741,-33.763535,0</coordinates></LineString>
</Placemark>
How do you think this would be best achieved?
Maybe if the key in the returned array is <Placemark> then the value could be added as such after the existing one?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | kml.module.235986.patch | 2 KB | raintonr |
Comments
Comment #1
raintonr commentedPlaying more with this I have discovered the
MultiGeometrytag as discussed here:http://code.google.com/apis/kml/documentation/kmlreference.html#multigeo...
It would seem that this is probably the way to go. One can use this tag to overcome the 'confusion' I first mention and allow both
PointandLineStringelements to be handled properly inside the same placemark.I would propose a small patch to the KML module that looked through the args array in
kml_format_placemarkfunction and any elements that were themself geometry tags would be placed with the default placemark inside aMultiGeometrytag.This should be easy enough to do and will work on it shortly.
Comment #2
raintonr commentedAs per #1 please find patch attached.
This handles all geometry types and the MultiGeometry tag itself inside the
$extrareturned from$extra = node_invoke_nodeapi($item, 'kml item');.For efficient styling it might be nice to add a prior hook call for other modules to add their style information. This can be embedded at the moment but is on a per-node basis rather than using style IDs.
Comment #3
raintonr commentedNow committed to cvs:
http://drupal.org/cvs?commit=130675
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.