com.amap.api.services.geocoder.GeocodeSearch Java Examples

The following examples show how to use com.amap.api.services.geocoder.GeocodeSearch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 6 votes vote down vote up
private void initMap() {
    aMap = mMapView.getMap();
    mUiSettings = aMap.getUiSettings();
    mUiSettings.setZoomControlsEnabled(false);
    mUiSettings.setScaleControlsEnabled(true);
    mUiSettings.setMyLocationButtonEnabled(false);

    //焊死位置,未得许可不能更改
    if (canSelect||AccountModel.getInstance().checkIsSuper()){
        aMap.setOnMapClickListener(this);
    }
    aMap.setOnMarkerClickListener(this);
    mGeocoderSearch = new GeocodeSearch(this);
    mGeocoderSearch.setOnGeocodeSearchListener(this);
    initMyPoint();
}
 
Example #2
Source File: ReGeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 初始化AMap对象
 */
private void init() {
	if (aMap == null) {
		aMap = mapView.getMap();
		regeoMarker = aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
				.icon(BitmapDescriptorFactory
						.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
		aMap.setOnMarkerClickListener(this);
	}
	Button regeoButton = (Button) findViewById(R.id.geoButton);
	Button regeoButton_ = (Button)findViewById(R.id.regeoButton);
	regeoButton.setText("ResGeoCoding(39.90865,116.39751)");
	regeoButton.setOnClickListener(this);
	regeoButton_.setVisibility(View.VISIBLE);
	regeoButton_.setText("逆地理编码同步方法(线程池)");
	regeoButton_.setOnClickListener(this);
	geocoderSearch = new GeocodeSearch(this);
	geocoderSearch.setOnGeocodeSearchListener(this);
	progDialog = new ProgressDialog(this);
}
 
Example #3
Source File: ReGeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 响应逆地理编码的批量请求
 */
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);
				}
			}
		});
	}
}
 
Example #4
Source File: AmapActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
private void initAmap() {
        if (aMap == null) {
            aMap = mapView.getMap();
        }
        aMap.setLocationSource(this);// 设置定位监听
        aMap.setMyLocationEnabled(true);
        aMap.getUiSettings().setZoomControlsEnabled(false);

//        aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
        CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(15);
        aMap.moveCamera(cameraUpdate);

        movingDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.icon_loaction_choose_moving);
        chooseDescripter = BitmapDescriptorFactory.fromResource(R.drawable.icon_loaction_choose);
        successDescripter = BitmapDescriptorFactory.fromResource(R.drawable.icon_usecarnow_position_succeed);

        geocodeSearch = new GeocodeSearch(this);
        geocodeSearch.setOnGeocodeSearchListener(this);
    }
 
Example #5
Source File: AutoScheduleAssistFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
/**
 * 由城市名查询地理位置
 * @param address 地址
 * @param name 城市名字
 */
private void doSearchGeo(String address, String name) {
    GeocodeSearch geocoderSearch = new GeocodeSearch(getContext());
    geocoderSearch.setOnGeocodeSearchListener(this);
    GeocodeQuery query = new GeocodeQuery(address, name);
    geocoderSearch.getFromLocationNameAsyn(query);
}
 
Example #6
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@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));
}
 
Example #7
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
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)));
}
 
Example #8
Source File: WritePresenter.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@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));
    }
}
 
Example #9
Source File: AmapActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
@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();
}
 
Example #10
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
@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();
}
 
Example #11
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
private void initAmap() {
    if (aMap == null) {
        aMap = mapView.getMap();
    }

    if (getIntent().hasExtra("location")) {
        isPerview = true;
        mMsg = getIntent().getParcelableExtra("location");
        tvCurLocation.setVisibility(View.GONE);
        returns.setVisibility(View.GONE);

        if (model) {
            CameraPosition location = new CameraPosition.Builder()
                    .target(new LatLng(mMsg.getLat(), mMsg.getLng())).zoom(18).bearing(0).tilt(30).build();
            show(location);
        } else {
            aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
                    .position(new LatLng(mMsg.getLat(), mMsg.getLng())).title(mMsg.getPoi())
                    .snippet(mMsg.getLat() + "," + mMsg.getLng()).draggable(false));
        }
        return;
    }


    aMap.setLocationSource(this);// 设置定位监听
    aMap.setMyLocationEnabled(true);
    aMap.getUiSettings().setZoomControlsEnabled(false);
    aMap.getUiSettings().setMyLocationButtonEnabled(false);
    CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(15);//设置缩放监听
    aMap.moveCamera(cameraUpdate);

    successDescripter = BitmapDescriptorFactory.fromResource(R.drawable.icon_usecarnow_position_succeed);
    geocodeSearch = new GeocodeSearch(this);
    geocodeSearch.setOnGeocodeSearchListener(this);
}
 
