javascript - how to get a user input in google maps using custom controls? - Stack Overflow

I have custom controls on my map with this tutorial.html#CustomDrawinghow can I create input boxes wit

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 user494461user494461
Add a ment  | 

2 Answers 2

Reset to default 2 +50

It 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745548193a4632439.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信