简体   繁体   English

多个设备的地理定位

[英]Geolocalisation of multiple devices android

I am currently making an app that requires me to geolocalize multiple devices on the same map. 我目前正在制作一个需要我在同一地图上对多个设备进行地理定位的应用。 The user clicks on an imageview, a new Activity pops up and a map is shown with the position of all of the app users. 用户单击图像视图,会弹出一个新的“活动”,并显示一个地图,其中包含所有应用程序用户的位置。 However after looking through the web I didn't find anything helpful. 但是,浏览网络后,我发现没有任何帮助。

I was wondering what was the better solution : 我想知道什么是更好的解决方案:

1) Each time a user starts the "MapsActivity" it triggers notifications to each user so it can request its position 2) Every 30 seconds each user's position is updated in a database and each time a user starts the "MapsActivity" it sends a query to the database => This solution might drain the battery ... 1)每次用户启动“ MapsActivity”,都会触发向每个用户的通知,以便可以请求其位置2)每隔30秒,每个用户的位置在数据库中都会更新一次,并且每次用户启动“ MapsActivity”时,都会发送查询到数据库=>此解决方案可能会耗尽电池...

Thanks for your help 谢谢你的帮助

Make sure that when a users starts the MapsActivity , you want location of all users to be displayed. 确保当用户启动MapsActivity时 ,您希望显示所有用户的位置。 If you want the location of all users displayed then that would'nt be geolocalization at all, it will be simple geolocation.For now 如果要显示所有用户的位置,那根本就不是地理定位,这将是简单的地理位置。

For location of all users 对于所有用户的位置

Figure out what precision of location of the users you need. 找出所需的用户位置精度。 If you need Highly precise location then you will have to use the method you descibed above which apprently drains battery. 如果需要高度精确的位置,则必须使用上面描述的方法,该方法会明显地消耗电池电量。

1) Each time a user starts the "MapsActivity" it triggers notifications to each user so it can request its position 2) Every 30 seconds each user's position is updated in a database and each time a user starts the "MapsActivity" it sends a query to the database => This solution might drain the battery

If highly precise data is not required, then periodically the users can send a geohash of their location to the servers and the servers can store data in > form. 如果不需要高精度数据,则用户可以定期将地理位置的哈希值发送到服务器,并且服务器可以>格式存储数据。 When a user starts the MapsActivity, geohash will be calculated locally and a query will be sent to the server which will return approximate positions in return. 当用户启动MapsActivity时,将在本地计算geohash并将查询发送到服务器,该服务器将返回近似位置。 The only advantage you have here is that the period can be larger ie users can ping the servers every 5 minutes instead of 30 seconds thus saving bettery. 您在这里拥有的唯一好处是周期可以更长,即用户可以每5分钟(而不是30秒)ping服务器一次,从而节省了时间。

For location of all users 对于所有用户的位置

Use the similar geohash technique and ping the servers with geohashes of users' location. 使用类似的geohash技术,并使用用户位置的geohash ping服务器。 Then while retrieving, calculate the aproximate geohash using levenshtein distance and return users belonging to all of these approximate geohashes. 然后在检索时,使用levenshtein距离计算近似的geohash并返回属于所有这些近似geohash的用户。

Heres some resources you might find useful 以下是一些您可能会发现有用的资源

Geohash information Geohash信息

Geohash website Geohash网站

Geohash API for Java Java的Geohash API

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

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