Length buffer around polyline

早过忘川 提交于 2019-12-02 21:09:54
yunzen

I found this stack in SO Path stroke algorithm (convert to triangles/quads) or other suggestions where there is a similar question, just for C++.

The answer is a algorithm in this PDF on page 3 (the CONVOLVE algorithm).

If you perhaps could make a working example in JSFiddle, we could be able to program a solution in there.

-- edit

After some time of analysing the script in the link you provided for the life demo, I found, that the polyline is not calculated in javascript, but is calculated on the server and returned with a AJAX call to some PERL programme.

Can't you just draw another polyline on the same path as the first one, with a larger stroke? It doesn't give you exactly the same results, i.e. a polygon with a border color different from its fill color, but the overall effect is very similar.

// first, black line
var kelias = new google.maps.Polyline({
            path: result.routes[0].overview_path,
            strokeColor: "#000000",
            strokeOpacity: 1.0,
            strokeWeight: 2
        });

// second, translucent red line
var kelias2 = new google.maps.Polyline({
            path: result.routes[0].overview_path,
            strokeColor: "#FF0000",
            strokeOpacity: 0.8,
            strokeWeight: 40,
            map: MAP
        });

Update: You're adding and subtracting 'z' from both the latitude and longitude of the points along your path. Given that latitude runs from +90 to -90, but longitude runs from +180 to -180, I think you maybe need different values for each.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!