Home > front end >  Baidu map API for JS midpoint information window to add HTML controls text text box, and button, how
Baidu map API for JS midpoint information window to add HTML controls text text box, and button, how

Time:10-24

Value value must be obtained from the external variables, similar to the XXXX.value=https://bbs.csdn.net/topics/name; So, I tried a good variety of the text box displays only string, such as the sentence above will show the name, not the name of the specific values, and affix the key code, strives for the great god answer.
 var content="& lt; Br>" + 
"Location:" + + ", "+ Y + X" & lt; Br>" +
"Name:" + '& lt; Input type="text" id="txt1" value="https://bbs.csdn.net/topics/789"/& gt; "+" & lt; Br>" +
":" + '& lt; Input type="text" id="txt2" value="https://bbs.csdn.net/topics/&name"/& gt; "+" & lt; Br>" +
"Type:" + '& lt; Input type="text" id="txt3 value=https://bbs.csdn.net/topics/&name"/> "+" & lt; Br>" +
"States:" + '& lt; Input type="text" id="txt4" value="https://bbs.csdn.net/topics/+name+"/& gt; "+" & lt; Br>" +
"Note:" + '& lt; Input type="text" id="txt5" value=""/& gt; "+" & lt; Br>" + "& lt; Br>" +
'& lt; Input type="button" onclick="" value=" at https://bbs.csdn.net/topics//& gt;" "+" + "
'& lt; Input type="button" onclick="set ();" Submit value="https://bbs.csdn.net/topics/"/& gt; ';

The above several are characters in the value displayed in the text box, with no quotation marks are the same

CodePudding user response:

I currently write assignment statement on open information window function, the back of the open operation, such as the following code, the problem is the first time open after the text inside information window does not display the data, turn off the open will show again, how to realize the first open can read data? I try in the open window above operation error,, consult everybody a great god!
 function openInfo (content, e) 
{
Var p=e. arget;
Var point=new BMap. Point (p.g etPosition (). The LNG, p.g etPosition (). The lat);
Var infoWindow=new BMap. InfoWindow (content, opts);
Map. OpenInfoWindow (infoWindow, point);
Document. The getElementById (" txt1 "). The value=https://bbs.csdn.net/topics/name;
Document. The getElementById (" txt2 "). The value=https://bbs.csdn.net/topics/num;
Document. The getElementById (" txt3 "). The value=https://bbs.csdn.net/topics/type;
Document. The getElementById (" txt4 "). The value=https://bbs.csdn.net/topics/status;
Document. The getElementById (" txt5 "). The value=https://bbs.csdn.net/topics/remark;
}

CodePudding user response:

I also met the same problem, on the custom form in the form controls such as input control,
1: using the document. The getElementById (" title "). The value="https://bbs.csdn.net/topics/title";
2: then will the loaded into the var infoWindow=new BMap. The infoWindow (content);
3: map. OpenInfoWindow (infoWindow, point);
Problem, the infoWindow input control value on their abdomen
  • Related