如何在google map api v3上添加切换按钮? [英] How to add toggle button on google map api v3?

查看:118
本文介绍了如何在google map api v3上添加切换按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了图书馆: geometrycontrols 写入api v2并允许添加按钮。如何使一个切换按钮在api v3中添加标记?我已经启动了map等功能。

解决方案

您可以添加任意结构化的< div> 到地图:

  var control = document.createElement('div'); 

您为此控件或其子级添加侦听器,例如:

  google.maps.event.addDomListener(control,'click',function(){...}); 

您将控件放在地图上:

  control.index = 1; 
map.controls [google.maps.ControlPosition.TOP_RIGHT] .push(control);

详情请参阅:

< a href =http://code.google.com/apis/maps/documentation/javascript/controls.html#CustomControls =noreferrer>自定义控件



示例


I found library: geometrycontrols that is written to api v2 and allows adding buttons. How to make a toggle button to add a marker in the api v3? I have initiated map etc.

解决方案

You can add an arbitrary structured <div> to the map:

var control = document.createElement('div'); 

You add a listener to this control or to its children, e.g.:

google.maps.event.addDomListener(control, 'click', function() {...}); 

You position the control on the map:

control.index = 1;   
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(control);  

For details, see:

Custom Controls

Example

这篇关于如何在google map api v3上添加切换按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