admin管理员组文章数量:1430622
I have custom controls on my map with this tutorial .html#CustomDrawing
how can I create input boxes with something similar to this, so I could pass user input values e.g. numbers to my javascript for further use?
I have custom controls on my map with this tutorial http://code.google./apis/maps/documentation/javascript/controls.html#CustomDrawing
how can I create input boxes with something similar to this, so I could pass user input values e.g. numbers to my javascript for further use?
Share Improve this question edited Sep 23, 2011 at 11:21 asked Sep 23, 2011 at 11:15 user494461user4944612 Answers
Reset to default 2 +50It isn't that different to add inputs
, buttons
or labels
instead of divs
.
I put together an example on jsfiddle.
If you want to create custom controls that happen to be input buttons, it works in a manner very similar to the way in the link you've posted. Instead of a div, you'll need to make an input
.
The code would look something like this:
//create your control HTML
var controlDiv = document.createElement('DIV');
var controlInput = document.createElement('INPUT');
controlInput.name = "inputName";
controlInput.type = "text";
controlDiv.appendChild(controlInput);
//create your control javascript (e.g. any handlers that you need)
var myControl = MyControl(controlDiv)
//add the control to your map
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(controlDiv);
As you've already mentioned, the tutorial should cover most of the issues you're encountering, you just need to ensure that you create an input
element and get values from that.
本文标签: javascripthow to get a user input in google maps using custom controlsStack Overflow
版权声明:本文标题:javascript - how to get a user input in google maps using custom controls? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745548193a2662805.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论