지도는 아래 코드와 함께로드되지만 프로그래밍 방식으로도 상호 작용할 수 있기를 원합니다 (예 : .setMyLocationEnabled() 호출을 통해 내 위치를 설정). 지금까지 시도한 모든 것이 충돌로 이어집니다. 이것은 MainActivity에서 관리되는 단편에 있습니다.조각 내에서 Google지도를 인스턴스화하는 방법은 무엇입니까?
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapFrag extends Fragment {
private GoogleMap map;
public MapFrag(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_map, container, false);
}
}
XML 파일 :
<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="***.fragment">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
</FrameLayout>
가 어떻게와 상호 작용하기 위해 조각에 GoogleMap으로 인스턴스화 할 수 있습니까?