1

Hi I'm having some issues with KML performance. At some times the KML markers only appear after a reload which may have to do with google caching the results. I think a better solution is needed perhaps something like displaying a total of markers for an area on a larger zoom level and then more detailed for levels that have more zoom. Is such a solution feasible and if so, how? Can you think of other ways how I can improve performance of my KML map? The links are http://www.koolbusiness.com and the KML file is http://www.koolbusiness.com/list.kml

I can load the KML file into maps.google.com with no problem however when trying to display it on my custom map the display sometimes won't load. Thanks in advance for any suggestions.

UPDATE: I've updated to using a KMZ file with zip compression. The file is available via http://www.koolbusiness.com/list.kmz and the source and more info is available at http://montao.googlecode.com

4

2 回答 2

2

不知道它是否会影响性能,但似乎您需要为 kml 文件配置 mime 类型。 http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server

您是否尝试将 kml 文件压缩为 kmz 文件?您可以使用 zip 程序执行此操作,只需调用文件 kmz。

您在地标中重复样式元素,但您也可以在文档元素下创建它们,然后使用 id 引用它们。http://code.google.com/apis/kml/documentation/kmlreference.html#style

于 2011-03-31T13:52:22.967 回答
1

我不确定您是否更改了 KML 以符合之前的一些建议,但是......

  • KML 文件似乎很小,这很好。我将建议在 lat/lng 上截断小数点。
  • 您可以像之前的海报提到的那样将 KML 文件压缩到 KMZ。可以在此处找到更多信息:http ://code.google.com/apis/kml/documentation/kml_tut.html#kml_server您还需要在服务器上设置 KMZ MIME 类型。
  • 您可以减少 KML 文件中的空白量。不需要时似乎有额外的空间......
  • 您可以配置您的 Web 服务器以发送 KML 文件的缓存版本...虽然我不确定您正在运行哪种后端,所以我无法真正给出指点。这可能是标记不显示的原因。如果请求时间过长,Google 的服务器会超时。

至于您关于在缩放区域中显示总标记的解决方案的问题:我认为您可以针对每个缩放级别检查地图的边界,然后仅显示在该边界具有坐标的标记。您可能必须编写某种函数来检查它是否在边界内。我不知道有什么方法可以从 KML 文件中检索标记作为对象,除非您自己使用客户端解析器手动解析 KML。

为了帮助确定您的标记未加载的原因,请尝试使用 FireBug 来确定对 Google 服务器的请求。并查看返回什么样的响应,这可能会为您的问题带来更多答案。我相信您应该寻找的是 KmlOverlayService。

希望有帮助。

于 2011-04-07T15:33:38.410 回答