如何提高 KML 性能
你好 我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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
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
我不确定您是否已更改 KML 以符合之前的一些建议,但是...
至于您关于在缩放区域中显示总标记的解决方案的问题:
我想您可以对于每个缩放级别,检查地图的边界,然后仅显示在该边界中有坐标的标记。您可能必须编写某种函数来检查它是否在边界内。我不知道有什么方法可以从 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...
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.