com.amap.api.maps.model.PolylineOptions Java Examples

The following examples show how to use com.amap.api.maps.model.PolylineOptions. 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: GaodeMapLocationManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void drawFlyLine() {
    if (this.locationMarker != null && this.deviceMarker != null) {
        LatLng latLngDevice = this.deviceMarker.getPosition();
        LatLng latLngMe = this.locationMarker.getPosition();
        this.latLngs.clear();
        this.latLngs.add(latLngDevice);
        this.latLngs.add(latLngMe);
        if (this.polyline == null) {
            PolylineOptions polylineOptions = new PolylineOptions();
            polylineOptions.addAll(this.latLngs);
            polylineOptions.width(10.0f).setDottedLine(false).geodesic(true).color(Color.argb(255, 1, 1, 1));
            if (this.polyline != null) {
                this.polyline.remove();
            }
            this.polyline = this.aMap.addPolyline(polylineOptions);
        }
        this.polyline.setPoints(this.latLngs);
    }
}
 
Example #2
Source File: BusLineOverlay.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 添加公交线路到地图中。
 *
 * @since V2.1.0
 */
public void addToMap() {
    try {
        List<LatLonPoint> pointList = mBusLineItem.getDirectionsCoordinates();
        List<LatLng> listPolyline = AMapServicesUtil.convertArrList(pointList);
        mBusLinePolyline = mAMap.addPolyline(new PolylineOptions()
                .addAll(listPolyline).color(getBusColor())
                .width(getBuslineWidth()));
        if (mBusStations.size() < 1) {
            return;
        }
        for (int i = 1; i < mBusStations.size() - 1; i++) {
            Marker marker = mAMap.addMarker(getMarkerOptions(i));
            mBusStationMarks.add(marker);
        }
        Marker markerStart = mAMap.addMarker(getMarkerOptions(0));
        mBusStationMarks.add(markerStart);
        Marker markerEnd = mAMap
                .addMarker(getMarkerOptions(mBusStations.size() - 1));
        mBusStationMarks.add(markerEnd);
    } catch (Throwable e) {
        e.printStackTrace();
    }

}
 
Example #3
Source File: CircleActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 *
 * @param centerpoint 中心点坐标
 * @param radius      半径 米
 */
public void addPolylinescircle(LatLng centerpoint, int radius) {
    double r = 6371000.79;
    PolylineOptions options = new PolylineOptions();
    int numpoints = 360;
    double phase = 2 * Math.PI / numpoints;

    //画图
    for (int i = 0; i < numpoints; i++) {
        double dx = (radius * Math.cos(i * phase));
        double dy = (radius * Math.sin(i * phase));//乘以1.6 椭圆比例

        double dlng = dx / (r * Math.cos(centerpoint.latitude * Math.PI / 180) * Math.PI / 180);
        double dlat = dy / (r * Math.PI / 180);
        double newlng = centerpoint.longitude + dlng;
        options.add(new LatLng(centerpoint.latitude + dlat, newlng));
    }

    aMap.addPolyline(options.width(10).useGradient(true).setDottedLine(true));

}
 
Example #4
Source File: AmapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void setRangingPolyLine() {
    if (mPoiList.size() < 2) {
        mTotal = 0;
        ((MainActivity) getActivity()).setRangingDistance(mTotal);
        return;
    }

    MyPoiModel end = mPoiList.get(mPoiList.size() - 1);
    MyPoiModel last = mPoiList.get(mPoiList.size() - 2);

    mTotal += AMapUtils.calculateLineDistance(new LatLng(end.getLatitude(), end.getLongitude()),
            new LatLng(last.getLatitude(), last.getLongitude()));

    List<LatLng> points = new ArrayList<>();
    points.add(new LatLng(end.getLatitude(), end.getLongitude()));
    points.add(new LatLng(last.getLatitude(), last.getLongitude()));

    Polyline ooPolyline = mAmap.addPolyline(new PolylineOptions().addAll(points).width(6).color(Color.BLUE));

    if (null == mLineList) {
        mLineList = new ArrayList<>();
    }
    mLineList.add(ooPolyline);

    ((MainActivity) getActivity()).setRangingDistance(mTotal);
}
 
