package com.tjzhxx.union.activity;

import android.os.Bundle;

import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;
import com.tjzhxx.union.R;
import com.tjzhxx.union.system.BaseActivity;

import butterknife.BindView;

/**
 * 描述:
 *
 * @author yhx
 * @create 2021/10/9  10:01 AM
 */
public class AddressMapActivity extends BaseActivity {
    @BindView(R.id.map)
    MapView mapView;
    private AMap aMap;
    @Override
    public int getContentViewLayoutID() {
        return R.layout.activity_address_map;
    }

    @Override
    public void bindViewAndEvent(Bundle savedInstanceState) {
        initTitle("位置信息");
        mapView.onCreate(savedInstanceState);
        aMap = mapView.getMap();
        aMap.getUiSettings().setScrollGesturesEnabled(true);
        aMap.getUiSettings().setRotateGesturesEnabled(false);//禁止地图旋转手势.
        aMap.getUiSettings().setTiltGesturesEnabled(false);//禁止倾斜手势.
        LatLng latLng = new LatLng(39.043066, 117.634121);
        aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
        MarkerOptions marker = new MarkerOptions();
        marker.position(latLng);
        aMap.addMarker(marker);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        //在activity执行onDestroy时执行mMapView.onDestroy()，销毁地图
        mapView.onDestroy();
    }

    @Override
    public void onResume() {
        super.onResume();
        //在activity执行onResume时执行mMapView.onResume ()，重新绘制加载地图
        mapView.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
        //在activity执行onPause时执行mMapView.onPause ()，暂停地图的绘制
        mapView.onPause();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState)，保存地图当前的状态
        mapView.onSaveInstanceState(outState);
    }
}
