帮助设置 OSMdroid 库以显示 OpenSourceMaps
嘿。我在设置 OSMdroid 库来显示 OpenSourceMaps 时遇到问题。我正在开展一项活动,该活动将允许用户查看其当前位置的地图,并带有按钮,以允许用户在普通谷歌地图视图、地形谷歌地图视图和 openstreetmaps 视图之间切换。我当前正在使用 JAR 文件,并将其添加到我的项目的构建路径中。它编译得很好,但我不明白如何使用该库。网上的教程/指导很少。我是否需要在布局中创建 IMapView 标记并像 Google 地图视图一样使用它?如何从正常的谷歌地图视图切换布局图块?
如果有人能给我一个关于这个库如何工作的简短演练,我将不胜感激。我已经用 JAVA 编码很多年了,所以我只需要一个关于我需要做什么的英文描述。
提前致谢。
Hey. I am having trouble setting up the OSMdroid library to display OpenSourceMaps. I am working on an activity that will allow the user to see a map of their current location wit buttons to allow the user to switch between normal google maps view, terrain google maps view, and openstreetmaps view. I am currently using the JAR file and just adding it to the build path of my project. It compiles fine however I don't understand how to use the library. There are very few tutorials/directions online. Do I need to make an IMapView tag in the layout and use it like a Google Map view? How do I switch the layout tiles from normal google maps view?
If someone could just give me a very short walkthrough of how this library works it would be much appreciated. I have been coding in JAVA for numerous years so I just need an english description of what I need to do.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法让 osmdroid 在一个项目中工作,但必须在不同的活动中使用 Google 和 OSM 视图,就像您将 Mapview 从 Google 切换到 OSM,然后尝试返回 Google 一样,我收到一个运行时错误,内容如下“每个活动仅允许一个地图视图”。这会导致大量重复代码,但运行正常。
使用最新的osmdroid-android-3.0.3.jar,绘制叠加层更加简单。您还需要包含 slf4j-android-1.5.8.jar。这里有价值的是用于开始的捆绑演示的代码。它有一个位置侦听器,并绘制一个非常简单的覆盖层(穿过屏幕的线)。如果您熟悉 Google 地图,您应该能够根据您的目的调整它。
和 xml (copymain.xml)
I managed to get osmdroid working in a project, but had to have the Google and the OSM views in different activities as if you switch a Mapview from Google to OSM and then try to go back to Google, I got a runtime error saying something like "only one mapview allowed per activity". This results in a lot of duplicate code but it does run OK.
Use the latest osmdroid-android-3.0.3.jar, it's much simpler for drawing overlays. You'll also need to include slf4j-android-1.5.8.jar. For what it's worth here is the code for the lashed up demo that used to start with. It's got a location listener and draws a very simple overlay (line across the screen) If you are familiar with Google Maps, you should be able to adapt it for your purpose.
And the xml (copymain.xml)