4

I want to display multiple lines between two coordinates. I will pass number of lines and color of the line, it has to display like below image.

please see the below image.this is my previous post enter image description here

2
  • 1
    Did you want Geodesic lines?
    – CaptDragon
    Mar 14, 2012 at 19:18
  • 1
    You mean you will pass two coordinates and color of the line? Intead of "i will pass no of lines and color of the line"?
    – CaptDragon
    Mar 14, 2012 at 19:52

1 Answer 1

10

This demo takes in two coordinates and a color and will create a Geodesic line between them.

DEMO LINK

enter image description here

You can add lines by entering information into the form, OR programmatically like so:

//Taj Mahal to Venice (San Marco)
AddLineProgrammatically(new OpenLayers.LonLat(78.0447, 27.17461), new OpenLayers.LonLat(12.34014, 45.43338), "#006633");
//Roman Coliseum to Mecca
AddLineProgrammatically(new OpenLayers.LonLat(12.49249, 41.89014), new OpenLayers.LonLat(39.8261238221, 21.4225222672), "#feadc8");
// Mecca to Statue of Liberty
AddLineProgrammatically(new OpenLayers.LonLat(39.8261238221, 21.4225222672), new OpenLayers.LonLat(-74.04457, 40.68927), "#3366cc");

This demo is based off of Mr. Wippermann great circle example.

Update per comment:

Simply comment out this line: vectorLayer.addFeatures([pointFeature, pointFeature2]); in the AddLine and AddLineProgrammatically functions if you don't want the markers.

enter image description here

7
  • Did I answer your question?
    – CaptDragon
    Mar 28, 2012 at 15:55
  • A small modification, now i dont want to display markers, will add markers through the markers layer. So i need only lines from this vector layer. Can u help me? Apr 6, 2012 at 13:42
  • simply comment out this line: vectorLayer.addFeatures([pointFeature, pointFeature2]); in the AddLine and AddLineProgrammatically functions.
    – CaptDragon
    Apr 6, 2012 at 14:38
  • hi one more small modification, i want remove all lines on an event. how to do that... Apr 10, 2012 at 17:52
  • That looks like a new question to me - perhaps you should post it as one. I'll be glad to answer it then.
    – CaptDragon
    Apr 10, 2012 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.