Example #5
Source File: PolylineActivitybase.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
	 * 多段颜色(非渐变色)
	 */
	private void addPolylinesWithColors() {
		//四个点
		LatLng A = new LatLng(Lat_A + 1, Lon_A + 1);
		LatLng B = new LatLng(Lat_B + 1, Lon_B + 1);
		LatLng C = new LatLng(Lat_C + 1, Lon_C + 1);
		LatLng D = new LatLng(Lat_D + 1, Lon_D + 1);
		
		//用一个数组来存放颜色,四个点对应三段颜色
		List<Integer> colorList = new ArrayList<Integer>();
		colorList.add(Color.RED);
		colorList.add(Color.YELLOW);
		colorList.add(Color.GREEN);
//		colorList.add(Color.BLACK);
		
		PolylineOptions options = new PolylineOptions();
		options.width(20);//设置宽度
		
		//加入四个点
		options.add(A,B,C,D);
		
		//加入对应的颜色,使用colorValues 即表示使用多颜色,使用color表示使用单色线
		options.colorValues(colorList);
		
		aMap.addPolyline(options);
	}
 
Example #6
Source File: BusLineOverlay.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 添加公交线路到地图中。
 *
 * @since V2.1.0
 */
public void addToMap() {
    try {
        List<LatLonPoint> pointList = mBusLineItem.getDirectionsCoordinates();
        List<LatLng> listPolyline = AMapServicesUtil.convertArrList(pointList);
        mBusLinePolyline = mAMap.addPolyline(new PolylineOptions()
                .addAll(listPolyline).color(getBusColor())
                .width(getBuslineWidth()));
        if (mBusStations.size() < 1) {
            return;
        }
        for (int i = 1; i < mBusStations.size() - 1; i++) {
            Marker marker = mAMap.addMarker(getMarkerOptions(i));
            mBusStationMarks.add(marker);
        }
        Marker markerStart = mAMap.addMarker(getMarkerOptions(0));
        mBusStationMarks.add(markerStart);
        Marker markerEnd = mAMap
                .addMarker(getMarkerOptions(mBusStations.size() - 1));
        mBusStationMarks.add(markerEnd);
    } catch (Throwable e) {
        e.printStackTrace();
    }

}
 
Example #7
Source File: BusLineOverlay.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
/**
 * 添加公交线路到地图中。
 *
 * @since V2.1.0
 */
public void addToMap() {
    try {
        List<LatLonPoint> pointList = mBusLineItem.getDirectionsCoordinates();
        List<LatLng> listPolyline = AMapServicesUtil.convertArrList(pointList);
        mBusLinePolyline = mAMap.addPolyline(new PolylineOptions()
                .addAll(listPolyline).color(getBusColor())
                .width(getBuslineWidth()));
        if (mBusStations.size() < 1) {
            return;
        }
        for (int i = 1; i < mBusStations.size() - 1; i++) {
            Marker marker = mAMap.addMarker(getMarkerOptions(i));
            mBusStationMarks.add(marker);
        }
        Marker markerStart = mAMap.addMarker(getMarkerOptions(0));
        mBusStationMarks.add(markerStart);
        Marker markerEnd = mAMap
                .addMarker(getMarkerOptions(mBusStations.size() - 1));
        mBusStationMarks.add(markerEnd);
    } catch (Throwable e) {
        e.printStackTrace();
    }

}
 
Example #8
Source File: AmapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void setRangingPolyLine() {
    if (mPoiList.size() < 2) {
        mTotal = 0;
        ((MainActivity) getActivity()).setRangingDistance(mTotal);
        return;
    }

    MyPoiModel end = mPoiList.get(mPoiList.size() - 1);
    MyPoiModel last = mPoiList.get(mPoiList.size() - 2);

    mTotal += AMapUtils.calculateLineDistance(new LatLng(end.getLatitude(), end.getLongitude()),
            new LatLng(last.getLatitude(), last.getLongitude()));

    List<LatLng> points = new ArrayList<>();
    points.add(new LatLng(end.getLatitude(), end.getLongitude()));
    points.add(new LatLng(last.getLatitude(), last.getLongitude()));

    Polyline ooPolyline = mAmap.addPolyline(new PolylineOptions().addAll(points).width(6).color(Color.BLUE));

    if (null == mLineList) {
        mLineList = new ArrayList<>();
    }
    mLineList.add(ooPolyline);

    ((MainActivity) getActivity()).setRangingDistance(mTotal);
}
 
