webglearth / webglearth2

[UNMAINTAINED] WebGL Earth 2 - the source code of the project
Apache License 2.0
888 stars 212 forks source link

Drawing geometry objects #37

Open careyv opened 9 years ago

careyv commented 9 years ago

webgl earth just provide the API of polygon,could u tell me how to draw a line?

klokan commented 9 years ago

Lines are not exposed to the API yet, as there was no client who requested this in the past.

Patch or Pull request with implementation made by you or your team is welcome...

Alternative would be development contract (against a quote which we can provide from http://www.klokantech.com/contact/) for the work may help to make this happen.

ChatonVert commented 8 years ago

I dig up this topic to know if something has been found ? I'm trying to hack polygon system by putting 2 points on same location so simulate a line, but it's not enough clear for now. Any one has find a good way to do it ?

Tremx389 commented 7 years ago

Hey, Here is my solution with using the polygon to draw a line between two coords

    const A = {lt: 40.7306, lg:-73.9352}
    const B = {lt: 47.4979, lg: 19.0402}

    let lineBetween = function(B, A) {
        let coords = [];

        const N = 100;

        const m = (A.lt - A.lg) / (B.lt - B.lg)
        for (let i = 0; i < N; ++i) {
            const lt = A.lt - i / N * (A.lt - B.lt);
            const lg = A.lg - i / N * (A.lg - B.lg)

            coords.push([lt, lg]);
            coords.unshift([lt, lg]);
        }

        return coords;
    }