• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TencentLocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.tencent.map.geolocation.TencentLocation的典型用法代码示例。如果您正苦于以下问题:Java TencentLocation类的具体用法?Java TencentLocation怎么用?Java TencentLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TencentLocation类属于com.tencent.map.geolocation包,在下文中一共展示了TencentLocation类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
    if (i == tencentLocation.ERROR_OK) {
        LatLng latLng = new LatLng(tencentLocation.getLatitude(), tencentLocation.getLongitude());
        if (myLocation == null) {
            myLocation = mTencentMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.mipmap.arm)).anchor(0.5f, 0.8f));
        }
        if (accuracy == null) {
            accuracy = mTencentMap.addCircle(new CircleOptions().center(latLng).radius(tencentLocation.getAccuracy()).fillColor(0x440000ff).strokeWidth(0f));
        }
        myLocation.setPosition(latLng);
        accuracy.setCenter(latLng);
        accuracy.setRadius(tencentLocation.getAccuracy());
        mTencentMap.animateTo(latLng);
        mTencentMap.setZoom(16);
        search(latLng);
        //取消定位
        mLocationManager.removeUpdates(MyLocationActivity.this);
    } else {
        LogUtils.sf("location failed:" + i);
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:23,代码来源:MyLocationActivity.java


示例2: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error, String reason) {
    if (error == TencentLocation.ERROR_OK) {
        LogUtil.d(TAG, "location changed" +
            "latitude" + location.getLatitude() +
            "longitude" + location.getLongitude());

        if (!mLoading) {
            mSubscription = loadDataWithLocation(new SimpleLocation(
                location.getCity(),
                location.getDistrict(),
                String.valueOf(location.getLatitude()),
                String.valueOf(location.getLongitude())));
        }
    } else {
        LogUtil.d(TAG, "location failed: " + reason + " code: " + error);
    }
}
 
开发者ID:garywzh,项目名称:SimpleWeather,代码行数:19,代码来源:MainActivity.java


示例3: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	if (error == TencentLocation.ERROR_OK) {
		mLocation = location;

		// 定位成功
		StringBuilder sb = new StringBuilder();
		sb.append("定位参数=").append(mRequestParams).append("\n");
		sb.append("(纬度=").append(location.getLatitude()).append(",经度=")
				.append(location.getLongitude()).append(",精度=")
				.append(location.getAccuracy()).append("), 来源=")
				.append(location.getProvider()).append(", 地址=")
				.append(location.getAddress());

		// 更新 status
		mStatus.setText(sb.toString());

		// 更新 location 图层
		mLocationOverlay.setAccuracy(mLocation.getAccuracy());
		mLocationOverlay.setGeoCoords(of(mLocation));
		mMapView.invalidate();
	}
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:25,代码来源:DemoMapActivity.java


示例4: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	String msg = null;
	if (error == TencentLocation.ERROR_OK) {
		// 定位成功
		StringBuilder sb = new StringBuilder();
		sb.append("(纬度=").append(location.getLatitude()).append(",经度=")
				.append(location.getLongitude()).append(",精度=")
				.append(location.getAccuracy()).append("), 来源=")
				.append(location.getProvider()).append(", 地址=")
				.append(location.getAddress());
		msg = sb.toString();
	} else {
		// 定位失败
		msg = "定位失败: " + reason;
	}

	// TODO 不将回调信息打印到 UI
	// updateLocationStatus(msg);
	Log.i("DemoStatusActivity", msg);
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:23,代码来源:DemoStatusActivity.java


示例5: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	String msg = null;
	if (error == TencentLocation.ERROR_OK) {
		// 定位成功
		StringBuilder sb = new StringBuilder();
		sb.append("(纬度=").append(location.getLatitude()).append(",经度=")
				.append(location.getLongitude()).append(",精度=")
				.append(location.getAccuracy()).append("), 来源=")
				.append(location.getProvider()).append(", 城市=")
				.append(location.getCity()).append(",citycode=")
				.append(location.getCityCode());
		msg = sb.toString();
	} else {
		// 定位失败
		msg = "定位失败: " + reason;
	}
	updateLocationStatus(msg);
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:21,代码来源:DemoIntervalActivity.java


示例6: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	String msg = null;
	if (error == TencentLocation.ERROR_OK) {
		// 定位成功
		StringBuilder sb = new StringBuilder();
		sb.append("(纬度=").append(location.getLatitude()).append(",经度=")
				.append(location.getLongitude()).append(",精度=")
				.append(location.getAccuracy()).append("), 来源=")
				.append(location.getProvider()).append(", 地址=")
				// 注意, 根据国家相关法规, wgs84坐标下无法提供地址信息
				.append("{84坐标下不提供地址!}");
		msg = sb.toString();
	} else {
		// 定位失败
		msg = "定位失败: " + reason;
	}
	updateLocationStatus(msg);
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:21,代码来源:DemoWgs84Activity.java


