简体   繁体   English

在Android活动中的Google地图上显示位置

[英]Display a location on Google Maps in Android Activity

I'm working on an Android project in which I will need to display the locations of various airports on Google Maps. 我正在开发一个Android项目,我需要在Google地图上显示各个机场的位置。 I already have a list of latitude/longitude coordinates. 我已经有了纬度/经度坐标列表。 My question is: 我的问题是:

How do I get these coordinates to Display as a location in Google Maps on an Android Activity? 如何在Android活动中将这些坐标显示为Google地图中的位置? What classes or other methods should I consider? 我应该考虑哪些类别或其他方法? Are there any templates or tutorials I could look at? 有没有我可以看到的模板或教程? Any help is most appreciated. 任何帮助都非常感谢。

If you already have lat/lng for all required places, you can just use this in a loop for all coordinates: 如果你已经为所有必需的地方都有lat / lng,你可以在所有坐标的循环中使用它:

  LatLng loc = new LatLng(latitude,longitude);
  map.addMarker(new MarkerOptions().position(loc).title("locationName"));

I think you need to use markers on your mapView 我认为你需要在mapView上使用标记

Here you can find the official documentation of the google map api, you'll find it's very easy to add marker on the map. 在这里你可以找到谷歌地图api的官方文档,你会发现它很容易在地图上添加标记。

If you also need to use the current location, I suggest you to read This too. 如果您还需要使用当前位置,我建议您阅读此内容

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

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