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

4 months ago
  1. import { Controller } from '@hotwired/stimulus';
  2. export default class extends Controller {
  3. static values = {
  4. importurl: String,
  5. layername: String,
  6. }
  7. remoteControl() {
  8. // cf <https://josm.openstreetmap.de/wiki/Help/RemoteControlCommands>
  9. const baseurl = 'http://localhost:8111';
  10. const _this = this;
  11. var url = baseurl + '/version';
  12. fetch(url)
  13. .then(function (response) {
  14. return response.json();
  15. })
  16. .then(function (json) {
  17. console.log('JOSM v' + json.version);
  18. url = baseurl + '/imagery?' + (new URLSearchParams({
  19. 'id': 'osmfr', // 'fr.orthohr', // cf <https://josm.openstreetmap.de/wiki/Maps>
  20. }));
  21. fetch(url)
  22. .then(function (response) {
  23. return response.text();
  24. })
  25. .then(function (text) {
  26. console.log(text);
  27. });
  28. url = baseurl + '/import?' + (new URLSearchParams({
  29. 'new_layer': true,
  30. 'layer_name': _this.layernameValue,
  31. 'url': _this.importurlValue,
  32. }));
  33. fetch(url)
  34. .then(function (response) {
  35. return response.text();
  36. })
  37. .then(function (text) {
  38. console.log(text);
  39. });
  40. });
  41. }
  42. }