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

The following examples show how to use com.amap.api.maps.model.PolygonOptions. 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: GeoFence_Nearby_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #2
Source File: GeoFence_Multiple_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #3
Source File: GeoFence_Polygon_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR)
				.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #4
Source File: GeoFence_Nearby_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #5
Source File: GeoFence_Keyword_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #6
Source File: GeoFence_Round_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR)
				.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #7
Source File: GeoFence_District_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #8
Source File: GeoFence_Multiple_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #9
Source File: GeoFence_Polygon_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR)
				.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #10
Source File: GeoFence_Keyword_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #11
Source File: GeoFence_Round_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR)
				.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #12
Source File: GeoFence_District_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawPolygon(GeoFence fence) {
	final List<List<DPoint>> pointList = fence.getPointList();
	if (null == pointList || pointList.isEmpty()) {
		return;
	}
	for (List<DPoint> subList : pointList) {
		List<LatLng> lst = new ArrayList<LatLng>();

		PolygonOptions polygonOption = new PolygonOptions();
		for (DPoint point : subList) {
			lst.add(new LatLng(point.getLatitude(), point.getLongitude()));
			boundsBuilder.include(
					new LatLng(point.getLatitude(), point.getLongitude()));
		}
		polygonOption.addAll(lst);

		polygonOption.strokeColor(Const.STROKE_COLOR).strokeWidth(Const.STROKE_WIDTH)
				.fillColor(Const.FILL_COLOR);
		mAMap.addPolygon(polygonOption);
	}
}
 
Example #13
Source File: ContainsActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
private void setUpMap() {
		aMap.setOnMapClickListener(this);
		// 绘制一个长方形
		PolygonOptions pOption = new PolygonOptions();
		pOption.add(new LatLng(39.926516, 116.389366));
		pOption.add(new LatLng(39.924870, 116.403270));
		pOption.add(new LatLng(39.918090, 116.406274));
		pOption.add(new LatLng(39.909466, 116.397863));
		pOption.add(new LatLng(39.913021, 116.387134));
		polygon = aMap.addPolygon(pOption.strokeWidth(4)
				.strokeColor(Color.argb(50, 1, 1, 1))
				.fillColor(Color.argb(50, 1, 1, 1)));
		aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.926516,
				116.389366), 16));
//		
	}
 
Example #14
Source File: HoleActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 初始化AMap对象
 */
private void init() {
    if (aMap == null) {
        aMap = mapView.getMap();
    }

    aMap.moveCamera(CameraUpdateFactory.zoomTo(8));
    CircleOptions circleOptions = new CircleOptions().center(Constants.BEIJING)
            .radius(100000).strokeColor(Color.argb(200, 1, 1, 1))
            .fillColor(Color.argb(200, 80, 1, 1)).strokeWidth(10);
    circle = aMap.addCircle(circleOptions);


    PolygonOptions polygonOptions = new PolygonOptions()
            .addAll(createRectangle(Constants.SHANGHAI, 1, 1))
            .fillColor(Color.LTGRAY).strokeColor(Color.RED).strokeWidth(10);

    polygon = aMap.addPolygon(polygonOptions);
}
 
Example #15
Source File: GaoDeMapNoFlyZone.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void drawIrregularNoFlyZone(LatLng[] lats, boolean isNoFly) {
    PolygonOptions options = new PolygonOptions();
    options.strokeWidth(0.0f).strokeColor(this.strokeColor);
    if (isNoFly) {
        options.fillColor(this.fillColor);
    } else {
        options.fillColor(this.fillColorHeightLimit);
    }
    for (LatLng add : lats) {
        options.add(add);
    }
    this.polygonList.add(this.aMap.addPolygon(options));
}
 
Example #16
Source File: ProvinceHoleActivity.java    From TraceByAmap with MIT License 4 votes vote down vote up
private void setUpMap() {

        List<LatLng> latLngs = new ArrayList();
        //绘制一个全世界的多边形
        latLngs.add(new LatLng(84.9, -179.9));
        latLngs.add(new LatLng(84.9, 179.9));
        latLngs.add(new LatLng(-84.9, 179.9));
        latLngs.add(new LatLng(-84.9, -179.9));

        polygon = aMap.addPolygon(new PolygonOptions().addAll(latLngs).fillColor(Color.rgb(245,245,245)).zIndex(10));

        searchDistrict();

        aMap.moveCamera(CameraUpdateFactory.zoomTo(8));

    }
 
Example #17
Source File: PolygonActivity.java    From TraceByAmap with MIT License 4 votes vote down vote up
private void setUpMap() {
		mColorBar.setOnSeekBarChangeListener(this);
		mAlphaBar.setOnSeekBarChangeListener(this);
		mWidthBar.setOnSeekBarChangeListener(this);
		aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(Constants.BEIJING, 5));// 设置指定的可视区域地图
		// 绘制一个长方形
		aMap.addPolygon(new PolygonOptions()
				.addAll(createRectangle(Constants.SHANGHAI, 1, 1))
				.fillColor(Color.LTGRAY).strokeColor(Color.RED).strokeWidth(1));

		PolygonOptions options = new PolygonOptions();
		int numPoints = 400;
		float semiHorizontalAxis = 5f;
		float semiVerticalAxis = 2.5f;
		double phase = 2 * Math.PI / numPoints;
		for (int i = 0; i <= numPoints; i++) {
			options.add(new LatLng(Constants.BEIJING.latitude
					+ semiVerticalAxis * Math.sin(i * phase),
					Constants.BEIJING.longitude + semiHorizontalAxis
							* Math.cos(i * phase)));
		}
		// 绘制一个椭圆
		polygon = aMap.addPolygon(options.strokeWidth(25)
				.strokeColor(Color.argb(50, 1, 1, 1))
				.fillColor(Color.argb(50, 1, 1, 1)));

