Note that there are some explanatory texts on larger screens.

plurals
  1. POPolygon with multiple paths -- how to connect?
    primarykey
    data
    text
    <p>I am creating a polygon with multiple event handlers -- I can click-drag to draw freehand, hold shift and click to snap to roads, and do a normal click as well. Originally, I had one array that I pushed each of these points to. However, since the event handlers are unique, debugging an array that I pass everywhere and modify everywhere seems like bad form.</p> <p>I've made it so that the polygon paths is an array of arrays of points. When I shift-click, it makes an array of points, when I click-drag, it makes an array of points, and then I push these to the array of arrays. </p> <p>However, how do I connect these together? I am currently not able to connect the endpoints of one array to the start of the next. Because I'm trying to modularize my code, I don't want to have to pass the last point of an array to the event listener that makes the next array, because that defeats the purpose of having separate arrays.</p> <p>The documentation is pretty thin on multiple paths for a polygon.</p> <p>Here's what I have so far.</p> <p><a href="http://jsfiddle.net/skitterm/fn4g5/1/" rel="nofollow">http://jsfiddle.net/skitterm/fn4g5/1/</a></p> <p>Pseudocode: </p> <pre><code>array C = new Array(); addEventListener for click { populate array A C.push(A); } addEventListener for shift-click { populate array B C.push(B); } addEventListener for right-click { create polygon { paths: C } } </code></pre> <p>I can create a polygon by just shift-clicking, or by clicking, or clicking and dragging, but I can't make a polygon where one side is done by shift-clicking and the rest by normal clicks.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload