Home > Mobile >  Android studio positioning applications
Android studio positioning applications

Time:10-31

How to do? Detail, small white answer,

CodePudding user response:

His butt Scott map location SDK

CodePudding user response:

Integrated baidu map SDK to also go,

CodePudding user response:

Can be integrated gold map
As follows:
AMapLocationClientOption mLocationOption=new AMapLocationClientOption ();
//declare AMapLocationClient class object
Public AMapLocationClient mLocationClient=null;

/* *
* gold positioning
*/
Private void initLocation () {
//initialize the positioning
MLocationClient=new AMapLocationClient (getApplicationContext ());
//set the orientation correction to monitor
MLocationClient. SetLocationListener (mLocationListener);
//set the positioning mode to AMapLocationMode Hight_Accuracy, high precision model,
MLocationOption. SetLocationMode (AMapLocationClientOption. AMapLocationMode. Hight_Accuracy);
/* *
* scenes, the establishment of the current support three scenarios (check-in, travel, sports, the default no scenario)
*/
//mLocationOption. SetLocationPurpose (AMapLocationClientOption. AMapLocationPurpose.. SignIn);
//get a positioning results:
//this method is the default value is false,
MLocationOption. SetOnceLocation (true);

//get the recent within 3 s highest precision positioning results:
//set setOnceLocationLatest (Boolean b) interface to true, starts the positioning the SDK will return within 3 s highest precision latest positioning as a result, if set to true, setOnceLocation (Boolean b) interface can be set to true, and will not, the default is false,
MLocationOption. SetOnceLocationLatest (true);
MLocationOption. SetNeedAddress (true);
if (null !={mLocationClient)
//to locate the client object set parameter
MLocationClient. SetLocationOption (mLocationOption);
//start positioning
MLocationClient. StartLocation ();
}

}


//declare positioning callback listener
Public AMapLocationListener mLocationListener=new AMapLocationListener () {
@ Override
Public void onLocationChanged (AMapLocation AMapLocation) {
If (amapLocation!=null) {
If (amapLocation getErrorCode ()==0) {
//analytical amapLocation can obtain corresponding content,
AmapLocation. GetLocationType ();//get the current source location results, such as network positioning results, see the location type list
AmapLocation. GetLatitude ();//get latitude
AmapLocation. GetLongitude ();//get longitude
AmapLocation. GetAccuracy ();//for accuracy of information
AmapLocation. GetAddress ();//address, if the option of setting isNeedAddress to false, is not the result, can have the address information, network positioning results of GPS positioning does not return address information,
AmapLocation. GetCountry ();//state information
AmapLocation. GetProvince ();//province information
AmapLocation. GetCity ();//city information
AmapLocation. GetDistrict ();//the city information
AmapLocation. GetStreet ();//the street information
AmapLocation. GetStreetNum ();/street/house number information
AmapLocation. GetCityCode ();//city code
AmapLocation. GetAdCode ();//area code
AmapLocation. GetAoiName ();//get the current anchor point of AOI information
AmapLocation. GetBuildingId ();//get the current indoor positioning buildings Id
AmapLocation. GetFloor ();//get the current indoor location floor
AmapLocation. GetGpsAccuracyStatus ();//get the current state of the GPS
MLocationClient. StopLocation ();//stop the localization, the local location services will not be destroyed
MLocationClient. OnDestroy ();//destruction of positioning the client, destroy local positioning service at the same time,
MCityCode=amapLocation. GetCityCode ();
MAdCode=amapLocation. GetAdCode ();
MCityAddress=amapLocation. GetDistrict ();
EventBus. GetDefault (). The post (new EventBusModel (" city_location "));
Logger. V (" positioning results source: "+ amapLocation. GetConScenario () +" -- -- -- \ n accuracy information: "+ amapLocation. GetAccuracy () +" - \ n city information: "+ amapLocation. GetCity () +" - \ n city information: "+ amapLocation. GetDistrict () +" -- -- -- -- -- - \ n the street information: "+ amapLocation. GetStreet () +" - \ n apartment information: "+ amapLocation. GetStreetNum () +" - \ n city code: "+ amapLocation. GetCityCode () +" -- -- -- -- -- \ n region code: "+ amapLocation. GetAdCode () +" -- -- -- -- -- \ n current indoor positioning of the floor: "+ amapLocation. GetFloor () +" -- -- -- -- -- - \ n indoor positioning buildings Id: "+ amapLocation. GetBuildingId ());
} else {
//positioning failure, can pass ErrCode (error code) information to determine the cause of the failure, errInfo is wrong information, see the error codes,
The e (" AmapError ", "the location Error, ErrCode:"
+ amapLocation. GetErrorCode () + ", errInfo:
"+ amapLocation. GetErrorInfo ());
}
}
}
};

Can locate, get all the data you want
  • Related