Browse Source

editLink: edit with remote control

master
parent
commit
dbf5c86ac1
  1. 1
      lang/en.json
  2. 22
      src/editLink.js

1
lang/en.json

@ -10,6 +10,7 @@
"default": "default",
"edit": "edit",
"editor:id": "iD (in-browser editor)",
"editor:remote": "Remote Control (JOSM or Merkaator)",
"error": "Error",
"export-all": "Export all visible map features",
"export-prepare": "Prepare download",

22
src/editLink.js

@ -1,5 +1,24 @@
window.editLinkRemote = function (type, osm_id) {
let bounds = global.map.getBounds()
xhr = new XMLHttpRequest()
let url = 'http://127.0.0.1:8111/load_and_zoom' +
'?left=' + bounds.getWest().toFixed(5) +
'&right=' + bounds.getEast().toFixed(5) +
'&top=' + bounds.getNorth().toFixed(5) +
'&bottom=' + bounds.getSouth().toFixed(5) +
'&' + type + '=' + osm_id
xhr.open('get', url, true)
xhr.responseType = 'text'
xhr.send()
return false
}
module.exports = function editLink (object) {
switch (global.options.editor) {
case 'remote':
return '<a class="editLink" href="#" onclick="return editLinkRemote(\'' + object.object.type + '\', ' + object.object.osm_id + ')">' + lang('edit') + '</a>'
case 'id':
default:
return '<a target="_blank" class="editLink" href="' + global.config.urlOpenStreetMap + '/edit?editor=id&' + object.object.type + '=' + object.object.osm_id + '">' + lang('edit') + '</a>'
@ -11,7 +30,8 @@ register_hook('options_form', function (def) {
'name': lang('options:chooseEditor'),
'type': 'select',
'values': {
'id': lang('editor:id')
'id': lang('editor:id'),
'remote': lang('editor:remote')
},
'default': 'id',
'weight': 5

Loading…
Cancel
Save