如何提高 KML 性能

发布于 2024-10-28 04:11:16 字数 703 浏览 1 评论 0原文

你好 我在 KML 性能方面遇到一些问题。有时,KML 标记仅在重新加载后出现,这可能与谷歌缓存结果有关。我认为需要更好的解决方案,也许需要在更大的缩放级别上显示某个区域的标记总数,然后在具有更大缩放级别的级别上显示更详细的标记。这样的解决方案是否可行?如果可行,如何实现?您能否想出其他方法来提高 KML 地图的性能?链接为 http://www.koolbusiness.com,KML 文件为 http://www.koolbusiness.com/list.kml

我可以将 KML 文件加载到maps.google.com 中,没有任何问题当尝试在我的自定义地图上显示它时,显示有时无法加载。 预先感谢您的任何建议。

更新:我已更新为使用带有 zip 压缩的 KMZ 文件。该文件可通过 http://www.koolbusiness.com/list.kmz 和源获取如需了解更多信息,请访问 http://montao.googlecode.com

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

所有深爱都是秘密 2024-11-04 04:11:16

不知道它是否会影响性能,但似乎您需要为 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

don't know if it affects performance but it seems like you need to configure the mime types for kml files.
http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server

Have you tried to compress the kml files as kmz files? You can do this with a zip program and just call the file kmz.

You repeat the style element in the placemarks but you can also create them under the doucment element and then just reference them with an id. http://code.google.com/apis/kml/documentation/kmlreference.html#style

晨光如昨 2024-11-04 04:11:16

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

  • KML 文件似乎非常小,这很好。我打算建议截断纬度/经度上的小数点。
  • 您可以像之前的海报提到的那样将 KML 文件压缩为 KMZ。如需了解更多信息,请访问:http://code.google.com/ apis/kml/documentation/kml_tut.html#kml_server 您还需要在服务器上设置 KMZ MIME 类型。
  • 您可以减少 KML 文件中的空白量。不需要时似乎有额外的空格...
  • 您可以配置网络服务器来发送 KML 文件的缓存版本...我不确定您正在运行哪种后端,所以我真的不能指点一下。这可能是标记不显示的原因。如果请求时间过长,Google 的服务器将使您的请求超时。

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

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

希望有帮助。

I'm not sure if you've changed the KML yet to conform to some of the previous suggestions but...

  • The KML File seems to be pretty minimal which is good. I was going to suggest truncating the decimal points on the lat/lng.
  • You can compress like KML file to KMZ like the previous poster has mentioned. More information can be found here: http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server You'll need to set up the KMZ MIME type on your server too.
  • You can reduce the amount of white space in your KML file. It seems to have additional spaces when not required...
  • You can configure your web server to send cached versions of the KML file... I'm not sure what kind of back end you're running though so I can't really give pointers. This might be a reason why the markers don't show. Google's server will time out your request if it takes too long.

As for your question about a solution to displaying total markers in an area for a zoom:
I was thinking you could for each zoom level, check the boundary of the map and then only display markers that have coordinates in that boundary. You'd probably have to write some kind of function that checks if it's in the boundary. I don't know of any way to retrieve the markers from the KML file as objects unless you manually parse the KML yourself using a client side parser.

To help determine why your markers don't load, try using FireBug to determine the requests to Google's servers. And see what kind of response is returning which might lead to more answers to your problem. I believe the one you should look for is KmlOverlayService.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文