2014-04-01 65 views
1

我已經執行谷歌地圖找到位置和我目前的位置..位置和我目前的位置顯示良好。但我目前的位置表示由藍點(默認),我想定製。我知道它會被標記完成,但沒有工作,那麼...... 這裏是我的代碼..Android谷歌地圖定製我的當前位置

private void initilizeMap() { 
     if (googleMap == null) { 
      googleMap = ((MapFragment) getFragmentManager().findFragmentById(
        R.id.map)).getMap(); 

      googleMap.getUiSettings().setCompassEnabled(false); 
      googleMap.getUiSettings().setRotateGesturesEnabled(true); 
      googleMap.setMyLocationEnabled(true); 
      googleMap.getUiSettings().setMyLocationButtonEnabled(true); 

      MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Target Location + "+ latitude+" +"+longitude); 
      marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)); 
     // adding marker 
      googleMap.addMarker(marker); 
      Location myLocation = googleMap.getMyLocation(); 
      if(myLocation!=null) 
      { 
       double dLatitude = myLocation.getLatitude(); 
       double dLongitude = myLocation.getLongitude(); 
       Log.i("APPLICATION"," : "+dLatitude); 
       Log.i("APPLICATION"," : "+dLongitude); 
       googleMap.addMarker(new MarkerOptions().position(
         new LatLng(dLatitude, dLongitude)).title("My Location").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))); 
       // mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(dLatitude, dLongitude), 8));*/ 

      } 
      else 
      { 
       Toast.makeText(this, "Unable to fetch the current location", Toast.LENGTH_SHORT); 
      } 
      } 
+0

你是否檢查過你的經度和緯度值?記錄您的值。 –

+0

也將您的相機放到您的位置...... googleMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(myLocation .getLatitude(),myLocation.getLongitude()))); –

回答

1

你設置你的新標記的位置,當你初始化地圖。但位置提供商會更新您的位置以找到您的真實位置。所以你應該跟蹤你的位置並更改每次更新的標記位置。

相關問題