Example #9
Source File: ColourfulPolylineActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
	 * 多段颜色(非渐变色)
	 */
	private void addPolylinesWithColors() {
		//四个点
		LatLng A = new LatLng(Lat_A + 0.0001, Lon_A + 0.0001);
		LatLng B = new LatLng(Lat_B + 0.0001, Lon_B + 0.0001);
		LatLng C = new LatLng(Lat_C + 0.0001, Lon_C + 0.0001);
		LatLng D = new LatLng(Lat_D + 0.0001, Lon_D + 0.0001);
		
		//用一个数组来存放颜色,四个点对应三段颜色
		List<Integer> colorList = new ArrayList<Integer>();
		colorList.add(Color.RED);
		colorList.add(Color.YELLOW);
		colorList.add(Color.GREEN);
//		colorList.add(Color.BLACK);
		
		PolylineOptions options = new PolylineOptions();
		options.width(20);//设置宽度
		
		//加入四个点
		options.add(A,B,C,D);
		
		//加入对应的颜色,使用colorValues 即表示使用多颜色,使用color表示使用单色线
		options.colorValues(colorList);
		
		aMap.addPolyline(options);
	}
 
Example #10
Source File: RecordShowActivity.java    From RecordPath3D with Apache License 2.0 6 votes vote down vote up
/**
 * 地图上添加原始轨迹线路及起终点、轨迹动画小人
 * 
 * @param startPoint
 * @param endPoint
 * @param originList
 */
private void addOriginTrace(LatLng startPoint, LatLng endPoint,
		List<LatLng> originList) {
	mOriginPolyline = mAMap.addPolyline(new PolylineOptions().color(
			Color.BLUE).addAll(originList));
	mOriginStartMarker = mAMap.addMarker(new MarkerOptions().position(
			startPoint).icon(
			BitmapDescriptorFactory.fromResource(R.drawable.start)));
	mOriginEndMarker = mAMap.addMarker(new MarkerOptions().position(
			endPoint).icon(
			BitmapDescriptorFactory.fromResource(R.drawable.end)));

	try {
		mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(getBounds(),
				50));
	} catch (Exception e) {
		e.printStackTrace();
	}

	mOriginRoleMarker = mAMap.addMarker(new MarkerOptions().position(
			startPoint).icon(
			BitmapDescriptorFactory.fromBitmap(BitmapFactory
					.decodeResource(getResources(), R.drawable.walk))));
}
 
Example #11
Source File: GaoDeMapAiPoint2PointManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void drawPointLine(LatLng latLngDevice) {
    if (this.pointMarker != null) {
        LatLng latLng = this.pointMarker.getPosition();
        this.latLngs.clear();
        this.latLngs.add(latLng);
        this.latLngs.add(latLngDevice);
        if (this.polyline == null) {
            PolylineOptions polylineOptions = new PolylineOptions();
            polylineOptions.addAll(this.latLngs);
            polylineOptions.setDottedLine(true);
            polylineOptions.color(this.context.getResources().getColor(R.color.x8_drone_inface_line)).zIndex(50.0f);
            polylineOptions.width(10.0f);
            if (this.polyline != null) {
                this.polyline.remove();
            }
            this.polyline = this.aMap.addPolyline(polylineOptions);
        }
        this.polyline.setPoints(this.latLngs);
    }
}
 
Example #12
Source File: GaoDeMapAiLineManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void drawPointLine(LatLng latLngDevice) {
    this.latLngs.clear();
    if (this.polyline != null) {
        this.polyline.remove();
    }
    this.latLngs.add(latLngDevice);
    for (Marker marker : this.mMarkerList) {
        this.latLngs.add(marker.getPosition());
    }
    PolylineOptions polylineOptions = new PolylineOptions();
    polylineOptions.addAll(this.latLngs);
    polylineOptions.setDottedLine(true);
    polylineOptions.color(this.context.getResources().getColor(R.color.x8_drone_inface_line)).zIndex(50.0f);
    polylineOptions.width(10.0f);
    this.polyline = this.aMap.addPolyline(polylineOptions);
}
 
Example #13
Source File: BusRouteOverlay.java    From TraceByAmap with MIT License 5 votes vote down vote up
private void addBusLineSteps(List<LatLonPoint> listPoints) {
	if (listPoints.size() < 1) {
		return;
	}
	addPolyLine(new PolylineOptions().width(getRouteWidth())
			.color(getBusColor())
			.addAll(AMapUtil.convertArrList(listPoints)));
}
 
Example #14
Source File: RouteOverlay.java    From TraceByAmap with MIT License 5 votes vote down vote up
protected void addPolyLine(PolylineOptions options) {
	if(options == null) {
		return;
	}
	Polyline polyline = mAMap.addPolyline(options);
	if(polyline != null) {
		allPolyLines.add(polyline);
	}
}
 
