Skip to content

Instantly share code, notes, and snippets.

@eloycoto
Created June 6, 2013 20:05
Show Gist options
  • Save eloycoto/5724493 to your computer and use it in GitHub Desktop.
Save eloycoto/5724493 to your computer and use it in GitHub Desktop.
var lineLayer = new OpenLayers.Layer.Vector("Line Layer");
map.addLayer(lineLayer);
map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path));
var points = new Array(
new OpenLayers.Geometry.Point(lon1, lat1),
new OpenLayers.Geometry.Point(lon2, lat2)
);
var line = new OpenLayers.Geometry.LineString(points);
var style = {
strokeColor: '#0000ff',
strokeOpacity: 0.5,
strokeWidth: 5
};
var lineFeature = new OpenLayers.Feature.Vector(line, null, style);
lineLayer.addFeatures([lineFeature]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment