ajax maps infobox - editing possible ?

This forum deals with any kind of web based client technology, whether it is the well known java script based Ajax servlet or the upcoming approaches such as Leaflet, OpenLayers and so on.

ajax maps infobox - editing possible ?

Postby nemec » Mon May 22, 2017 4:48 pm

Hello !

i use a infobox for defined points

var infobox = new com.ptvag.webcomponent.map.vector.InfoBox();
infobox.set({x:4303250,y:5486500,text:"Mc Donalds"});
vectorLayer.addElement(infobox);

is it possible to edit this Text on the map ?

Regards
Andreas
nemec
 
Posts: 17
Joined: Tue May 02, 2017 10:05 am

Re: ajax maps infobox - editing possible ?

Postby AndreasJunghans » Tue May 23, 2017 10:22 am

Hi Andreas,

the text in an InfoBox is HTML, so you can put anything there. Here's a small example that makes the text editable (not pretty and only tested in Chrome, but you should get the idea):

Code: Select all
var infobox = new com.ptvag.webcomponent.map.vector.InfoBox();
var myText = "Test";
function setContents() {
  var textSpan = document.createElement("span");
  textSpan.id = "textSpan";
  textSpan.appendChild(document.createTextNode(myText));
  infobox.setText(textSpan.outerHTML);
  setTimeout(function() {
    textSpan = document.getElementById("textSpan");
    textSpan.onclick = textClicked;
  }, 0);
}
function textClicked() {
  var input = document.createElement("input");
  input.id = "textInput";
  infobox.setText(input.outerHTML);
  setTimeout(function() {
    input = document.getElementById("textInput");
    input.value = myText;
    input.onkeydown = textKeyDown;
    input.focus();
  }, 0);
};
function textKeyDown(e) {
  if (!e) e = window.event;
  if (e.keyCode == 13) {
    if (this.value.trim() != "") {
      myText = this.value;
    }
    setContents();
  }
};
infobox.set({x:4303250,y:5486500});
setContents();
vectorLayer.addElement(infobox);


Regards,

Andreas (yes, me too :-))
AndreasJunghans
 
Posts: 11
Joined: Tue May 13, 2014 3:28 pm

Re: ajax maps infobox - editing possible ?

Postby nemec » Tue May 23, 2017 11:17 am

Thank you very much / Danke 1000 fach !

it runs!!!

Regards /Grüße aus Wien
Andreas Nemec
nemec
 
Posts: 17
Joined: Tue May 02, 2017 10:05 am


Return to PTV Webclients (Ajax, Leaflet, OpenLayers, WMS, ...) (Admin=LNM)

cron