简体   繁体   English

如何在Android地图位置上放置标记?

[英]How to put marker on android map location?

After I find this Location mCurrentLocation = mLocationClient.getLastLocation(); 找到此Location mCurrentLocation = mLocationClient.getLastLocation(); how can I add a marker to that that location? 如何在该位置添加标记?

Making a marker like MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)) requires a position object, is there a way that I can retrieve a position from the Location object? 制作类似MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude))需要一个position对象,有没有办法我可以从Location对象中检索position or is this done in some other way? 还是以其他方式完成?

You can use the getLatitude() and getLongitude() of the Location class which will return double which by then you can pass it in your new LatLong constructor. 您可以使用Location类的getLatitude()getLongitude() ,它们将返回double值,然后您可以将其传递到new LatLong构造函数中。

sample: 样品:

MarkerOptions marker = new MarkerOptions().position(new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()))

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

相关问题 如何在Android中更改位置时在地图上放置标记 - how to put marker on map when location gets changed in android 从Firebase检索位置并将标记放在google map api for android上 - Retrieve location from Firebase and put marker on google map api for android Android如何将地图聚焦在您当前的位置或标记位置 - Android How to focus map on your currently location or marker location 如何在谷歌地图上移动地图,但在Android中将标记保留为当前位置? - how to moves map on google map but keep marker as current location in android? 如何在Android Studio中以字符串形式获取地图标记的位置? - How can I get the location, as a string, of a map marker in Android studio? 如何在中心 - android上使用固定标记搜索拖动地图上的位置 - How to search location on dragging map with fixed marker at center-android 如何在Android地图上更改位置时删除标记并再次重绘 - How to remove Marker and redraw it again when changing location on Android map 如何在Android中的谷歌地图上用标记显示我的当前位置 - how to show my current location with marker on google map in android 从Firebase检索位置并将标记放在Google Map API for Android应用程序上 - Retrieve location from Firebase and put marker on google map api for android application 将布局放在google map标记Android上方 - Put layout above google Map marker Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM