You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.5 KiB

import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
static values = {
importurl: String,
layername: String,
}
remoteControl() {
// cf <https://josm.openstreetmap.de/wiki/Help/RemoteControlCommands>
const baseurl = 'http://localhost:8111';
const _this = this;
var url = baseurl + '/version';
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (json) {
console.log('JOSM v' + json.version);
url = baseurl + '/imagery?' + (new URLSearchParams({
'id': 'osmfr', // 'fr.orthohr', // cf <https://josm.openstreetmap.de/wiki/Maps>
}));
fetch(url)
.then(function (response) {
return response.text();
})
.then(function (text) {
console.log(text);
});
url = baseurl + '/import?' + (new URLSearchParams({
'new_layer': true,
'layer_name': _this.layernameValue,
'url': _this.importurlValue,
}));
fetch(url)
.then(function (response) {
return response.text();
})
.then(function (text) {
console.log(text);
});
});
}
}