Example #15
Source File: RecordShowActivity.java    From RecordPath3D with Apache License 2.0 5 votes vote down vote up
/**
 * 地图上添加纠偏后轨迹线路及起终点、轨迹动画小人
 * 
 * @param startPoint
 * @param endPoint
 * @param originList
 */
private void addGraspTrace(List<LatLng> graspList, boolean mGraspChecked) {
	if (graspList == null || graspList.size() < 2) {
		return;
	}
	LatLng startPoint = graspList.get(0);
	LatLng endPoint = graspList.get(graspList.size() - 1);
	mGraspPolyline = mAMap.addPolyline(new PolylineOptions()
			.setCustomTexture(
					BitmapDescriptorFactory
							.fromResource(R.drawable.grasp_trace_line))
			.width(40).addAll(graspList));
	mGraspStartMarker = mAMap.addMarker(new MarkerOptions().position(
			startPoint).icon(
			BitmapDescriptorFactory.fromResource(R.drawable.start)));
	mGraspEndMarker = mAMap.addMarker(new MarkerOptions()
			.position(endPoint).icon(
					BitmapDescriptorFactory.fromResource(R.drawable.end)));
	mGraspRoleMarker = mAMap.addMarker(new MarkerOptions().position(
			startPoint).icon(
			BitmapDescriptorFactory.fromBitmap(BitmapFactory
					.decodeResource(getResources(), R.drawable.walk))));
	if (!mGraspChecked) {
		mGraspPolyline.setVisible(false);
		mGraspStartMarker.setVisible(false);
		mGraspEndMarker.setVisible(false);
		mGraspRoleMarker.setVisible(false);
	}
}
 
Example #16
Source File: RouteDistanceActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
private void setFromAndTo() {

		LatLng latLngStart0 = AMapUtil.convertToLatLng(start0);
		LatLng latLngStart1 = AMapUtil.convertToLatLng(start1);
		LatLng latLngStart2 = AMapUtil.convertToLatLng(start2);
		LatLng latLngStart3 = AMapUtil.convertToLatLng(start3);
		LatLng latLngEnd = AMapUtil.convertToLatLng(dest);

		aMap.addMarker(new MarkerOptions()
		.position(latLngStart0)
		.icon(BitmapDescriptorFactory.fromResource(R.drawable.poi_marker_1)));
		aMap.addMarker(new MarkerOptions()
				.position(latLngStart1)
				.icon(BitmapDescriptorFactory.fromResource(R.drawable.poi_marker_2)));
		aMap.addMarker(new MarkerOptions()
				.position(latLngStart2)
				.icon(BitmapDescriptorFactory.fromResource(R.drawable.poi_marker_3)));
		aMap.addMarker(new MarkerOptions()
				.position(latLngStart3)
				.icon(BitmapDescriptorFactory.fromResource(R.drawable.poi_marker_4)));

		aMap.addMarker(new MarkerOptions()
		.position(latLngEnd)
		.icon(BitmapDescriptorFactory.fromResource(R.drawable.end)));



		aMap.addPolyline(new PolylineOptions().add(latLngStart0,latLngEnd).color(Color.GREEN));
		aMap.addPolyline(new PolylineOptions().add(latLngStart1,latLngEnd).color(Color.GREEN));
		aMap.addPolyline(new PolylineOptions().add(latLngStart2,latLngEnd).color(Color.GREEN));
		aMap.addPolyline(new PolylineOptions().add(latLngStart3,latLngEnd).color(Color.GREEN));


		mDistanceText.add(aMap.addText(new TextOptions().position(getMidLatLng(latLngStart0, latLngEnd)).text("cal distance ...")));
		mDistanceText.add(aMap.addText(new TextOptions().position(getMidLatLng(latLngStart1, latLngEnd)).text("cal distance ...")));
		mDistanceText.add(aMap.addText(new TextOptions().position(getMidLatLng(latLngStart2, latLngEnd)).text("cal distance ...")));
		mDistanceText.add(aMap.addText(new TextOptions().position(getMidLatLng(latLngStart3, latLngEnd)).text("cal distance ...")));

	}
 
Example #17
Source File: RouteOverlay.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
protected void addPolyLine(PolylineOptions options) {
	if(options == null) {
		return;
	}
	Polyline polyline = mAMap.addPolyline(options);
	if(polyline != null) {
		allPolyLines.add(polyline);
	}
}
 
