安卓⾼德地图-(附近信息点Poi与标记Marker2)1.效果图
2.先导⼊jar包,可以去官⽹下载 如图:
特别注意:其中地图和定位还有TabLayout在前⾯详细说过,这⾥就不重复了(所以复制全部会报错~) 2.1.MapDemoActivity:
import android.app.ProgressDialog;
aphics.Color;
import android.support.design.widget.TabLayout;
import android.t.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;position和location的区别
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.del.BitmapDescriptorFactory;
import com.amap.del.LatLng;
import com.amap.del.MarkerOptions;
import com.amap.del.MyLocationStyle;
import com.amap.LatLonPoint;
import com.amap.PoiItem;
import com.amap.api.services.poisearch.PoiResult;
import com.amap.api.services.poisearch.PoiSearch;
import com.helloworld.demo.R;
import com.helloworld.demo.MyAdapter;
import com.helloworld.demo.util.LocationUtils;
import com.helloworld.demo.util.Tools;
import com.helloworld.demo.widget.PermissionsUtils;
public class MapDemoActivity extends AppCompatActivity implements PoiSearch.OnPoiSearchListener, AMapLocationListener {
private static final String TAG = "MapDemoActivity";
private MapView mMapView;
private ListView listView;
private TabLayout tabLayout;
private AMap aMap;
error memory configured incorrectly//判断权限是否打开
private boolean isNeedCheck = true;
private MyLocationStyle myLocationStyle;
compote//声明AMapLocationClient类对象
public AMapLocationClient mLocationClient = null;
//声明AMapLocationClientOption对象
public AMapLocationClientOption mLocationOption = null;
private static final int PERMISSON_REQUESTCODE = 0;
private MyAdapter adapter;
/**
* 查询的类型
*/
private String BANK = "银⾏";
private String DINING_ROOM = "餐厅";
private String PLOT = "⼩区";
private String OFFICE_BUILDINGS = "写字楼";
private String BUS_STATION = "公交站";
private String SUBWAY_STATION = "地铁站";
private String LAVATORY = "厕所";
private String SUPERMARKET = "超市";
/**
* 纬度、经度、城市名
*/
android手机编程appprivate double latitude, longitude;
private String cityName;
private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_map_demo);
mMapView = (MapView) this.findViewById(R.id.map);
listView = (ListView) this.findViewById(R.id.listview);
tabLayout = (TabLayout) this.findViewById(R.id.tablayout);
/
/ 此⽅法须重写,虚拟机需要在很多情况下保存地图绘制的当前状态
ininview();
initLocation();
}
private void ininview() {
tabLayout.wTab().setText(DINING_ROOM));
tabLayout.wTab().setText(BANK));
tabLayout.wTab().setText(PLOT));
tabLayout.wTab().setText(OFFICE_BUILDINGS));
tabLayout.wTab().setText(BUS_STATION));
tabLayout.wTab().setText(SUBWAY_STATION));
tabLayout.wTab().setText(LAVATORY));
tabLayout.wTab().setText(SUPERMARKET));
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
LinearLayout linearLayout = (LinearLayout) ChildAt(0);
linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
linearLayout.Drawable(this, R.drawable.layout_divider_vertical)); linearLayout.setDividerPadding(30);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
int selPosition = Position();
if (selPosition == 0) {
seartchPoiStart(DINING_ROOM);
} else if (selPosition == 1) {
seartchPoiStart(BANK);
} else if (selPosition == 2) {
mysql查询范围语句seartchPoiStart(PLOT);
} else if (selPosition == 3) {
seartchPoiStart(OFFICE_BUILDINGS);
} else if (selPosition == 4) {
seartchPoiStart(BUS_STATION);
} else if (selPosition == 5) {
seartchPoiStart(SUBWAY_STATION);
} else if (selPosition == 6) {
seartchPoiStart(LAVATORY);
} else {
seartchPoiStart(SUPERMARKET);
}
Log.e(TAG, "onTabSelected: " + selPosition);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
微服务指的是什么public void onTabReselected(TabLayout.Tab tab) {
}
});
}
private void initLocation() {
if (aMap == null) {
aMap = Map();
}
aMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
@Override
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论