【发布时间】:2014-02-12 02:38:59
【问题描述】:
我有一个 android 地图应用程序,它可以跟踪用户位置并将其显示在地图上。我这样做是为了在红色标记的顶部出现一个标题“你在这里”。但是,它并没有自己出现,我必须点击红色标记。我可以点击任何红色标记,标题会移到那里并消失在前一个标记上。
我如何让它只出现在最新的红色标记(最新位置)上并且不能被删除?向用户显示他的当前位置。
我设置的速度为1。我不知道它是否足够好。当我没有移动时,位置停止更新,但它仍然很慢且不准确。
public void onLocationChanged(Location myLocation) {
System.out.println("speed " + myLocation.getSpeed());
if(myLocation.getSpeed() > speed)
{
//show location on map.................
//Get latitude of the current location
double latitude = myLocation.getLatitude();
//Get longitude of the current location
double longitude = myLocation.getLongitude();
//Create a LatLng object for the current location
LatLng latLng = new LatLng(latitude, longitude);
//Show the current location in Google Map
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
//Zoom in the Google Map
googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));
【问题讨论】:
标签: android google-maps