private void initView(Bundle savedInstanceState) { station_mapview.onCreate(savedInstanceState); aMap = station_mapview.getMap(); aMap.setOnMarkerClickListener(this); aMap.setOnMarkerDragListener(this); aMap.setOnMapLoadedListener(this); aMap.setOnCameraChangeListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_poi_map); setupToolBar(); mapView = (MapView) findViewById(R.id.map); mapView.onCreate(savedInstanceState); aMap = mapView.getMap(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 在onCreat方法中给aMap对象赋值 setContentView(R.layout.activity_main); mapView = (MapView) findViewById(R.id.map); mapView.onCreate(savedInstanceState); // 必须要写 aMap = mapView.getMap(); initMap(); initMapButton(); initTitleButton(); }
/** 初始花AMap对象 */ private void initMap() { if (aMap == null) { aMap = mapView.getMap(); } mapUisetting(); mylocationsource = new MyLocationSource(this); aMap.setLocationSource(mylocationsource); // 设置定位资源 aMap.setMyLocationEnabled(true); // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false aMap.setInfoWindowAdapter(this); // 设置自定义InfoWindo 样式 aMap.setOnInfoWindowClickListener(this); // 设置点击infowinfow事件监听器 aMap.setOnMarkerClickListener(this); // 设置点击marker事件监听器 aMap.setOnMapLongClickListener(this); // 长按地图事件监听器 }
/** 初始化AMap对象 */ private void init() { if (aMap == null) { aMap = mapView.getMap(); } CheckBox traffic = (CheckBox) findViewById(R.id.traffic); traffic.setOnClickListener(this); Spinner spinner = (Spinner) findViewById(R.id.layers_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.layers_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); }
/** 初始化AMap对象 */ private void init() { if (aMap == null) { aMap = mapView.getMap(); // aMap.setOnMapClickListener(this); aMap.setOnCameraChangeListener(this); aMap.setOnMarkerClickListener(this); // 添加点击marker监听事件 aMap.setInfoWindowAdapter(this); // 添加显示infowindow监听事件 regeoMarker = aMap.addMarker( new MarkerOptions() .anchor(0.5f, 0.5f) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); } ; geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this); progDialog = new ProgressDialog(this); mListView = (ListView) this.findViewById(R.id.map_listview); mSpinner = (Spinner) this.findViewById(R.id.map_spinner); ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, itemDeep); mSpinner.setAdapter(mAdapter); mSearchAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mSearchList); mListView.setAdapter(mSearchAdapter); mListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String name = mSearchList.get(position); address = address + " - " + name; backToIssue(); } }); addressTv = (TextView) this.findViewById(R.id.gaode_address); }
/** 初始化AMap 对象 */ private void init() { if (aMap == null) { aMap = mapView.getMap(); } }