Page 1 of 1
ajax maps infobox - editing possible ?
Posted: Mon May 22, 2017 4:48 pm
by nemec
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
Re: ajax maps infobox - editing possible ?
Posted: Tue May 23, 2017 10:22 am
by AndreasJunghans
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
)
Re: ajax maps infobox - editing possible ?
Posted: Tue May 23, 2017 11:17 am
by nemec
Thank you very much / Danke 1000 fach !
it runs!!!
Regards /Grüße aus Wien
Andreas Nemec