-
Notifications
You must be signed in to change notification settings - Fork 2
/
embed.php
141 lines (127 loc) · 4.32 KB
/
embed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="share-tracks.css" />
<style>
/* @import url('style.css'); */
textarea {
margin: 0;
}
#content,
iframe {
float: left;
margin: 1em;
}
#sizes label,
#tiles label {
display: inline-block;
vertical-align: bottom;
padding: 2px;
margin: 2px;
color: #fff;
border: 3px solid #fff;
background: #cdb;
cursor: pointer;
}
#sizes input,
#tiles input { visibility: hidden; margin-left: -18px}
#sizes label.selected,
#tiles label.selected {
border-color: #d00;
color: #d00;
}
#sizes .size1 { width: 70px; height:50px; }
#sizes .size2 { width: 100px; height:70px; }
#sizes .size3 { width: 130px; height:90px; }
</style>
<link rel="stylesheet" href="//unpkg.com/github-fork-ribbon-css@0.2.3/gh-fork-ribbon.css"></head>
<body>
<div id="content">
<label>Track: </label>
<select id="gpxfile">
<?
foreach(glob('./gpxs/*.gpx') as $f)
echo '<option value="'.$f.'">'.basename($f).'</option>'."\n";
?>
</select>
<br /><br />
<div id="sizes">
<label class="size1"><span>350 x 250</span><input name="size" type="radio" data-width="350" data-height="250" /></label>
<label class="size2"><span>640 x 360</span><input name="size" type="radio" data-width="640" data-height="360" /></label>
<label class="size3"><span>700 x 480</span><input name="size" type="radio" data-width="700" data-height="480" /></label>
</div>
<br />
<div id="tiles">
<label class="tile1"><span>OSM</span><input name="tile" type="radio" value="OSM" /></label>
<label class="tile2"><span>Paths</span><input name="tile" type="radio" value="Paths" /></label>
<label class="tile3"><span>Gray</span><input name="tile" type="radio" value="Gray" /></label>
<label class="tile4"><span>Sat</span><input name="tile" type="radio" value="Satellite" /></label>
<label class="tile5"><span>Terrain</span><input name="tile" type="radio" value="Terrain" /></label>
<label class="tile6"><span>Print</span><input name="tile" type="radio" value="Print" /></label>
</div>
<br />
<textarea cols="41" rows="5"></textarea>
<br />
<input id="iframeurl" type="text" valud="" size="42" />
</div>
<iframe src="map.html?gpxs/chia.fosso.gpx" frameborder="0" width="350" height="250"></iframe>
<a href="https://github.com/stefanocudini/share-tracks" class="github-fork-ribbon" data-ribbon="Fork me on GitHub">Github</a>
<script src="//unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
<script type="text/javascript">
$(function() {
var iframeOpts = {w: 350, h: 250, lay: 'OSM'};
$("#sizes :radio").on('click', function(e) {
var selected = $(this);
selected.parent().addClass("selected").siblings().removeClass("selected");
iframeOpts.w = selected.data("width");
iframeOpts.h = selected.data("height");
createIframe();
});
$("#tiles :radio").on('click', function(e) {
var selected = $(this);
selected.parent().addClass("selected").siblings().removeClass("selected");
iframeOpts.lay = selected.val();
createIframe();
});
$('#gpxfile').on('change', createIframe);
$('textarea').on('click', function(e) {
var start = 0,
end = this.value.length;
if (this.createTextRange) {
var selRange = this.createTextRange();
selRange.collapse(true);
selRange.moveStart('character', start);
selRange.moveEnd('character', end);
selRange.select();
}
else if(this.setSelectionRange) {
this.setSelectionRange(start, end);
}
else if(this.selectionStart) {
this.selectionStart = start;
this.selectionEnd = end;
}
});
function createIframe() {
var w = iframeOpts.w,
h = iframeOpts.h;
/*z = 16,
lat = 42.466865,
lon = 12.26337,*/
lay = iframeOpts.lay,
file = $('#gpxfile').val(),
params = 'map.html?'+file,//+'#layer='+lay, only layer parameter don't work in L.Permalink
url = window.location.protocol+'//'+window.location.host+'/'+window.location.pathname,
url = url.substring(0, url.lastIndexOf('/') + 1) + params,
iframeHtml = '<iframe frameborder="0" width="'+ w +'" height="'+ h +'" src="'+ url +'"></iframe>';
console.log(url);
$('#iframeurl').val(url);
$('textarea').text( iframeHtml );
$('iframe').replaceWith( $(iframeHtml) );
}
});
</script>
</body>
</html>