百度地图学习记录

自定义路径添加点和折线(目前轨迹记录中只用到这两个)

/**
	 * 绘制单点,该点状态不随地图状态变化而变化
	 * 
	 * @return 点对象
	 */
	public Graphic drawPoint(double mLat_point, double mLon_point) {
		int lat = (int) (mLat_point * 1E6);
		int lon = (int) (mLon_point * 1E6);
		GeoPoint pt1 = new GeoPoint(lat, lon);

		// 构建点
		Geometry pointGeometry = new Geometry();
		// 设置坐标
		pointGeometry.setPoint(pt1, 3);//坐标和半径
		// 设定样式
		Symbol pointSymbol = new Symbol();
		Symbol.Color pointColor = pointSymbol.new Color();
		pointColor.red = 0;
		pointColor.green = 126;
		pointColor.blue = 255;
		pointColor.alpha = 255;
		pointSymbol.setPointSymbol(pointColor);
		// 生成Graphic对象
		Graphic pointGraphic = new Graphic(pointGeometry, pointSymbol);
		return pointGraphic;
	}

	/**
	 * 绘制折线,该折线状态随地图状态变化
	 * 
	 * @return 折线对象
	 */
	public Graphic drawLine(double mLat_start, double mLon_start,
			double mLat_end, double mLon_end) {

		int lat = (int) (mLat_start * 1E6);
		int lon = (int) (mLon_start * 1E6);
		GeoPoint pt1 = new GeoPoint(lat, lon);
		lat = (int) (mLat_end * 1E6);
		lon = (int) (mLon_end * 1E6);
		GeoPoint pt2 = new GeoPoint(lat, lon);

		// 构建线
		Geometry lineGeometry = new Geometry();
		// 设定折线点坐标
		GeoPoint[] linePoints = new GeoPoint[2];
		linePoints[0] = pt1;
		linePoints[1] = pt2;
		lineGeometry.setPolyLine(linePoints);
		// 设定样式
		Symbol lineSymbol = new Symbol();
		Symbol.Color lineColor = lineSymbol.new Color();
		lineColor.red = 255;
		lineColor.green = 0;
		lineColor.blue = 0;
		lineColor.alpha = 255;
		lineSymbol.setLineSymbol(lineColor, 2);//颜色和粗细
		// 生成Graphic对象
		Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
		return lineGraphic;
	}
关于签名

目前自己签名时,只有密码设为android的时候,才能使用百度地图api,不然都会提示错误102(可能是本人能力有限吧)

你可能感兴趣的:(百度地图学习记录)