如何在谷歌地图的边缘创建填充 [英] how to create a padding around the edge of a google map

查看:120
本文介绍了如何在谷歌地图的边缘创建填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常忙碌的Google地图应用程序,我尝试在地图的外边缘创建一个缓冲区,以便Google地图命令不会在那里放置任何东西。我的解决方案是创建无形的div并将它们作为控件添加到地图中,每个边都有一个。这似乎很好,因为所有的谷歌命令看到他们并相应地调整,并且地图正常显示。例如,fitBounds确保我的边界不在不可见图层下。对于我有控制栏的顶部来说,这是一个完美的解决方案,但对于没有任何东西的其他边缘,它会产生一个问题 - 当他们进行单击事件时,我无法在这些控件下单击地图或信息窗口。

所以我正在寻找2个解决方案之一:
1)我可以让我的隐形控件将点击传递给地图,或者;
2)是否有更好的方法来填充地图的边缘;每次我想调用fitBounds或panTo时都不会涉及大量的数学运算,因为我会自动完成大量的地图运动。



干杯

解决方案

试着给无形的DIV一个负Z指数,例如-10


I have a very busy Google Maps app that I have built and I'm trying to create a "buffer zone" around the outside edge of the map so that the google map commands won't put things there. My solution was to create invisible divs and add them to the map as controls, one for each of the edges. This seems to work great as all of the google commands see them and adjust accordingly, and the map appears normally. For example, fitBounds ensures my bounds is not under the invisible layers. For the top where I have a control bar it's a perfect solution, but for the other edges where there is nothing, it creates a problem - I can't click on the map or info windows under these controls as they take the click event.

So I'm looking for one of 2 solutions: 1) can I make my invisible controls pass clicks through to the map, or; 2) is there a better way to pad the edge of the map; something that doesn't involve a much of math every time I want to call a fitBounds or panTo would be preferred as I automate a lot of map motion

Cheers

解决方案

Try to give the invisible DIV a negative z-index, e.g. -10

这篇关于如何在谷歌地图的边缘创建填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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