简体   繁体   English

如何跟踪用户位置并使用Google Map制作路线

[英]how to track user location and make the route with google map

I would like to ask you an idea. 我想问你一个主意。 How to create a mobile application like starve or runtastic which can record user location in realtime and after user finish traveling, the app can draw the route that user traveled and show to them as a result. 如何创建像starve或runtastic这样的移动应用程序,该应用程序可以实时记录用户的位置,并且在用户完成旅行后,该应用程序可以绘制用户旅行的路线并显示给他们。 During user is traveling the app also find any places nearby the user location (places are stored in my database). 在用户旅行期间,该应用程序还会找到用户位置附近的所有地点(地点存储在我的数据库中)。

Please give me any idea. 请给我任何想法。

Thank you. 谢谢。

You will need to Use google Location API and map API. 您将需要使用google Location API和map API。 To setup map, follow this tutorial: http://www.tutorialspoint.com/android/android_google_maps.htm , 要设置地图,请遵循以下教程: http : //www.tutorialspoint.com/android/android_google_maps.htm

and to use the locationManager, follow this tutorial http://www.androidhive.info/2015/02/android-location-api-using-google-play-services/ . 并使用locationManager,请按照本教程http://www.androidhive.info/2015/02/android-location-api-using-google-play-services/进行操作

To draw the polyLine on different positions covered by the user, you might have to track every position longitude and latitude and draw the polyLine along the path. 要在用户覆盖的不同位置上绘制折线,您可能必须跟踪每个位置的经度和纬度,然后沿路径绘制折线。 For detailed info, checkout google Api on map and location at http://developer.android.com/training/location/index.html . 有关详细信息,请在http://developer.android.com/training/location/index.html上查看地图和位置上的google Api。

Hope this help 希望这个帮助

Your Question is very vague. 您的问题非常模糊。

To start with you will need Google Maps API key that renders a map to your fragment. 首先,您需要使用Google Maps API密钥将地图呈现到您的片段。


Current locations can be enabled by 当前位置可以通过以下方式启用

GoogleMap.setMyLocationEnabled(true);


After Asking a users destination you will use Google Maps Directions API with a Server key to opt for a route in form on JSON or XML through a URL. 询问用户目的地后,您将使用带有服务器密钥的Google Maps Directions API通过URL以JSON或XML形式选择路线。

https://maps.googleapis.com/maps/api/directions/output?origin="origin_location&destination="final_destination"&mode="traveling_mode"&alternatives="true"&key="ServerAPIkey"

You must pass this URL for a string with JSON or XML(output) data. 您必须为包含JSON或XML(输出)数据的字符串传递此URL。 And use that data to draw polyline for your route. 并使用该数据为您的路线绘制折线。

To Read complete details, it is adviced that you read google documentations on their developers website. 要阅读完整的详细信息,建议您阅读其开发者网站上的google文档。

Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM