Saturday 28 January 2017

javascript - How to draw Geodesic lines in Openlayers 2?


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



Answer



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.



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...