9

を現在地ボタンを変更することができ、Googleマップでこのアイコンを置き換えるためにどのような方法があります。どのように私はAndroidでそれを行うことができます。は、私は私の希望のアイコンで、このアイコンのボタンを変更したい<br> <img src="https://i.stack.imgur.com/7WnwF.png" alt="My Location Icon"> のように私たちは、Googleマップで現在地アイコンを持っているAndroidのマップで

質問が不明なので、私は追加情報を追加しています。 https://support.google.com/maps/answer/3093609?hl=enであなたもこれらのアイコンを説明する場所シンボルを理解する>アイコンが

すぐ下であなたの、場所にを修正セクションenter image description hereを示されていたセクションのポイント数2にあなたの場所をもとに行き方見ることができます。

これはマーカーではありませんので、私が書いたように位置ボタンです私の質問はどうすればそのアイコン(位置ボタン)を希望のアイコンに変更できますか?

は、このアイコンボタンもGoogleマップのアイコンPICに示されている参照してください enter image description here

+0

[これ](http://stackoverflow.com/questions/14826345/android-maps-api-v2-change-mylocation-icon)あなたのアイコンを変更するのに役立ちます –

+4

誰でもそれをマークしていますあまりにも簡単です答えを提供してくださいそれをマークしてください – Mohit

+0

@SonuRaj myLocationのアイコンを変更しているが、私はマップの右上にあるボタンの形を変更したいとしている – Mohit

答えて

4

はい、あなたは、

私は右下に私の場所のボタンを配置し直すことで、私の地図の断片でこの問題を解決することができます以下のコードを使用してビューのコーナーは、ここに私のMapsActivity.javaです: - :

-

import android.support.v4.app.FragmentActivity; 
import android.os.Bundle; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.RelativeLayout; 

import com.google.android.gms.maps.CameraUpdateFactory; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.OnMapReadyCallback; 
import com.google.android.gms.maps.SupportMapFragment; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.MarkerOptions; 

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 

    private GoogleMap mMap; 
    View mapView; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.fragment_map); 
     // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
     SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
       .findFragmentById(R.id.map); 
     mapView = mapFragment.getView(); 
     mapFragment.getMapAsync(this); 
      } 

    /** 
    * Manipulates the map once available. 
    * This callback is triggered when the map is ready to be used. 
    * This is where we can add markers or lines, add listeners or move the camera. In this case, 
    * we just add a marker near Sydney, Australia. 
    * If Google Play services is not installed on the device, the user will be prompted to install 
    * it inside the SupportMapFragment. This method will only be triggered once the user has 
    * installed Google Play services and returned to the app. 
    */ 
    @Override 
    public void onMapReady(GoogleMap googleMap) { 
     mMap = googleMap; 
     mMap.setMyLocationEnabled(true); 

     // Add a marker in Sydney and move the camera 
     LatLng sydney = new LatLng(-34, 151); 
     mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); 
     mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); 

     if (mapView != null && 
       mapView.findViewById(Integer.parseInt("1")) != null) { 
      // Get the button view 
      View locationButton = ((View) mapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2")); 
      // and next place it, on bottom right (as Google Maps app) 
      RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) 
        locationButton.getLayoutParams(); 
      // position on right bottom 
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); 
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); 
      layoutParams.setMargins(0, 0, 30, 30); 
     } 

    } 
} 

そして、ここでは、フラグメントのレイアウトです

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.infogird.www.location_button_reposition.MapFragment"> 

    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:map="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 
</FrameLayout> 

これがあなたの問題を解決することを願っています。ありがとう。

+0

署名付きapkで動作しますか?デバッグモードでは動作しますが、リリースモードでは動作しません。 – seema

+0

リリースモードで直面している正確な問題は何ですか?マップAPI V2では、リリースバージョンとデバッグバージョンの間で変更されるのは、ここで登録するキーです.code.google.com/apis/consoleデバッグが機能していて、最終リリースがそうでない場合は、必要な変更のみ。だから、私はあなたのリリースキーストアのハッシュコードを再確認し、それがGoogle APIコンソールに正しく入力されていることを確認することをお勧めします。 @seema –

+0

が完了しました。問題は、整数値1を使用していました。Integer.parseInt( "1")に置き換えられました。 – seema

0

コーディング

 ImageView btnMyLocation = (ImageView) ((View) mapFragment.getView().findViewById(1).getParent()).findViewById(2); 
     btnMyLocation.setImageResource(R.mipmap.ic_location_circle); 

     RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) 
       btnMyLocation.getLayoutParams(); 
     // position on right bottom 
     layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); 
     layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); 
     layoutParams.setMargins(0, 0, 30, 30); 

ハッピー..私はそれが返事が遅れている知っているが、このコードは私のために動作します..!

関連する問題