Example #18
Source File: BusRouteOverlay.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void addBusLineSteps(List<LatLonPoint> listPoints) {
	if (listPoints.size() < 1) {
		return;
	}
	addPolyLine(new PolylineOptions().width(getRouteWidth())
			.color(getBusColor())
			.addAll(AMapUtil.convertArrList(listPoints)));
}
 
Example #19
Source File: RouteOverlay.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
protected void addPolyLine(PolylineOptions options) {
	if(options == null) {
		return;
	}
	Polyline polyline = mAMap.addPolyline(options);
	if(polyline != null) {
		allPolyLines.add(polyline);
	}
}
 
Example #20
Source File: BusRouteOverlay.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void addBusLineSteps(List<LatLonPoint> listPoints) {
	if (listPoints.size() < 1) {
		return;
	}
	addPolyLine(new PolylineOptions().width(getRouteWidth())
			.color(getBusColor())
			.addAll(AMapUtil.convertArrList(listPoints)));
}
 
Example #21
Source File: MapDrawer.java    From RunMap with Apache License 2.0 5 votes vote down vote up
public void drawPolyLine(List<LatLng> latLngs, int color) {
    CFLog.e("TAG", "draw new Poly");
    PolylineOptions options = new PolylineOptions();
    options.addAll(latLngs);
    options.color(color);
    options.width(20);
    mAmap.addPolyline(options);
}
 
Example #22
Source File: AMapPolyline.java    From react-native-amap with MIT License 5 votes vote down vote up
private PolylineOptions createPolylineOptions() {
    PolylineOptions options = new PolylineOptions();
    options.addAll(coordinates);
    options.color(color);
    options.width(width);
    options.geodesic(geodesic);
    options.zIndex(zIndex);
    return options;
}
 
Example #23
Source File: MainActivity.java    From SmoothMove with MIT License 5 votes vote down vote up
private void addPolylineInPlayGround() {
    List<LatLng> list = readLatLngs();
    List<Integer> colorList = new ArrayList<Integer>();
    List<BitmapDescriptor> bitmapDescriptors = new ArrayList<BitmapDescriptor>();

    int[] colors = new int[]{Color.argb(255, 0, 255, 0), Color.argb(255, 255, 255, 0), Color
            .argb(255, 255, 0, 0)};

    //用一个数组来存放纹理
    List<BitmapDescriptor> textureList = new ArrayList<BitmapDescriptor>();
    textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.custtexture));

    List<Integer> texIndexList = new ArrayList<Integer>();
    texIndexList.add(0);//对应上面的第0个纹理
    texIndexList.add(1);
    texIndexList.add(2);

    Random random = new Random();
    for (int i = 0; i < list.size(); i++) {
        colorList.add(colors[random.nextInt(3)]);
        bitmapDescriptors.add(textureList.get(0));

    }

    aMap.addPolyline(new PolylineOptions().setCustomTexture(BitmapDescriptorFactory
            .fromResource(R.drawable.custtexture)) //setCustomTextureList(bitmapDescriptors)
            //				.setCustomTextureIndex(texIndexList)
            .addAll(list)
            .useGradient(true)
            .width(18));
}
 
Example #24
Source File: GeodesicActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
private void setUpMap() {

		// 设置当前地图级别为4
		aMap.moveCamera(CameraUpdateFactory.zoomTo(4));
		// 设置地图底图文字的z轴指数,默认为0
		aMap.setMapTextZIndex(2);

		// 绘制一个乌鲁木齐到哈尔滨的大地曲线
		aMap.addPolyline((new PolylineOptions())
				.add(new LatLng(43.828, 87.621), new LatLng(45.808, 126.55))
				.geodesic(true).color(Color.RED));

	}
 
Example #25
Source File: GaodeMapLocationManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void addFlyPolyLine(double latitude, double logitude) {
    this.flyLatLngs.add(new LatLng(latitude, logitude));
    List<LatLng> latLngs = new ArrayList(this.flyLatLngs.getLinkedList());
    if (this.flyPolyLine == null) {
        PolylineOptions polylineOptions = new PolylineOptions();
        polylineOptions.addAll(latLngs);
        polylineOptions.color(this.context.getResources().getColor(R.color.x8_drone_inface_line)).zIndex(50.0f);
        polylineOptions.width(4.0f);
        this.flyPolyLine = this.aMap.addPolyline(polylineOptions);
    }
    this.flyPolyLine.setPoints(latLngs);
}
 