//		LatLng latLng1 = new LatLng(39.967641, 116.322888);
//		LatLng latLng2 = new LatLng(39.967641, 116.434124);
//		LatLng latLng3 = new LatLng(39.951852, 116.464337);
//		LatLng latLng4 = new LatLng(39.867581, 116.458843);
//		LatLng latLng5 = new LatLng(39.870743, 116.311901);

		// 定义多边形的5个点点坐标
		LatLng latLng1 = new LatLng(42.742467, 79.842785);
		LatLng latLng2 = new LatLng(43.893433, 98.124035);
		LatLng latLng3 = new LatLng(33.058738, 101.463879);
		LatLng latLng4 = new LatLng(25.873426, 95.838879);
		LatLng latLng5 = new LatLng(30.8214661, 78.788097);

		// 声明 多边形参数对象
		PolygonOptions polygonOptions = new PolygonOptions();
		// 添加 多边形的每个顶点(顺序添加)
		polygonOptions.add(latLng1, latLng2, latLng3, latLng4, latLng5);
		polygonOptions.strokeWidth(15) // 多边形的边框
				.strokeColor(Color.argb(50, 1, 1, 1)) // 边框颜色
				.fillColor(Color.argb(1, 1, 1, 1));   // 多边形的填充色

		// 添加一个多边形
		aMap.addPolygon(polygonOptions);
	}
 
Example #18
Source File: CloudActivity.java    From TraceByAmap with MIT License votes vote down vote up
/**
	 * 检索结果回调
	 * @param result
	 * @param rCode
     */
	@Override
	public void onCloudSearched(CloudResult result, int rCode) {
		dissmissProgressDialog();

		if (rCode == AMapException.CODE_AMAP_SUCCESS) {
			if (result != null && result.getQuery() != null) {
				if (result.getQuery().equals(mQuery)) {
					mCloudItems = result.getClouds();

					if (mCloudItems != null && mCloudItems.size() > 0) {
						mAMap.clear();
						mPoiCloudOverlay = new CloudOverlay(mAMap, mCloudItems);
						mPoiCloudOverlay.removeFromMap();
						mPoiCloudOverlay.addToMap();
						// mPoiCloudOverlay.zoomToSpan();
						for (CloudItem item : mCloudItems) {
							items.add(item);
							Log.d(TAG, "_id " + item.getID());
							Log.d(TAG, "_location "
									+ item.getLatLonPoint().toString());
							Log.d(TAG, "_name " + item.getTitle());
							Log.d(TAG, "_address " + item.getSnippet());
							Log.d(TAG, "_caretetime " + item.getCreatetime());
							Log.d(TAG, "_updatetime " + item.getUpdatetime());
							Log.d(TAG, "_distance " + item.getDistance());
							Iterator iter = item.getCustomfield().entrySet()
									.iterator();
							while (iter.hasNext()) {
								Map.Entry entry = (Map.Entry) iter.next();
								Object key = entry.getKey();
								Object val = entry.getValue();
								Log.d(TAG, key + "   " + val);
							}
						}
						if (mQuery.getBound().getShape()
								.equals(SearchBound.BOUND_SHAPE)) {// 圆形
							mAMap.addCircle(new CircleOptions()
									.center(new LatLng(mCenterPoint
											.getLatitude(), mCenterPoint
											.getLongitude())).radius(5000)
									.strokeColor(
									// Color.argb(50, 1, 1, 1)
											Color.RED)
									.fillColor(Color.argb(50, 1, 1, 1))
									.strokeWidth(5));

							mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
									new LatLng(mCenterPoint.getLatitude(),
											mCenterPoint.getLongitude()), 12));

						} else if (mQuery.getBound().getShape()
								.equals(SearchBound.POLYGON_SHAPE)) {
							mAMap.addPolygon(new PolygonOptions()
									.add(AMapUtil.convertToLatLng(mPoint1))
									.add(AMapUtil.convertToLatLng(mPoint2))
									.add(AMapUtil.convertToLatLng(mPoint3))
									.add(AMapUtil.convertToLatLng(mPoint4))
									.fillColor(Color.argb(50, 1, 1, 1))
									.strokeColor(Color.RED).strokeWidth(1));
							LatLngBounds bounds = new LatLngBounds.Builder()
									.include(AMapUtil.convertToLatLng(mPoint1))
									.include(AMapUtil.convertToLatLng(mPoint2))
									.include(AMapUtil.convertToLatLng(mPoint3))
									.build();
							mAMap.moveCamera(CameraUpdateFactory
									.newLatLngBounds(bounds, 50));
						} else if ((mQuery.getBound().getShape()
								.equals(SearchBound.LOCAL_SHAPE))) {
							mPoiCloudOverlay.zoomToSpan();
						}

					} else {
						ToastUtil.show(this, R.string.no_result);
					}
				}
			} else {
				ToastUtil.show(this, R.string.no_result);
			}
		} else {
			ToastUtil.showerror(this, rCode);
		}

	}