Java源码示例:com.amap.api.services.geocoder.RegeocodeQuery
示例1
/**
* 响应逆地理编码的批量请求
*/
private void getAddresses() {
List<LatLonPoint> geopointlist = readLatLonPoints();
for (final LatLonPoint point : geopointlist) {
ThreadUtil.getInstance().execute(new Runnable() {
@Override
public void run() {
try {
RegeocodeQuery query = new RegeocodeQuery(point, 200,
GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
RegeocodeAddress result = geocoderSearch.getFromLocation(query);// 设置同步逆地理编码请求
if (result != null && result.getFormatAddress() != null) {
aMap.addMarker(new MarkerOptions()
.position(new LatLng(point.getLatitude(), point.getLongitude()))
.title(result.getFormatAddress()));
}
} catch (AMapException e) {
Message msg = msgHandler.obtainMessage();
msg.arg1 = e.getErrorCode();
msgHandler.sendMessage(msg);
}
}
});
}
}
示例2
/**
* 响应逆地理编码
*/
public void getAddress(final LatLonPoint latLonPoint) {
showDialog();
RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200,
GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
geocoderSearch.getFromLocationAsyn(query);// 设置异步逆地理编码请求
}
示例3
@Override
public void onMyLocationChange(Location location) {
LogUtil.e(TAG, "onMyLocationChange");
GeocodeSearch geocoderSearch = new GeocodeSearch(getContext());
geocoderSearch.setOnGeocodeSearchListener(this);
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
aMap.moveCamera(CameraUpdateFactory.changeLatLng(latLng));
LatLonPoint latLonPoint = new LatLonPoint(location.getLatitude(), location.getLongitude());
RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 10000, GeocodeSearch.AMAP);
geocoderSearch.getFromLocationAsyn(query);
}
示例4
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
LatLonPoint point = new LatLonPoint(cameraPosition.target.latitude, cameraPosition.target.longitude);
RegeocodeQuery query = new RegeocodeQuery(point, 50, GeocodeSearch.AMAP);
geocodeSearch.getFromLocationAsyn(query);
if (centerMarker != null) {
animMarker();
}
showLocationView();
}
示例5
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
LatLonPoint point = new LatLonPoint(cameraPosition.target.latitude, cameraPosition.target.longitude);
RegeocodeQuery query = new RegeocodeQuery(point, 50, GeocodeSearch.AMAP);
geocodeSearch.getFromLocationAsyn(query);
if (centerMarker != null) {
animMarker();
}
showLocationView();
}
示例6
@Override
protected void onCreate(WriteActivity view, Bundle savedState) {
super.onCreate(view, savedState);
provider = new ImageProvider(getView());
mGeocoderSearch = new GeocodeSearch(getView());
mGeocoderSearch.setOnGeocodeSearchListener(this);
location = LocationModel.getInstance().getCurLocation();
if (location != null) {
mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(location.getLatitude(), location.getLongitude()), 50, GeocodeSearch.AMAP));
}
}
示例7
private void initMyPoint() {
Location location = LocationModel.getInstance().getCurLocation();
moveTo(location.getLatitude(), location.getLongitude(), 13);
mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(location.getLatitude(), location.getLongitude()), 50, GeocodeSearch.AMAP));
MarkerOptions markerOption = new MarkerOptions();
markerOption.icon(BitmapDescriptorFactory
.fromResource(R.drawable.location_marker));
mMyLocation = aMap.addMarker(markerOption);
mPoint = new LatLng(location.getLatitude(),location.getLongitude());
LocationModel.getInstance().registerLocationChange(newLocation -> mMyLocation.setPosition(new LatLng(location.latitude,location.longitude)));
}
示例8
@Override
public void onMapClick(LatLng latLng) {
if (mLastMarker != null) mLastMarker.destroy();
mPoint = latLng;
MarkerOptions markerOption = new MarkerOptions();
markerOption.position(latLng);
markerOption.icon(BitmapDescriptorFactory
.fromResource(R.drawable.location_point_bigger_red));
mLastMarker = aMap.addMarker(markerOption);
mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(latLng.latitude,latLng.longitude), 50,GeocodeSearch.AMAP));
}
示例9
@Override
public boolean onMarkerClick(Marker marker) {
if (marker.equals(mMyLocation)){
if (mLastMarker != null) mLastMarker.destroy();
mPoint = marker.getPosition();
mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(marker.getPosition().latitude,marker.getPosition().longitude), 50,GeocodeSearch.AMAP));
}
return true;
}
示例10
private void coordinateConvertToGeo(Coordinate coordinate) {
RegeocodeQuery query = new RegeocodeQuery(new LatLonPoint(coordinate.latitude, coordinate.longitude), 200, GeocodeSearch.AMAP);
geocoderSearch.getFromLocationAsyn(query);
}
示例11
private void searchLocationsName(LatLng latLng) {
oldLocation = latLng;
LatLonPoint point = new LatLonPoint(latLng.latitude, latLng.longitude);
RegeocodeQuery query = new RegeocodeQuery(point, 1000, GeocodeSearch.AMAP);
geocodeSearch.getFromLocationAsyn(query);
}
示例12
public void search(double latitude, double longitude) {
RegeocodeQuery regecodeQuery = new RegeocodeQuery(new LatLonPoint(
latitude, longitude), SEARCH_RADIUS, GeocodeSearch.AMAP);
mGeocodeSearch.getFromLocationAsyn(regecodeQuery);
}
示例13
private void geocodeAddress() {
if (mSearchLatLonPoint == null) return;
RegeocodeQuery query = new RegeocodeQuery(mSearchLatLonPoint, 2000, GeocodeSearch.AMAP);
mGeocodeSearch.getFromLocationAsyn(query);
}