Google 地图、KML 还是 JSON 哪种数据源更可取?
我完全看到了 JSON 的好处,将轻量级数据数组放入我的 Google 地图中(并通过模板显示点列表)。我听过很多关于 KML 的讨论。
将点拉入 Google 地图、JSON 的最佳方式是哪种 || KML?我主要关心的是性能,还有可能改进地图的功能广度。
I totally see the benefits of JSON, pull over a lightweight array of data to stuff into my Google Maps (and template through to show a list of the points as well). I've heard a lot of talk about KML.
Which is the preferable way to pull points into Google Maps, JSON || KML? My primary concern is performance, but also breadth of features that could potentially improve the map.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我个人使用 json,因为 kml 生成的功能不如通过解析 json 创建的功能灵活。例如,您无法从 kml 将悬停事件添加到多边形。
Personally I use json because the kml resulting features are less flexible than the features that you create from parsing json. For example, you can't add a hover event to a polygon from kml.
如果您只是加载更简单的数据,那么与 JSON 相比,KML 作为 XML 是非常的重量级,并且不仅会在网络传输方面而且会在解析时间方面遭受性能损失。当然,这就是 JSON 的缺点,它不仅限制了潜在的表达能力(取决于 Google 地图组件可以通过 JSON 与 KML 消耗什么),还限制了哪些客户端可以消耗您的数据。如果您以 KML 格式提供数据,则任何读取 KML 的设备都可以使用您的数据,例如 Google 地球。它就像地理数据的 RSS,如果您想要或需要它的话。
KML, being XML, is very heavyweight compared to JSON if you're just loading simpler data and will suffer performance penalties not only in network transfer but in parsing time as a result. That's the downside to JSON, of course, is that you're limited not only in expressive power potentially (depending on what the Google Maps components can consume via JSON versus KML), but also on which clients can consume your data. If you give your data in KML, anything that reads KML can use your data, like Google Earth. It's like the RSS of geographic data, that is if you want or need it to be.
在过去的几个月里,我使用 OpenLayers 做了很多工作,并且非常喜欢它。该库是开源的,包含大量开箱即用的格式,包括 GeoJSON和 KML。 这是其余示例。结合 OpenLayers 和 ExtJS ,结果是 ExtJS 。 geoext.org/" rel="nofollow noreferrer">GeoExt(示例此处)。
These past few months I've done a lot of work with OpenLayers and have really enjoyed it. The library is open source and includes tons of formats out of the box including GeoJSON and KML. Here's the rest of the examples. Combined OpenLayers and ExtJS and it results in GeoExt (examples here).
我想为 KML 辩护,特别是在 Google 地图的背景下:
I would like to make a case for KML, specially in the context of Google Maps:
您可以在 KMZ、KML 和 GeoJSON 之间进行转换:
KMZ 只是 KML 文件的 ZIP 存档。所以至少KMZ -> KML 很容易。
另外,
如果上传速度是一个问题,我会选择压缩文件。我的猜测:对于小数据,GeoJSON 会更小,如果您的功能变得更复杂,KMZ 会更小。但我很高兴看到一些基准/数字/示例。
You can convert between KMZ, KML and GeoJSON:
KMZ is simply a ZIP archive of a KML file. So at least KMZ -> KML is easy.
And also
If upload speed is a concern, I would go with the compressed file. My guess: GeoJSON is way smaller for small data, KMZ is way smaller if your Features become more complex. But I'd be happy to see some benchmarks / numbers / examples.