Skip to content

Commit c8dccd3

Browse files
committed
Added the path finder
1 parent b5bb20b commit c8dccd3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pathfinder.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<style>
2+
html, body {
3+
margin: 0px;
4+
padding: 0px;
5+
}
6+
</Style>
7+
8+
9+
<svg style="width: 768px; height: 1205px; margin: 0px; padding: 0px; background: url(map/map.svg) center center no-repeat scroll; version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="557px"
10+
height="701px" viewBox="0 0 768 1205" enable-background="new 0 0 768 1205" xml:space="preserve">
11+
12+
</svg>
13+
14+
15+
<script>
16+
17+
function parseSVG(s) {
18+
var div = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
19+
div.innerHTML= '<svg xmlns="http://www.w3.org/2000/svg">'+ s +'</svg>';
20+
var frag = document.createDocumentFragment();
21+
while (div.firstChild.firstChild)
22+
frag.appendChild(div.firstChild.firstChild);
23+
return frag;
24+
}
25+
26+
function show() {
27+
document.getElementsByTagName("svg")[0].innerHTML = "";
28+
var points = document.getElementById("points").value;
29+
var e = "<polyline fill='none' stroke='red' stroke-width='3' points='"+points+"'></polyline>";
30+
document.getElementsByTagName("svg")[0].appendChild(parseSVG(e));
31+
}
32+
</script>
33+
34+
<div style="position: fixed; right: 10px; top: 0px">
35+
<p>
36+
<h1>Enter points </h1>
37+
<span style="color:red">NOTE: Separate every x-y pair by a comma. eg (x y, x y, x y)</span><br><br>
38+
<textarea id="points" style="width: 300px; height: 200px;">001 231, 231 343, 522 343, 299 32, 12 323</textarea><br><br>
39+
<input type="button" value="show" onclick="show();">
40+
</p>
41+
</div>
42+

0 commit comments

Comments
 (0)