Example #12
Source File: AmapWrapper.java    From RunMap with Apache License 2.0 5 votes vote down vote up
public AmapWrapper(AMap aMap){
    this.mAmap = aMap;
    mAmapStateListener = new AMapStateListenerImpl();
    mGeocodeSearch = new GeocodeSearch(GlobalApplication.getAppContext());
    mMapDrawer = new MapDrawer(mAmap);
    initLocationOptions();
    initLocationClient();
}
 
Example #13
Source File: AutoScheduleAssistFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #15
Source File: ReGeocoderActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 响应逆地理编码
 */
public void getAddress(final LatLonPoint latLonPoint) {
	showDialog();
	RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200,
			GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
	geocoderSearch.getFromLocationAsyn(query);// 设置异步逆地理编码请求
}
 
Example #16
Source File: GeocoderActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 初始化AMap对象
 */
private void init() {
	if (aMap == null) {
		aMap = mapView.getMap();
		geoMarker = aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
				.icon(BitmapDescriptorFactory
						.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
	}
	Button geoButton = (Button) findViewById(R.id.geoButton);
	geoButton.setText("GeoCoding(北京市朝阳区方恒国际中心A座)");
	geoButton.setOnClickListener(this);
	geocoderSearch = new GeocodeSearch(this);
	geocoderSearch.setOnGeocodeSearchListener(this);
	progDialog = new ProgressDialog(this);
}
 
Example #17
Source File: FlutterAMapConvertRegister.java    From flutter_amap_plugin with MIT License 5 votes vote down vote up
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
    geocoderSearch = new GeocodeSearch(FlutterAmapPlugin.registrar.activity().getApplicationContext());
    geocoderSearch.setOnGeocodeSearchListener(this);
    if (methodCall.method.equals("geoToCoordinate")) {
        if (methodCall.arguments instanceof String) {
            geoConvertToCoordinate(methodCall.arguments.toString());
        }
    } else if (methodCall.method.equals("coordinateToGeo")) {
        if (methodCall.arguments instanceof String) {
            Coordinate model = new Gson().fromJson(methodCall.arguments.toString(), Coordinate.class);
            coordinateConvertToGeo(model);
        }
    }
}
 
Example #18
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_map);

    ActionBar actionBar = getActionBar();
    if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true);

    mMapView = findViewById(R.id.map_view);
    mMapView.onCreate(savedInstanceState);

    mListView = findViewById(R.id.list_view);
    mTvPrompt = findViewById(R.id.tv_prompt);
    mSearchResultAdapter = new SearchResultAdapter(this);
    mListView.setAdapter(mSearchResultAdapter);
    mListView.setOnItemClickListener(this);

    mAMap = mMapView.getMap();

    mAMap.getUiSettings().setZoomControlsEnabled(false);
    mAMap.setLocationSource(this);
    mAMap.getUiSettings().setMyLocationButtonEnabled(true);
    mAMap.setMyLocationEnabled(true);

    mAMap.setOnCameraChangeListener(new MyOnCameraChangeListener());
    mAMap.setOnMapLoadedListener(new MyOnMapLoadedListener());

    mGeocodeSearch = new GeocodeSearch(getApplicationContext());
    mGeocodeSearch.setOnGeocodeSearchListener(new MyOnGeocodeSearchListener());

    // 请求权限
    PermissionUtil.requestPermissions(this,
            new String[] {
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.ACCESS_FINE_LOCATION},
            99);
}
 
Example #19
Source File: RegeocodeTask.java    From Android_UsingCar_Example with Apache License 2.0 4 votes vote down vote up
public void search(double latitude, double longitude) {
	RegeocodeQuery regecodeQuery = new RegeocodeQuery(new LatLonPoint(
			latitude, longitude), SEARCH_RADIUS, GeocodeSearch.AMAP);
	mGeocodeSearch.getFromLocationAsyn(regecodeQuery);
}
 
Example #20
Source File: RegeocodeTask.java    From Android_UsingCar_Example with Apache License 2.0 4 votes vote down vote up
public RegeocodeTask(Context context) {
	mGeocodeSearch = new GeocodeSearch(context);
	mGeocodeSearch.setOnGeocodeSearchListener(this);
}
 
Example #21
Source File: LocationActivity.java    From Socket.io-FLSocketIM-Android with MIT License 4 votes vote down vote up
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);
}
 
Example #22
Source File: FlutterAMapConvertRegister.java    From flutter_amap_plugin with MIT License 4 votes vote down vote up
private void coordinateConvertToGeo(Coordinate coordinate) {
    RegeocodeQuery query = new RegeocodeQuery(new LatLonPoint(coordinate.latitude, coordinate.longitude), 200, GeocodeSearch.AMAP);
    geocoderSearch.getFromLocationAsyn(query);
}
 
Example #23
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 3 votes vote down vote up
private void geocodeAddress() {

        if (mSearchLatLonPoint == null) return;

        RegeocodeQuery query = new RegeocodeQuery(mSearchLatLonPoint, 2000, GeocodeSearch.AMAP);
        mGeocodeSearch.getFromLocationAsyn(query);
    }