如何在 Android 上显示自定义地图 [英] How to display a custom map on Android

查看:39
本文介绍了如何在 Android 上显示自定义地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个显示公园地图的 Android 应用程序,当用户点击地图上的某个位置时,该应用程序会转到另一个屏幕.

I'm trying to make an Android application that displays a map of a Park and when a user taps on a certain location on the map, the application goes to another screen.

问题是目前我的公园地图是 .jpg 格式.哪个映射 API 最适合我的应用程序,我将如何将此 .jpg 地图转换为 API 接受的格式.

Problem is that currently my map of the park is in a .jpg format. Which mapping API is best for my application and how would I go about converting this .jpg map into a format that is accepted by the API.

谢谢!

推荐答案

使用自定义地图为 Google 地图添加叠加层非常容易,示例代码开箱即用.

Adding an overlay for Google maps with a custom map is pretty easy to do, the sample code works out of the box.

要覆盖地图,您需要大致了解公园的 GPS 坐标.使用 jpg 的覆盖示例代码在这里:https://code.google.com/p/android-maps-extensions/source/browse/google-play-src/com/example/mapdemo/GroundOverlayDemoActivity.java?r=fd7175206a82da6d87b773e968d52849b4c107fb

To overlay the map you need to have a rough idea of the gps coordinates of the park. There is the sample code for overlays using a jpg is here: https://code.google.com/p/android-maps-extensions/source/browse/google-play-services-samples/src/com/example/mapdemo/GroundOverlayDemoActivity.java?r=fd7175206a82da6d87b773e968d52849b4c107fb

克隆整个项目并将其导入Eclipse:

Clone the entire project and import it into Eclipse:

git clone https://code.google.com/p/android-maps-extensions/

在您的设备上运行并安装它后,您需要在此处获取 API 密钥:https://code.google.com/apis/console

After you have it running and installed on your device, you will want to get an API key here: https://code.google.com/apis/console

如果您遇到困难,这里有完整的说明:https://developers.google.com/maps/documentation/android/start

Full instructions are here if you get stuck: https://developers.google.com/maps/documentation/android/start

还有其他演示可以使您的地图更有用,例如:

There are other demos to make your map more useful for example:

  • 前往活动/公园的交通信息
  • 一个 3D 透视图,如果你想要眼睛糖果
  • 与公园相关的用户当前位置的 GPS
  • 使叠加层不透明或略微透明
  • 自定义标记,以便用户可以点击并打开另一个屏幕

这篇关于如何在 Android 上显示自定义地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