加载后更改Google Maps v3 mapOptions对象 [英] Change Google Maps v3 mapOptions object after load

查看:151
本文介绍了加载后更改Google Maps v3 mapOptions对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何修改V3地图的mapOptions(在初始地图加载后)?



具体而言,我希望能够将

  draggable:false 

选项

<$ p $当一个动作(例如点击一个动作)时,一个动作(如点击一个动作)

另外:我尝试了加载jquery-ui-map并使用:

  $('#map')。gmap('option','draggable',true); 

然而,这似乎是重新加载地图并忘记了所有其他现有选项。我可以重新定义它们,但这似乎有点hackish。



任何指针赞赏。



谢谢! / p>

解决方案

发现我甚至不需要jQuery,它已经是Google Maps API的一部分。简单地做:

  map.set('draggable',true); 

太容易了!希望它能帮助别人。


How can i modify a V3 map's mapOptions (after the initial map has been loaded)?

Specifically, I would like to be able to flip the

draggable: false

option to

draggable: true

When an action (such as a click on a div) is triggered.

Addition: I have tried loading jquery-ui-map and using:

$('#map').gmap('option', 'draggable', true);

However this seems to reload the map and forget all the other existing options. I could redefine them all, but that seems a bit hackish.

Any pointers appreciated.

Thanks!

解决方案

Found that I don't even need jQuery for this – it's already part of the Google Maps API. Simply do:

map.set('draggable', true);

Too easy! Hope it helps someone.

这篇关于加载后更改Google Maps v3 mapOptions对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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