[OpenLayers-Users] LineGrid Layer?
Nathan Gerber
ngerber999 at gmail.com
Mon Nov 12 12:26:53 PST 2012
We figured it out. We created a clone of PointGrid and modified it for
lines.
var lines = [];
// Longitudinal Lines
var startX = gridLeft;
var endX = gridLeft + (cols - 1)*this.dx;
for (var j=0; j<rows; ++j) {
var y = gridBottom + (j * this.dy);
var pointList = [];
var point1 = new OpenLayers.Geometry.Point(startX, y);
var point2 = new OpenLayers.Geometry.Point(endX, y);
if (this.rotation) {
point1.rotate(this.rotation, rotationOrigin);
point2.rotate(this.rotation, rotationOrigin);
}
pointList.push(point1);
pointList.push(point2);
var geom = new OpenLayers.Geometry.LineString(pointList);
lines.push(new OpenLayers.Feature.Vector(geom));
}
// Latititudinal Lines
var startY = gridBottom;
var endY = gridBottom + (rows - 1)*this.dy;
for (var i=0; i<cols; ++i) {
var x = gridLeft + (i * this.dx);
var pointList = [];
var point1 = new OpenLayers.Geometry.Point(x, startY);
var point2 = new OpenLayers.Geometry.Point(x, endY);
if (this.rotation) {
point1.rotate(this.rotation, rotationOrigin);
point2.rotate(this.rotation, rotationOrigin);
}
pointList.push(point1);
pointList.push(point2);
var geom = new OpenLayers.Geometry.LineString(pointList);
lines.push(new OpenLayers.Feature.Vector(geom));
}
this.destroyFeatures(this.features, {silent: true});
this.addFeatures(lines, {silent: true});
--
Nathan Gerber
On Mon, Nov 12, 2012 at 8:35 AM, Nathan Gerber <ngerber999 at gmail.com> wrote:
> Is there a way to get line grids to appear that would function like the
> PointGrid layer? Graticule is close, but does not meet my needs due to it
> being locked to the coordinate system. I need to be able to draw grids
> based upon user selected sizes and angles and PointGrid seems to do the job
> for me except that it only renders points rather than lines.
> --
> Nathan Gerber
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121112/86507665/attachment.html>
More information about the Users
mailing list