[OpenLayers-Users] Drawing lines in custom map.
miguel
juanabreu at hotmail.com
Tue Oct 9 13:40:18 PDT 2012
Thanks for replying mike, I will give this a try. Can I ask why are these
line stricken?
var lineFeature = new OpenLayers.Feature.Vector(line, null, style);
lineLayer.addFeatures([li
neFeature]);
did you mean to do that?
Miguel
From: Mike Ryan [mailto:m.ryan6000 at gmail.com]
Sent: Tuesday, October 09, 2012 4:09 PM
To: openlayers-users at lists.osgeo.org; juanabreu at hotmail.com
Subject: Re: [OpenLayers-Users] KML icons point
That example doesn't give you the nuts and bolts of programmatically
creating the line.
This does:
http://stackoverflow.com/questions/2735944/drawing-a-path-with-a-line-in-ope
nlayers-using-javascript
var lineLayer = new OpenLayers.Layer.Vector("Line Layer");
map.addLayer(lineLayer);
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([li
neFeature]);
And it wouldn't hurt to have the API at your fingertips for LineString:
http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLay
ers/Geometry/LineString-js.html
On 10/9/2012 3:48 PM, miguel wrote:
Hi
Forgive me with the noob question I have successfully using my own custom
map tiles for doing diagram. The problem I have now encountered is how do I
draw the lines programmatically. I found this example page
http://openlayers.org/dev/examples/draw-feature.html but looking at the
source code does not reveal much to me. Does anyone have have an example
using x and y coordinates or long lattitute on how to draw lines on a map. I
would greatly appreciated.
Miguel
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121009/b1b278e2/attachment-0001.html>
More information about the Users
mailing list