|
|
- import { Controller } from '@hotwired/stimulus';
-
- export default class extends Controller {
- static values = {
- imagery: String,
- importurl: String,
- layername: String,
- sendosm: Boolean,
- bottom: Number,
- top: Number,
- left: Number,
- right: Number,
- comment: String,
- source: String,
- hashtags: 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': _this.imageryValue,
- }));
- fetch(url)
- .then(function (response) {
- return response.text();
- })
- .then(function (text) {
- console.log('JOSM imagery ' + text);
- });
- if (_this.sendosmValue) {
- 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('JOSM import ' + text);
- });
- }
- url = baseurl + '/zoom?' + (new URLSearchParams({
- 'bottom': _this.bottomValue,
- 'top': _this.topValue,
- 'left': _this.leftValue,
- 'right': _this.rightValue,
- 'changeset_comment': _this.commentValue,
- 'changeset_source': _this.sourceValue,
- 'changeset_hashtags': _this.hashtagsValue,
- }));
- fetch(url)
- .then(function (response) {
- return response.text();
- })
- .then(function (text) {
- console.log('JOSM zoom ' + text);
- });
- });
- }
- }
|