현재 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);
에
하지만, 난 여전히 내 마커를 찾을 수 없습니다. 자바 코드로
@ Xingchen 시도했지만 여전히 동일합니다. –
레이아웃 파일은 어떻습니까? '단편'에 'class = "com.google.android.gms.maps.SupportMapFragment"가 있습니까? – Xcihnegn
@ Xingchen 예, 있습니다. –