use of com.litingzhe.justandroid.ui.mapView.adapter.HorizontalListViewAdapter in project JustAndroid by chinaltz.
the class MapActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activitty_nearbypark);
ButterKnife.bind(this);
isFirstInitMap = true;
mContext = this;
navTitle.setText("地图相关导航");
String[] titles = { "新街口", "夫子庙", "百家湖", "河西万达" };
hotAreaList = new ArrayList();
LatLng xinjiekouLatlng = new LatLng(32.0414637353, 118.7851165312);
LatLng fuzimiaoLatlng = new LatLng(32.0206226446, 118.7889921341);
LatLng baijiahuLatlng = new LatLng(31.9319650736, 118.8212252856);
LatLng hexiLatlng = new LatLng(32.0328683928, 118.7360117294);
hotAreaList.add(xinjiekouLatlng);
hotAreaList.add(fuzimiaoLatlng);
hotAreaList.add(baijiahuLatlng);
hotAreaList.add(hexiLatlng);
hListViewAdapter = new HorizontalListViewAdapter(getApplicationContext(), titles);
horizontalListView.setAdapter(hListViewAdapter);
horizontalListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
hListViewAdapter.setSelectIndex(position);
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom((LatLng) hotAreaList.get(position), 14));
addMarkersToMap((LatLng) hotAreaList.get(position), position + 1);
}
});
// 此方法必须重写
mapView.onCreate(savedInstanceState);
if (aMap == null) {
aMap = mapView.getMap();
CameraUpdate mCameraUpdate = CameraUpdateFactory.zoomTo(14);
aMap.moveCamera(mCameraUpdate);
// aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
// aMap.getUiSettings().setCompassEnabled(false);
aMap.getUiSettings().setScaleControlsEnabled(true);
didLocation();
aMap.setOnMarkerClickListener(new AMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
int index = Integer.parseInt(marker.getSnippet());
popupInfo(paopaoView, index);
return true;
}
});
aMap.setOnMapClickListener(new AMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
paopaoView.setVisibility(View.INVISIBLE);
}
});
aMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
}
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
LatLng target = cameraPosition.target;
if (isFirstInitMap) {
isFirstInitMap = false;
} else {
// getNearParkList(target.longitude + "", target.latitude + "");
}
}
});
}
searchEditText.setFocusable(false);
searchEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
locationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
didLocation();
}
});
}
Aggregations