显示 gpx 文件的地图
我希望允许用户将跟踪路线的 gpx 文件上传到我的 Rails 3.2 应用程序,并在地图上显示它们,即使用 Google 地图。
我怎样才能做到这一点?有没有比我自己解析 gpx 文件、将所有航点存储在我的数据库中并通过 json 为 Google Maps API 提供它们更简单的方法?
提前致谢!
I want to allow users to upload gpx files of a tracked route to my rails 3.2 app and to show them on a map, i.e. by using Google Maps.
How can I do that? Is there an easier way than parsing the gpx file by myself, store all waypoints in my database and provide them via json for the Google Maps API?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,我不是 Ruby 专家。然而,地理数据抽象库(GDAL)应该很好地处理这个问题。 GDAL 有 Ruby 绑定:
http://trac.osgeo.org/gdal/wiki/GdalOgrInRuby
我建议使用它将 GPX 转换为 KML,然后使用 KMLLayer 对象显示 KML。您将使用 ogr2ogr:
http://gdal.org/ogr2ogr.html
这是 KMLLayer:
http://code.google.com/apis/maps/documentation /javascript/layers.html#KMLLayers
Sorry, not much of a Ruby expert. However, the Geographic Data Abstraction Library (GDAL) should handle this very well. GDAL has Ruby bindings:
http://trac.osgeo.org/gdal/wiki/GdalOgrInRuby
I would suggest using it to convert GPX to KML and then using the KMLLayer object to display the KML. You would use ogr2ogr:
http://gdal.org/ogr2ogr.html
Here's the KMLLayer:
http://code.google.com/apis/maps/documentation/javascript/layers.html#KMLLayers