[OpenLayers-Users] polylines

Frederico Lucca fredlucca at gmail.com
Fri Feb 2 12:25:10 EST 2007


Evaldas,

This works for me.

On Canvas.js I have added:

    addPolyLine: function(points) {
        var ctx = this.canvas.getContext("2d");

        ctx.beginPath();

        var k = 0;
        for (k=0; k<points.length; k++)
        {
            var px = this.map.getPixelFromLonLat(points[k]);

            if (k==0)
            {
                ctx.moveTo(px.x, px.y);
            }
            else
            {
                ctx.lineTo(px.x, px.y);
            }
        }

        ctx.stroke();
    },

    drawPolyLine: function(points) {
        var ctx = this.canvas.getContext("2d");
        this.addPolyLine(points);
        this.lines.push(new Array(points, ctx.strokeStyle, ctx.lineWidth,
ctx.globalAlpha));
    },

And changed on redraw()

        for(var i=0; i < this.lines.length; i++) {
            if (this.lines[i].length==4)
            {
                this.setStrokeColor(this.lines[i][1]);
                this.setStrokeWidth(this.lines[i][2]);
                this.setAlpha(this.lines[i][3]);
                this.addPolyLine(this.lines[i][0]);
            }
            else
            {
                this.setStrokeColor(this.lines[i][2]);
                this.setStrokeWidth(this.lines[i][3]);
                this.setAlpha(this.lines[i][4]);
                this.addLine(this.lines[i][0], this.lines[i][1]);
            }
        }

Best Regards,

Fred

On 1/31/07, Evaldas Taroza <e.taroza at gmail.com> wrote:
>
> Hi,
> I have lost the track on the progress of OpenLayers. Can one already draw
> a polyline on the map?
>
> Thanks,
>
> Zeppe
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
>


-- 
"Everything under the sun is in tune
But the sun is eclipsed by the moon"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070202/53353165/attachment.html


More information about the Users mailing list