Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Apologies in advance if I have overlooked the documentation where this is clear.
I'd like to create a line on my map reflecting a series of points in time order. I can do the dots themselves just fine, but it's not clear how to get that set of points rendered as the vertices of a polyline.
Am I required to create a little mini-module to do so? I am willing, but it seems tantalizingly like there should be a less code-intensive way.
Thanks in advance. This is a remarkable module. Good stuff.
Comments
Comment #1
tmcw CreditAttribution: tmcw commentedHow are you drawing the dots? If you're using the OpenLayers CCK module's input to do it, then you should be able to enable line input and draw lines. Otherwise, if you're doing geotaxonomy or lat/lon input, there isn't a clear-cut way to do this, unfortunately, although a behavior would likely be possible that connects the dots.
Comment #2
Cayenne CreditAttribution: Cayenne commentedAh, I see.
Yes, I was just using the simple lat/lon method from the tutorial.
And I see that the WKT input method is just that, so I'll need to mess with the behavior, I guess, since I want to connect the dots between various datapoints, up to a given time.
This is for yacht race tracking.
Comment #3
davideads CreditAttribution: davideads commentedJust a note: OpenLayers supports line segments. It does NOT support encoded polylines (see http://openlayers.org/pipermail/dev/2009-February/004393.html).
Comment #4
Cayenne CreditAttribution: Cayenne commentedWow. that seems really surprising. I don't think it's consistent with what else I have read and seen demonstrated with Openlayers, and seems like a bad thing to leave out. I will continue to investigate...
Comment #5
tmcw CreditAttribution: tmcw commentedI'm assuming that Mr. Schmidt's opposition to polylines is based on the facts that
Comment #6
seanberto CreditAttribution: seanberto commentedIf I understand the thread correctly, this is something that Loubabe (Lev Tsypin) and I are going to be working on. We are planning on using the Node Queue module to allow a site visitor to create an ordered list of flagged nodes that they want to visit as part of a walking tour. We hope to use a view of these flagged nodes (sorted by the node queue order) as the sort for displaying a polyline on an OpenLayers map. We'll be exploring this more in the next few weeks.
Comment #7
Cayenne CreditAttribution: Cayenne commentedThat's grreat!
Working with unDrupalled OpenLayers, I have made a nice little page that displays a random polyline across the Pacific Ocean, which is what I want.
If it is at all possible for you to make your project slightly more generic, so that the output of a View, or even just calls to a table, can feed the polyline, that'd be really slick.
Pseudo code
SELECT name, lat, lon, date, comment FROM positions
GROUP BY name
ORDER BY date
Or something like that. But as long as we are agnostic about how the ordered view of nodes got created (and I want to include 70 paths in one map) I am happy.
Comment #8
davideads CreditAttribution: davideads commented@Cayenne and @Seanberto -- dunno if you got my contact emails, but "connecting the dots" is rather easy. As of today, I also have code written to make a curvy line.
Comment #9
Cayenne CreditAttribution: Cayenne commentedI did not get your contact email. Also, it appears that openlayers.org itself is DOWN today and has been intermittent the last couple. I wish I had DL'd the js.
EDIT: Site back up, but still. a little troubling....
Comment #10
tmcw CreditAttribution: tmcw commentedCayenne: the OSGEO server has been going up and down recently, as I've heard on #openlayers (on irc.freenode.org). I think it was just dev.openlayers.org, but, who knows. This is a separate project.
Comment #11
mattcasey CreditAttribution: mattcasey commentedIf you guys have any scripts to share, can I get in?
I am currently trying to do this - my client is traveling across country and will update his position for each blog post. I want to draw a line following his path, plus one special 'temporary' line segment projecting the next location (which may be an unpublished node, or have some special field checked?)
Great module - Thanks!
Comment #12
tmcw CreditAttribution: tmcw commentedEr, it strikes me as odd to do this on the PHP level and reaching back even to the database level - why not just output points to the map and use a custom behavior to re-write them as a line segment? That'd be much less gnarly and much more reusable.
Comment #13
davideads CreditAttribution: davideads commentedReaching back to the database level makes no sense, but using PHP to generate the line segments has its place.
I don't think doing it in PHP is necessarily less reusable if the PHP is written sanely, and it keeps the CPU cycles required to create the segments on the server (where the layer can also be cached, so that you can compute once and use many times). It seems to me it really comes down to where you have the cycles to spare. On my project, doing it server side is a no-brainer -- it is dramatically faster without caching, and we have a very powerful server infrastructure to drive the site.
Comment #14
davideads CreditAttribution: davideads commentedAlso, my last comment applies to complex features (like curved lines). For drawing a straight line segment between points on the map which require no attributes or other fancy processing, a behavior is definitely the way to go.
Comment #15
tmcw CreditAttribution: tmcw commentedHuh? Bezier-curved lines are usually generated in OpenLayers, just using Geometry.Curve, rather than on the server side, which would make the data transfer larger. Anyway, if you've got a working solution, go for it.
Comment #16
zzolo CreditAttribution: zzolo commentedClosing as this seems to be resolved, and just a discussion on implementation details. Feel free to continue the discussion if needed.
Comment #17
davideads CreditAttribution: davideads commentedWow, I sure got sidetracked by work and travel from this one -- here's a comment on my implementation and why I'm trying to do it this way. Maybe I'm off base...
I'm not using Geometry.Curve because I would a) need to calculate the intermediary points to draw the curve through in Javascript, which seems like needless computation by the client and b) Geometry.Curve isn't a cubic bezier curve. Given how little layer data (on my project, building curve-y lines server side adds 5-10k to the size of the layer data transferred. In an environment where most users will have direct fiber connections to their desktops, I don't think that's exactly a deal breaker).
Because of this, and because of the advantages of a cubic bezier in terms of control over the curve itself, to my mind it still makes sense to generate the curved features server side. I can make control points dependent on metadata associated with map points (i.e. network delay between two physical locations compared to a baseline measurement) and easily change curvature, etc by varying the angle and location of the control points.
See http://trac.openlayers.org/ticket/619 and http://trac.openlayers.org/ticket/1715
Comment #18
leo82 CreditAttribution: leo82 commentedHi seanberto,
any help on how do you achieve that?
Comment #19
leo82 CreditAttribution: leo82 commentedComment #20
ken-g CreditAttribution: ken-g as a volunteer and commented