[英]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.