示例7: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(final TencentLocation tencentLocation,
                              int code, String s) {
    if (TencentLocation.ERROR_OK == code) {
        Toast.makeText(this, "定位成功", Toast.LENGTH_SHORT).show();


        mHandler.post(new Runnable() {
            @Override
            public void run() {
                GeoPoint point = new GeoPoint((int) (tencentLocation.getLatitude() * 1E6),
                        (int) (tencentLocation.getLongitude() * 1E6)); // 用给定的经纬度构造一个GeoPoint,单位是微度
                mMapView.getController().setCenter(point);
                mWorkHandler.post(new POISearchRunnable());
            }
        });
        TencentLocationManager.getInstance(this).removeUpdates(this);
    } else {
        Toast.makeText(this, "定位失败", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:yangyunfeng666,项目名称:demo-app-android-v2-2.3.9,代码行数:22,代码来源:SOSOLocationActivity.java


示例8: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	Log.i("test", "MainActivity, onLocationChanged, " + location);
	Log.i("test", "MainActivity, onLocationChanged, " + error);
	Log.i("test", "MainActivity, onLocationChanged, " + reason);
	if (TencentLocation.ERROR_OK == error) {

	} else {
		// 定位失败
	}
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:13,代码来源:MainActivity.java


示例9: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	String msg = null;
	if (error == TencentLocation.ERROR_OK) {
		// 定位成功
		msg = toString(location, mLevel);
	} else {
		// 定位失败
		msg = "定位失败: " + reason;
	}
	updateLocationStatus(msg);
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:14,代码来源:DemoLevelActivity.java


示例10: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	String msg = null;
	if (error == TencentLocation.ERROR_OK) {

		// 当前线程名字
		String threadName = Thread.currentThread().getName();

		// 定位成功
		StringBuilder sb = new StringBuilder();
		sb.append("(纬度=").append(location.getLatitude()).append(",经度=")
				.append(location.getLongitude()).append(",精度=")
				.append(location.getAccuracy()).append("), 来源=")
				.append(location.getProvider()).append(", 地址=")
				.append(location.getAddress());
		sb.append(", 当前线程=" + threadName);
		msg = sb.toString();
	} else {
		// 定位失败
		msg = "定位失败: " + reason;
	}

	final String message = msg;
	// 注意! 如果 onLocationChanged 不是在主线程中回调, 一定不要直接修改 UI
	mLocationStatus.post(new Runnable() {

		@Override
		public void run() {
			updateLocationStatus(message);

		}
	});
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:35,代码来源:DemoThreadActivity.java


示例11: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	if (error == TencentLocation.ERROR_OK) {
		double latitude = location.getLatitude();
		double longitude = location.getLongitude();
		double dirction = location.getExtra().getDouble(TencentLocation.EXTRA_DIRECTION);
		// System.out.println(latitude + " " + longitude + " " + dirction);
		mStatus.setText("纬度=" + latitude + ",经度=" + longitude + "\n方向=" + (int)dirction);
		mView.updateDirection(dirction);
	} else {
		mView.updateDirection(0);
	}
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:15,代码来源:DemoDirectionActivity.java


示例12: init

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@SuppressLint("HandlerLeak")
private void init(final Context context) {
	// onLocationChanged() 仅在"位置"发生变化时回调
	// 要实现更流畅的指南针效果, 可通过定时消息, 加快获取"方向"
	mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			TencentLocation location = TencentLocationManager.getInstance(context).getLastKnownLocation();
			if (location != null) {
				double dirction = location.getExtra().getDouble(TencentLocation.EXTRA_DIRECTION);
				updateDirection(dirction);
			}
		}
	};

	mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mPaint.setStyle(Style.STROKE);
	mPaint.setStrokeWidth(2f);
	mPaint.setColor(Color.RED);

	mPen = new Paint(Paint.ANTI_ALIAS_FLAG);
	mPen.setTextSize(getRawSize(TypedValue.COMPLEX_UNIT_SP, 20));
	mPen.setColor(Color.BLACK);

	mBmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_pointer);
	mBmpW = mBmp.getWidth() / 2;
	mBmpH = mBmp.getHeight() / 2;
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:30,代码来源:DemoDirectionActivity.java


示例13: animateTo

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
private void animateTo(TencentLocation location) {
	if (location == null) {
		return;
	}
	mMapView.getController().animateTo(Utils.of(location));
	// 修改 mapview 中心点
	mMapView.getController().setCenter(Utils.of(location));
	// 注意一定要更新当前位置 mCenter
	updatePosition();
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:11,代码来源:DemoGeofenceEditorActivty.java


示例14: onLocationChanged

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
@Override
public void onLocationChanged(TencentLocation location, int error,
		String reason) {
	mLastError = error;
	mLastLocation = location;
	if (mTmp != null) {
		mTmp.run();
	}

	// 自动停止
	stop();
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:13,代码来源:LocationHelper.java


示例15: toString

import com.tencent.map.geolocation.TencentLocation; //导入依赖的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();
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:48,代码来源:DemoLevelActivity.java


示例16: of

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
private static GeoPoint of(TencentLocation location) {
	GeoPoint ge = new GeoPoint((int) (location.getLatitude() * 1E6),
			(int) (location.getLongitude() * 1E6));
	return ge;
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:6,代码来源:DemoMapActivity.java


示例17: getLastLocation

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
public TencentLocation getLastLocation() {
	if (mLastError == 0) {
		return mLastLocation;
	}
	return null;
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:7,代码来源:LocationHelper.java


示例18: of

import com.tencent.map.geolocation.TencentLocation; //导入依赖的package包/类
public static GeoPoint of(TencentLocation location) {
	GeoPoint ge = new GeoPoint((int) (location.getLatitude() * 1E6),
			(int) (location.getLongitude() * 1E6));
	return ge;
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:6,代码来源:Utils.java



注:本文中的com.tencent.map.geolocation.TencentLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClassGen类代码示例发布时间:2022-05-23
下一篇:
Java JobHopMeta类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap