[Mapbox-Android]如何显示用户所在位置附近的所有商店,医院?

问题描述 投票:-1回答:1

有一个教程:https://docs.mapbox.com/help/tutorials/android-store-locator/这显示了如何手动添加商店,创建数据集并将其显示在我们的应用程序中。我想让所有医院,银行靠近特定用户位置。我该如何实现?请帮忙!

java android location mapbox mapbox-android
1个回答
0
投票

您将要使用Mapbox Tilequery API查询Mapbox Streets的building层或查询具有银行/医院数据的自定义样式。

https://docs.mapbox.com/android/java/overview/tilequery/

https://docs.mapbox.com/android/java/examples/tilequery/

使用https://docs.mapbox.com/playground/tilequery/来玩Mapbox Tilequery API。例如,https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/-122.4052,37.7564.json?limit=19&radius=536&layers=building&dedupe=true&access_token=PASTE_YOUR_MAPBOX_TOKEN_HERE为您提供FeatureCollection个对象的一个​​Feature。循环浏览每个Feature以查看其type属性是否为hospitalbank等。>

https://imgur.com/UmsdOOY

关于使用设备的位置用于Tilequery请求:

LocationComponent所示设置https://docs.mapbox.com/android/maps/examples/show-a-users-location。然后,您可以执行以下操作以获取设备位置:

locationComponent.getLastKnownLocation().getLatitude();
locationComponent.getLastKnownLocation().getLongitude();

或者如果您需要跟踪设备位置:

https://docs.mapbox.com/help/tutorials/android-location-listening

https://docs.mapbox.com/android/maps/examples/location-change-listening

© www.soinside.com 2019 - 2024. All rights reserved.