d3.carto.layer drawing routes

42 views
Skip to first unread message

Jim Noss

unread,
Aug 30, 2016, 4:08:20 PM8/30/16
to d3-js
For the d3-carto-map library, I am currently plotting points using latitude and longitude. How can I connect two latitude/longitude point with a straight line?

Do I have to make a new layer using the D3 'LineString' type with the coordinate endpoints?


Mike Bostock

unread,
Aug 30, 2016, 4:27:54 PM8/30/16
to d3...@googlegroups.com
You should make a GeoJSON LineString feature, yes, assuming that you desire to draw the shortest path between two points on the surface of the sphere, which is a geodesic (and not a straight line).

Jim Noss

unread,
Aug 30, 2016, 6:55:38 PM8/30/16
to d3-js
Thanks. would you know how to do this with d3.carto.map?
Not sure if I make a new d3.carto.layer or a feature using 'LineString' with my two lat/long coordinates that are added to a new d3.carto.layer layer.  

Elijah Meeks

unread,
Aug 31, 2016, 4:45:37 PM8/31/16
to d3-js
You would need to add it as a new layer. There are examples of adding new layers from derived features in the wiki. Unfortunately, I don't have the time to support d3.carto anymore, so you might consider looking into a more established web mapping library.

Jim Noss

unread,
Aug 31, 2016, 6:46:35 PM8/31/16
to d3...@googlegroups.com
Your d3.carto library is perfect for my needs. Got the lat/Lon points plotted and will create a new layer for the LineString between the coordinates and add to the map.  Thanks
--
You received this message because you are subscribed to a topic in the Google Groups "d3-js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/d3-js/AUpenXSXS3o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to d3-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Jim


Key West Life

unread,
Oct 24, 2016, 8:50:58 AM10/24/16
to d3...@googlegroups.com
Looking at Mike's LineString example http://bl.ocks.org/mbostock/5851933 do you have a similar code snippet on how to do the same with the d3.carto library? 
Which layer should I use and does it support the LineString coordinates like in Mike's example?  sorry. a little lost on how to implement the new layer for the LineString coordinates in d3.carto.

--
You received this message because you are subscribed to a topic in the Google Groups "d3-js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/d3-js/AUpenXSXS3o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to d3-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jim

Reply all
Reply to author
Forward
0 new messages