Example #26
Source File: GaoDeMapAiSurroundManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void addPolylinescircle(LatLng centerpoint, float radius) {
    PolylineOptions options = new PolylineOptions();
    double phase = 6.283185307179586d / ((double) 360);
    for (int i = 0; i < 360; i++) {
        double newlng = centerpoint.longitude + ((((double) radius) * Math.cos(((double) i) * phase)) / (((Math.cos((centerpoint.latitude * 3.141592653589793d) / 180.0d) * 6371000.79d) * 3.141592653589793d) / 180.0d));
        options.add(new LatLng(centerpoint.latitude + ((((double) radius) * Math.sin(((double) i) * phase)) / ((3.141592653589793d * 6371000.79d) / 180.0d)), newlng));
    }
    options.color(this.context.getResources().getColor(R.color.x8_drone_inface_line));
    this.polyline = this.aMap.addPolyline(options.width(10.0f).useGradient(true).setDottedLine(true));
}
 
Example #27
Source File: SmoothMoveActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
     * 添加轨迹线
     */
    private void addPolylineInPlayGround() {
        List<LatLng> list = readLatLngs();
        List<Integer> colorList = new ArrayList<Integer>();
        List<BitmapDescriptor> bitmapDescriptors = new ArrayList<BitmapDescriptor>();

        int[] colors = new int[]{Color.argb(255, 0, 255, 0),Color.argb(255, 255, 255, 0),Color.argb(255, 255, 0, 0)};

        //用一个数组来存放纹理
        List<BitmapDescriptor> textureList = new ArrayList<BitmapDescriptor>();
        textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.custtexture));

        List<Integer> texIndexList = new ArrayList<Integer>();
        texIndexList.add(0);//对应上面的第0个纹理
        texIndexList.add(1);
        texIndexList.add(2);

        Random random = new Random();
        for (int i = 0; i < list.size(); i++) {
            colorList.add(colors[random.nextInt(3)]);
            bitmapDescriptors.add(textureList.get(0));

        }

        mPolyline = mAMap.addPolyline(new PolylineOptions().setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.custtexture)) //setCustomTextureList(bitmapDescriptors)
//				.setCustomTextureIndex(texIndexList)
                .addAll(list)
                .useGradient(true)
                .width(18));

        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        builder.include(list.get(0));
        builder.include(list.get(list.size() - 2));

        mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 100));
    }
 
Example #28
Source File: ColourfulPolylineActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 多段颜色(渐变色)
 */
private void addPolylinesWithGradientColors() {
	//四个点
	LatLng A = new LatLng(Lat_A + 0.0004, Lon_A + 0.0004);
	LatLng B = new LatLng(Lat_B + 0.0004, Lon_B + 0.0004);
	LatLng C = new LatLng(Lat_C + 0.0004, Lon_C + 0.0004);
	LatLng D = new LatLng(Lat_D + 0.0004, Lon_D + 0.0004);
	
	//用一个数组来存放颜色,渐变色,四个点需要设置四个颜色
	List<Integer> colorList = new ArrayList<Integer>();
	colorList.add(Color.RED);
	colorList.add(Color.YELLOW);
	colorList.add(Color.GREEN);
	colorList.add(Color.BLACK);//如果第四个颜色不添加,那么最后一段将显示上一段的颜色
	
	PolylineOptions options = new PolylineOptions();
	options.width(20);//设置宽度
	
	//加入四个点
	options.add(A,B,C,D);
	
	//加入对应的颜色,使用colorValues 即表示使用多颜色,使用color表示使用单色线
	options.colorValues(colorList);
	
	//加上这个属性,表示使用渐变线
	options.useGradient(true);
	
	aMap.addPolyline(options);
}
 
Example #29
Source File: PolylineActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
private void addPolylinessoild() {
	LatLng A = new LatLng(Lat_A, Lon_A);
	LatLng B = new LatLng(Lat_B, Lon_B);
    LatLng C = new LatLng(Lat_C, Lon_C);
	LatLng D = new LatLng(Lat_D, Lon_D);
	aMap.addPolyline((new PolylineOptions())
			.add(A, B, C, D)
			.width(10)
			.color(Color.argb(255, 1, 255, 255)));
}
 
Example #30
Source File: PolylineActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
private void addPolylinesdotted() {
	polyline = aMap.addPolyline((new PolylineOptions())
			.add(Constants.SHANGHAI, Constants.BEIJING, Constants.CHENGDU)
			.width(10)
			.setDottedLine(true)//设置虚线
			.color(Color.argb(255, 1, 1, 1)));
}