private RouteResult queryBusRoute(RouteQuery routeQuery) throws AMapException { final RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(routeQuery.getStartPoint(), routeQuery.getEndPoint()); final int busMode = routeQuery.getMode(); if (DEBUG) { Log.d("DirectionsInteractor", "queryBusRoute busMode:" + busMode); } RegeocodeQuery regeocodeQuery = new RegeocodeQuery(routeQuery.getStartPoint(), 200, GeocodeSearch.AMAP); GeocodeSearch geocodeSearch = new GeocodeSearch(mContext); BusRouteResult busRouteResult = null; // 反查出地理地址,用于获取城市 RegeocodeAddress regeocodeAddress = geocodeSearch.getFromLocation(regeocodeQuery); String cityName = CommonUtils.isStringEmpty(regeocodeAddress.getCity()) ? regeocodeAddress.getProvince() : regeocodeAddress.getCity(); RouteSearch.BusRouteQuery query = new RouteSearch.BusRouteQuery( fromAndTo, busMode, cityName, routeQuery.getIncludeNightBus() ? 1 : 0); RouteSearch routeSearch = new RouteSearch(mContext); busRouteResult = routeSearch.calculateBusRoute(query); return busRouteResult; }
/** * 中心点的数据处理 * * @param point */ private void getAddress(LatLng point) { // 0. 设置中心位置 aMap.moveCamera(CameraUpdateFactory.changeLatLng(point)); aMap.moveCamera( CameraUpdateFactory.zoomTo(Integer.valueOf(getString(R.string.default_me_zoomlevel)))); // 1. 清楚地图上的marker aMap.clear(); // 2. 将地理坐标转换为中文地址 mainMarkerLatLng = point; LatLonPoint latLonPoint = new LatLonPoint(point.latitude, point.longitude); GeocodeSearch geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this); // latLonPoint参数表示一个Latlng,第二参数表示范围多少米,GeocodeSearch.AMAP表示是国测局坐标系还是GPS原生坐标系 RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 100, GeocodeSearch.AMAP); geocoderSearch.getFromLocationAsyn(query); // 设置同步逆地理编码请求 // 3. 将坐标发送给服务器, 请求附近的停车场的坐标与停车场的信息 // 初始化url String databaseUrl = null; databaseUrl = ParkingHttp.AddUrlType(databaseUrl, ParkingHttp.JSON_BASE_DATA); databaseUrl = ParkingHttp.AddUrlParms(databaseUrl, ParkingHttp.JSON_LAT, String.valueOf(point.latitude)); databaseUrl = ParkingHttp.AddUrlParms(databaseUrl, ParkingHttp.JSON_LNG, String.valueOf(point.longitude)); databaseUrl = ParkingHttp.AddUrlParms(databaseUrl, ParkingHttp.JSON_RANGE, RANGE_1000); Log.e(TAG, databaseUrl); if (downloadTask != null) Log.e(TAG, String.valueOf(downloadTask.cancel(true))); downloadTask = new DownloadTask(); downloadTask.execute(databaseUrl); // 4. 将这些信息绘制在地图上 }
public void reGeocode(RegeocodeQuery query) { if (aMap != null) { if (geocodeSearch == null) { geocodeSearch = new GeocodeSearch(this); geocodeSearch.setOnGeocodeSearchListener(geocodeSearchListener); } geocodeSearch.getFromLocationAsyn(query); } }
/** 响应地理编码 */ public void getLatlon(final String name, final String city) { showDialog(); GeocodeQuery query = new GeocodeQuery(name, city); // 第一个参数表示地址,第二个参数表示查询城市,中文或者中文全拼,citycode、adcode // 需要控制第2个参数,第2个参数为城市编码。 geocoderSearch.getFromLocationNameAsyn(query); // 设置同步地理编码请求 }
public void getAddress(final LatLonPoint latLonPoint) { RegeocodeQuery query = new RegeocodeQuery( latLonPoint, 200, GeocodeSearch.AMAP); // 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系 geocoderSearch.getFromLocationAsyn(query); // 设置同步逆地理编码请求 }
/** 初始化AMap对象 */ private void init() { tvAddress = (TextView) this.findViewById(R.id.tvAddress); if (aMap == null) { aMap = mapView.getMap(); setUpMap(); } geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(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); }
public void search(double latitude, double longitude) { RegeocodeQuery regecodeQuery = new RegeocodeQuery(new LatLonPoint(latitude, longitude), SEARCH_RADIUS, GeocodeSearch.AMAP); mGeocodeSearch.getFromLocationAsyn(regecodeQuery); }
public RegeocodeTask(Context context) { mGeocodeSearch = new GeocodeSearch(context); mGeocodeSearch.setOnGeocodeSearchListener(this); }