问题描述
今天我和一位客户交谈,他想在 Android 上构建一个简单的导航 APP!
Today I've talked to a client and he wants to build a simple navigation APP on Android!
基本上我们可以使用谷歌地图,放置一些我们的"标记来显示一些位置(餐厅、酒店等)......我们还需要向用户的朋友展示附近!
Basically we could use Google maps, place some of "our" markers to show some locations (restaurants, hotels etc.) .. also we need to show user's friends near by!
这一切都可以在 Android 上的 Google Maps API 中实现,除了我无法在我自己的应用程序中找到有关精细导航实现的任何有用信息(无需切换到 Google 地图应用程序)..
Everything of that is possible in Google Maps API on Android, except I can not find any useful information about Turn-by-turn navigation implementation inside my own app (without switching to Google Maps App) ..
有人可以简单地澄清一下 - 是否可以在 Android 应用中使用 Google 地图来创建基于 GPS 的精细化应用?
Can someone simply clarify - is it possible to use Google Maps inside an Android app to create turn-by-turn GPS based app?
谢谢
推荐答案
阅读 Tushar 的回答在使用此答案之前,请参阅以下内容
Read answer by Tushar below before using this answer
首选
如果您想在您的应用中完全实现导航,则必须结合使用 Google Maps API 和 Google Directions API.它们可以免费使用,但您必须为 api 请求付费.(https://developers.google.com/maps/documentation/directions/)
If you want to implement the navigation completely in your app you will have to use a combination of the Google Maps API and the Google Directions API. They are free to use up to a limit and then you have to pay for the api requests.(https://developers.google.com/maps/documentation/directions/)
第二个选项
我只想将您要导航的位置的纬度和经度发送到设备的地图"应用.这里有一些代码可以让你开始使用这个方法:
I would just send the latitude and longitude of the location you want to navigate to the devices Maps app. Here is some code to start you off with this method:
double lat = < latitude of the location you want to navigate to>
double lng = < longitude of the location you want to navigate to>
String format = "geo:0,0?q=" + lat + "," + lng + "( Location title)";
Uri uri = Uri.parse(format);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
这将打开设备的地图应用程序并绘制位置,用户可以使用该应用程序做任何他们想做的事情.
This will open the device's Maps app and plot the location and the user can use the app to do what ever they want.
我会选择第二个选项,它非常容易实施.
I would go with the Second Option, it is stupidly easy to implement.
这篇关于是否可以使用 Google 地图在 Android/iOS 上创建逐向 GPS 导航应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!