本文整理汇总了Java中com.tencent.map.geolocation.TencentLocationRequest类的典型用法代码示例。如果您正苦于以下问题:Java TencentLocationRequest类的具体用法?Java TencentLocationRequest怎么用?Java TencentLocationRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TencentLocationRequest类属于com.tencent.map.geolocation包,在下文中一共展示了TencentLocationRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
private void startLocation() {
mLocationManager = TencentLocationManager.getInstance(this);
mLocationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
mRefreshLayout.post(new Runnable() {
@Override
public void run() {
mRefreshLayout.setRefreshing(true);
}
});
TencentLocationRequest request = TencentLocationRequest.create()
// 设置定位周期
.setInterval(1000)
// 设置定位level
.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA);
int result = mLocationManager.requestLocationUpdates(request, this);
if (result == 0) {
LogUtil.d(TAG, "start location");
} else {
LogUtil.d(TAG, "cannot start location! error: " + result);
}
}
示例2: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation(View view) {
// 创建定位请求
TencentLocationRequest request = TencentLocationRequest.create();
// 修改定位请求参数, 定位周期 3000 ms
request.setInterval(3000);
Looper otherLooper = mThread.getLooper();
if (mIndex == BG_THREAD) {
// 开始定位, 在 mThread 线程中
mLocationManager.requestLocationUpdates(request, this, otherLooper);
} else if (mIndex == MAIN_THREAD) {
// 开始定位, 在主线程中
mLocationManager.requestLocationUpdates(request, this);
}
updateLocationStatus("开始定位: " + request + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType()));
}
示例3: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation(View view) {
if (!mStarted) {
mStarted = true;
// 创建定位请求
TencentLocationRequest request = TencentLocationRequest
.create()
.setRequestLevel(
TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA)
.setInterval(mInterval); // 设置定位周期, 建议值为 1s-20s
// 开始定位
mLocationManager.requestLocationUpdates(request, this);
updateLocationStatus("开始定位: " + request + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType()));
}
}
示例4: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation(View view) {
// 创建定位请求
final TencentLocationRequest request = TencentLocationRequest.create();
// 修改定位请求参数, 定位周期 3000 ms
request.setInterval(3000);
// 在 mThread 线程发起定位
mHandler.post(new Runnable() {
@Override
public void run() {
mLocationManager.requestLocationUpdates(request,
DemoThreadActivity2.this);
}
});
updateLocationStatus("开始定位: " + request + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType()));
}
示例5: initView
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
@Override
public void initView() {
mBtnToolbarSend.setVisibility(View.VISIBLE);
setRlMapHeight(maxHeight);
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mOritationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
mLocationManager = TencentLocationManager.getInstance(this);
mLocationRequest = TencentLocationRequest.create();
mTencentMap = mMap.getMap();
mTencentSearch = new TencentSearch(this);
}
示例6: getDefaultLocationRequest
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public static TencentLocationRequest getDefaultLocationRequest(){
if(locationRequest == null){
// 请求的位置信息包括经纬度,位置所处的中国大陆行政区划(REQUEST_LEVEL_ADMIN_AREA)
return TencentLocationRequest.create().setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA);
}
return locationRequest;
}
示例7: onCreate
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TencentLocationRequest request = TencentLocationRequest.create();
TencentLocationManager locationManager = TencentLocationManager
.getInstance(this);
int error = locationManager.requestLocationUpdates(request, this);
Log.i("test",
"MainActivity, onCreate, locationManager.requestLocationUpdates returns "
+ error);
}
示例8: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation() {
TencentLocationRequest request = TencentLocationRequest.create();
request.setInterval(1000);
int errorNo = mLocationManager.requestLocationUpdates(request, this);
if (errorNo == 2) {
System.out.println("Key����ȷ�����������ã�");
}
}
示例9: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation(View view) {
// 创建定位请求
TencentLocationRequest request = TencentLocationRequest.create()
.setInterval(5000) // 设置定位周期
.setRequestLevel(mLevel); // 设置定位level
// 开始定位
mLocationManager.requestLocationUpdates(request, this);
updateLocationStatus("开始定位: " + request + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType()));
}
示例10: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
private void startLocation() {
TencentLocationRequest request = TencentLocationRequest.create();
request.setInterval(5000);
mLocationManager.requestLocationUpdates(request, this);
mRequestParams = request.toString() + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType());
}
示例11: onCreate
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_direction);
mStatus = (TextView) findViewById(R.id.status);
mView = (DirectionView) findViewById(R.id.dir);
mLocationManager = TencentLocationManager.getInstance(this);
mLocationManager.requestLocationUpdates(TencentLocationRequest.create()
.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO)
.setInterval(500).setAllowDirection(true), this);
}
示例12: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation(View view) {
// 创建定位请求
TencentLocationRequest request = TencentLocationRequest.create();
// 修改定位请求参数, 周期为 5000 ms
request.setInterval(5000);
// 开始定位
mLocationManager.requestLocationUpdates(request, this);
updateLocationStatus("开始定位: " + request + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType()));
}
示例13: start
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void start(Runnable r) {
if (!mStarted) {
mStarted = true;
mTmp = r;
TencentLocationRequest request = TencentLocationRequest.create()
.setInterval(5000)
.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO);
TencentLocationManager.getInstance(mContext)
.requestLocationUpdates(request, this);
}
}
示例14: startLocation
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
public void startLocation(View view) {
// 创建定位请求
TencentLocationRequest request = TencentLocationRequest.create();
// 修改定位请求参数, 定位周期 3000 ms
request.setInterval(3000);
// 开始定位
mLocationManager.requestLocationUpdates(request, this);
updateLocationStatus("开始定位: " + request + ", 坐标系="
+ DemoUtils.toString(mLocationManager.getCoordinateType()));
}
示例15: toString
import com.tencent.map.geolocation.TencentLocationRequest; //导入依赖的package包/类
private static String toString(TencentLocation location, int level) {
StringBuilder sb = new StringBuilder();
sb.append("latitude=").append(location.getLatitude()).append(",");
sb.append("longitude=").append(location.getLongitude()).append(",");
sb.append("altitude=").append(location.getAltitude()).append(",");
sb.append("accuracy=").append(location.getAccuracy()).append(",");
switch (level) {
case TencentLocationRequest.REQUEST_LEVEL_GEO:
break;
case TencentLocationRequest.REQUEST_LEVEL_NAME:
sb.append("name=").append(location.getName()).append(",");
sb.append("address=").append(location.getAddress()).append(",");
break;
case TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA:
case TencentLocationRequest.REQUEST_LEVEL_POI:
case 7:
sb.append("nation=").append(location.getNation()).append(",");
sb.append("province=").append(location.getProvince()).append(",");
sb.append("city=").append(location.getCity()).append(",");
sb.append("district=").append(location.getDistrict()).append(",");
sb.append("town=").append(location.getTown()).append(",");
sb.append("village=").append(location.getVillage()).append(",");
sb.append("street=").append(location.getStreet()).append(",");
sb.append("streetNo=").append(location.getStreetNo()).append(",");
if (level == TencentLocationRequest.REQUEST_LEVEL_POI) {
List<TencentPoi> poiList = location.getPoiList();
int size = poiList.size();
for (int i = 0, limit = 3; i < limit && i < size; i++) {
sb.append("\n");
sb.append("poi[" + i + "]=")
.append(toString(poiList.get(i))).append(",");
}
}
break;
default:
break;
}
return sb.toString();
}