私はイタリア人で、JavaScript とサーバー側のルール設定のほとんど初心者です。ウェブサイトを作成していて、gpxtruder.xyz のコードの一部を使用する予定です。
私は所有者 (Jim Denova jim@anoved.net) の許可を得て、オープンソース ライセンスの下でリリースされているオリジナル コードを使用します。
index.html ページのコードは次のとおりです。
<form enctype="multipart/form-data" method="get" name="gpxform">
<p><input type="radio" name="gpxsource" value="0" id="gpxsource_upload" onchange="return toggle(event, 0, 'gpxfile') && toggle(event, 1, 'gpxsample');" />
<label for="gpxsource_upload">Upload GPX:</label>
<input type="file" id="gpxfile" /><br />
<input type="radio" name="gpxsource" value="1" id="gpxsource_sample" onchange="return toggle(event, 0, 'gpxfile') && toggle(event, 1, 'gpxsample');" checked />
<label for="gpxsource_sample">Sample GPX:</label>
<select id="gpxsample">
<option value="0" selected>South Mountain</option>
<option value="1">Vestal XX (20k road race)</option>
</select>
<h1>Hello, my name is <span id="name"></span></h1>
<script>
let gpxsource = "1"
let name = gpxsource;
document.getElementById("name").innerHTML = name;
</script>
事前に選択したトラックを選択して結果を表示したり、独自の gpx ファイルをロードしたりできます
パラメータは gpxtruder.js ファイルに送信され、コードの最初の部分のデータを処理するコードの一部に従います
if (radioValue(form.gpxsource) === 0) {
// Assign a local URL to the file selected for upload
// https://developer.mozilla.org/en-US/docs/Web/API/URL.createObjectURL
var files = document.getElementById('gpxfile').value;
window.alert(gpxfile);
//var files = document.getElementById('gpxfile').files;
window.alert(files);
if (files.length === 0) {
Messages.error('No GPX file selected.');
return;
}
// upload_url = window.URL.createObjectURL(files[0]);
upload_url = files
} else {
if (parseInt(form.gpxsample.value) === 0) {
upload_url = "https://gpxtruder.xyz/gpx/SouthMtn.gpx";
} else if (parseInt(form.gpxsample.value) === 1) {
upload_url = "https://gpxtruder.xyz/gpx/VXX.gpx";
} else {
return;
}
}
window.alert(upload_url);
window.alert(options);
loader(options, upload_url);
if (radioValue(form.gpxsource) === 0) {
window.URL.revokeObjectURL(upload_url);
}
コードの 2 番目の部分
var loader = function(options, gpx_url) {
window.alert(gpx_url);
Messages.clear();
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState === 4 /*&& req.status == 200*/) {
if (!req.responseXML) {
Messages.error("This doesn't appear to be a GPX file.");
return;
}
window.alert(req.responseXML);
// Attempt to parse response XML as a GPX file.
var pts = Parser.file(req.responseXML, options.zoverride, options.zconstant);
if (pts === null) {
return;
}
// If all is well, proceed to extrude the GPX path.
g = new Gpex(options, pts);
}
};
// submit asynchronous request for the GPX file
req.open('GET', gpx_url, true);
req.overrideMimeType("text/xml");
req.send();
};
upload_url = "https://gpxtruder.xyz/gpx/VXX.gpx";
URLアドレスを変更し、gpxファイルをホストしたサーバーWebスペースを挿入すると、元のファイルを使用しても、「これはGPXファイルではないようです」というページの回答に厳密に関連しています。
問題がある可能性があるとは思いませんでした。
JavaScript関連の問題でしょうか?(ただし、コードとファイルは正確にオリジナルの複製です) または gpx ファイルがホストされている場合、サーバー側の構成の問題である可能性がありますか?
元のファイルが見つかりました
https://gpxtruder.xyz/index.html
https://gpxtruder.xyz/js/gpxtruder.js
可能であれば、助けてくれてありがとう。