/** 设置页面监听 */ private void setUpMap() { Button searButton = (Button) findViewById(R.id.searchButton); searButton.setOnClickListener(this); Button nextButton = (Button) findViewById(R.id.nextButton); nextButton.setOnClickListener(this); searchText = (AutoCompleteTextView) findViewById(R.id.keyWord); searchText.addTextChangedListener(this); // 添加文本输入框监听事件 editCity = (EditText) findViewById(R.id.city); aMap.setOnMarkerClickListener(this); // 添加点击marker监听事件 aMap.setInfoWindowAdapter(this); // 添加显示infowindow监听事件 }
/** 设置地图 */ private void setUpMap() { mMap.setOnMarkerClickListener(this); // 设置点击marker事件监听器 mMap.setInfoWindowAdapter(this); mMap.setOnInfoWindowClickListener(this); // 设置点击infoWindow事件监听器 mMap.setOnMapLoadedListener(this); // 设置map载入成功事件监听器 mMap.setOnCameraChangeListener(this); routeSearch = new RouteSearch(getActivity()); routeSearch.setRouteSearchListener(this); setLocation(); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[0], 17.904732f)); startTextView = (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_start); startTextView.setFocusable(false); endTextView = (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_goals); endTextView.setFocusable(false); routeSearchImagebtn = (ImageButton) schoolView.findViewById(R.id.imagebtn_roadsearch_search); routeSearchImagebtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { strStart = startTextView.getText().toString().trim(); strEnd = endTextView.getText().toString().trim(); if (strStart == null || strStart.length() == 0) { Toast.makeText(getActivity(), "请选择起点", Toast.LENGTH_SHORT).show(); return; } if (strEnd == null || strEnd.length() == 0) { Toast.makeText(getActivity(), "请选择终点", Toast.LENGTH_SHORT).show(); return; } if (startPoint != null && endPoint != null) { if (NetworkUtils.isConnect(getActivity())) { progDialog = ProgressDialog.show(getActivity(), null, "正在搜索", true, true); searchRoute(); } else { Toast.makeText(getActivity(), "亲,请检查网络连接", Toast.LENGTH_SHORT).show(); } // searchRouteResult(startPoint, endPoint); } } }); }