即使使用标记也为 JQuery UI 地图定义不同的默认缩放
我一直在网上寻找这个问题的答案,但基本上,我希望下面的代码能够准确地完成它正在做的事情......
$(function() {
$('#map_canvas').gmap().bind('init', function(ev, map) {
$('#map_canvas').gmap('addMarker', { 'position': '57.7973333,12.0502107', 'bounds': true }).click(function() {
$('#map_canvas').gmap('openInfoWindow', { 'content': '134 Some Street Name, postcode and such' }, this);
});
});
});
</script>
然而,这个地图视图是放大的,我希望能够控制它但将其保持在范围内。我尝试过使用:
$('#map_canvas').gmap('option', 'zoom', 7);
下面的功能,但它没有任何不同。在用户单击或拖动任何内容之前,如何控制地图的默认缩放?
谢谢!
I have been scavenging the web for an answer to this question but basically, I want the code below to do exactly what it's doing....
$(function() {
$('#map_canvas').gmap().bind('init', function(ev, map) {
$('#map_canvas').gmap('addMarker', { 'position': '57.7973333,12.0502107', 'bounds': true }).click(function() {
$('#map_canvas').gmap('openInfoWindow', { 'content': '134 Some Street Name, postcode and such' }, this);
});
});
});
</script>
However, this map view is to zoomed in and I want to be able to control it yet keep it within the bounds. I have tried using:
$('#map_canvas').gmap('option', 'zoom', 7);
below function but it makes no different whatsoever. How can I control the default zoom of the map before the user has clicked or dragged anything?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在构造函数 gmap({zoom:7}) 中设置缩放。如果您在 addMarker 方法中将bounds 属性设置为 true,它将覆盖之前在任何地方设置的任何缩放(通过选项或在构造函数中)。设置缩放并将边界设置为 false 的示例:
Set the zoom in the contructor gmap({zoom:7}). If you set the bounds property to true in the addMarker method, it will override any previous zoom set anywhere alse (by options or in the constructor). Example of setting the zoom and setting the bounds to false:
每当添加标记时,请将“边界”更改为 false。然后您可以设置您喜欢的任何缩放级别。
Change the 'bounds' to false whenever you add a marker. Then you can set whatever zoom level you like.
我发现最简单的方法是进入 jquery.ui.map.js 并更改那里的默认设置。这很容易。我把我的设置为15。
The easiest way I found was to go into jquery.ui.map.js and change the default set there. It's easy. I set mine to 15.