0

현재 Android 앱을 사용하여지도 앱에서 작업 중입니다. 내가 추가 한 마커를 제외한 모든 것이 완벽하게 작동합니다. 저는 공식 가이드 Google Maps Android API v2을 가이드로 사용하고 있지만 맵을로드하려고 할 때 아무 곳에 나 내 마커를 찾을 수 없습니다. 내가 놓친 게 있니?Android Studio -지도 아이콘이 누락되었습니다

여기 내지도 활동이다 :

import android.os.Bundle; 
import com.google.android.gms.maps.*; 
import com.google.android.gms.maps.model.*; 
import com.google.android.gms.maps.GoogleMap; 
import android.support.v4.app.FragmentActivity; 
import com.google.android.gms.maps.OnMapReadyCallback; 
import com.google.android.gms.maps.CameraUpdateFactory; 

public class MapFragment extends FragmentActivity implements OnMapReadyCallback 
{ 
    private SupportMapFragment sMapFragment; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.map_layout); 

     sMapFragment = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)); 
     sMapFragment.getMapAsync(this); 
    } 

    @Override 
    public void onMapReady(GoogleMap mMap) 
    { 
     LatLng one = new LatLng(10.178, 122.560); 
     LatLng ILOILO = new LatLng(10.730278, 122.548889); 

     mMap.setBuildingsEnabled(true); 
     mMap.setMyLocationEnabled(true); 
     mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); 
     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ILOILO, 12)); 

     mMap.addMarker(new MarkerOptions() 
      .title("Empty Lot 1") 
      .snippet("blah blah blah") 
      .position(one) 
      .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); 
    } 
} 

그리고 여기 내 map_layout입니다 :

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

편집

나는 또한 private SupportMapFragment sMapFragment;을 제거하고 내

 sMapFragment = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)); 
     sMapFragment.getMapAsync(this); 
을 변경하려고했습니다

 SupportMapFragment sMapFragment = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)); 
     sMapFragment.getMapAsync(this); 

하지만, 난 여전히 내 마커를 찾을 수 없습니다. 자바 코드로

+0

@ Xingchen 시도했지만 여전히 동일합니다. –

+0

레이아웃 파일은 어떻습니까? '단편'에 'class = "com.google.android.gms.maps.SupportMapFragment"가 있습니까? – Xcihnegn

+0

@ Xingchen 예, 있습니다. –

답변

0

잘 보인다 ..이 도움이 될

xmlns:map="http://schemas.android.com/apk/res-auto" 
android:name="com.google.android.gms.maps.SupportMapFragment" 

희망 onMapReadyCallback 청취자의 구글 문서에 따라 당신의 XML 파일을 편집하십시오!

+0

감사합니다! Btw, 일식과 함께 일할 때와 달리 줌 제한이있는 것으로 보입니다. –

0

기기의 위치 서비스가 사용 설정되어 있는지 확인하는 것도 좋은 방법입니다. 해결책을 찾기 위해 몇 시간을 낭비했고 결국 내 위치 서비스가 활성화되지 않았 음을 발견했습니다!

관련 문제