【问题标题】:why is google's infoWindow CSS not exposed? customization is too hard为什么google的infoWindow CSS没有暴露?定制太难了
【发布时间】:2011-10-30 06:30:12
【问题描述】:

这真的让我很烦恼 - 很多。

在浏览了谷歌地图 v3 在 firebug 中生成的客户端代码之后,我正准备开车上街,让其中一些工程师了解一下我的想法... arrrgh :P

infowWindow 类生成的 HTML 我个人认为简直是疯了。也许有人可以帮助我理解它。

infowWindow HTML 结构是这样的:

#map_canvas > div > div > div > div > div // 5 levels of elements, 
no big deal here, ok...
> div // top left corner
div // top right corner
div // bottom left corner
div // bottom right corner

// now comes fun stuff for the speech bubble arrow:

div
div
div
div
div
div
div
div
div
div

// the 10 divs above are stacked diagonally with odd sizes to make this arrow. 
i'm sorry but WHY?!? is it done like that? I suppose they wanted the user to be 
able to grab the map even right next to the arrow. Think about this: do users 
really need to be able to not grab the arrow? if grabbing the arrow causes map pan, 
as is the case for the shadow images, would that really be a problem?

div // bottom middle for image background border or something
div // top middle
div // middle
div // bottom middle, again
div // entire block of the infoWindow, probably the container
> img // close box
div // center block with the contents of the infoWindow
div // text content container

哇——太疯狂了!

注意没有真正的语义结构,而且 - 天哪,我敢有这样的 假设 - 任何地方都没有类名,什么都没有。我想也许他们有一些 一种 9-slice box 继续,然后分别产生箭头;我是说, iw3.png 中的图像精灵肯定不会是这里的问题。

我非常希望对这个 api 有影响的人遇到这个并且 希望谷歌最终会找到一种方法来解决这个问题 infoWindow 的视觉效果就像标记一样简单。

感谢收看!愉快的评论。

同时,我将使用 hack 来获取这些疯狂的 div 并让它们按照我的要求行事。


之前我在其他帖子上发表过评论,我认为在 API 中要求一种方法让您使用自定义 UI 而不像当前需要的那样使用几乎复制整个窗口对象的方法应该不会太过分(参见 google 扩展类 v3)。

google.maps.infoWindow.setStyle({
  'topleft' : {
    'background' : 'url(images/windowsprite.png) 0 0 no-repeat',
    'width' : '10px',
    'height' : '10px'
  },
  'topRight' : {
     ...etc...
  }
  ...etc...
})

【问题讨论】:

    标签: css google-maps google-maps-api-3 customization infowindow


    【解决方案1】:

    你试过信息框吗?

    http://googlegeodevelopers.blogspot.com/2010/04/infobox-10-highly-customizable.html

    还是信息泡泡?

    http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/examples/example.html/

    它们都让您对信息窗口的外观有更多的控制,同时仍然抽象了一些复杂的部分。

    元素上缺少类是 API 的(好的)设计决策。它消除了与用户定义的类发生冲突的可能性。

    【讨论】:

    • 是的,我都试过了,但我很累,因为它在一个巨大的库中重复了很多功能,所以我可以做一些简单的 CSS 调整。我只是期待一个将盒子 CSS 公开为可设置属性的谷歌 API。至于类,我认为使用简单的前缀不会有问题。
    【解决方案2】:

    经过多次尝试和错误,我决定解决此问题的最佳方法是使用 OverlayView 类并简单地自定义构建一个容器。好吧,“简单”是一种轻描淡写的说法,但它确实有效。现在我可以完全控制布局和功能。

    【讨论】:

      【解决方案3】:

      您尝试使用 CSS 进行样式设置?下面的示例显示了这一点。这是更改 UI 最直接的方法。

      http://code.google.com/apis/maps/documentation/javascript/overlays.html#InfoWindows

      【讨论】:

      • 那是为了内容,而不是窗口本身。
      猜你喜欢
      • 2015-09-26
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      • 2011-08-12
      • 2018-02-16
      • 2018-12-25
      • 2022-06-14
      • 2021-02-04
      相关资源
      最近更新 更多