【发布时间】:2018-07-23 15:10:15
【问题描述】:
我正在制作一个应用程序,当它打开时,它会显示用户的当前位置。问题是我还想通过按下标记来输入所有详细信息(家庭地址、邮政编码、国家),就像这样应用 Application Photo
代码:
private GoogleMap mMap;
private GoogleApiClient googleApiClient;
private LocationRequest locationRequest;
private Location lastLocation;
private Marker currentUserLocationMarker;
这是包含标记的方法
@Override
public void onLocationChanged(Location location) {
lastLocation=location;
if(currentUserLocationMarker!=null)
{
currentUserLocationMarker.remove();
}
LatLng latLng= new LatLng(location.getLatitude(),location.getLongitude());
MarkerOptions markerOptions= new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Test");
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_marker_mini));
currentUserLocationMarker = mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomBy(15));
if(googleApiClient != null)
{
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient,this);
}
}
【问题讨论】: