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

The following examples show how to use com.amap.api.maps.model.LatLng. 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_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 #2
Source File: DrivingRouteOverlay.java    From TraceByAmap with MIT License 6 votes vote down vote up
private void addThroughPointMarker() {
    if (this.throughPointList != null && this.throughPointList.size() > 0) {
        LatLonPoint latLonPoint = null;
        for (int i = 0; i < this.throughPointList.size(); i++) {
            latLonPoint = this.throughPointList.get(i);
            if (latLonPoint != null) {
                throughPointMarkerList.add(mAMap
                        .addMarker((new MarkerOptions())
                                .position(
                                        new LatLng(latLonPoint
                                                .getLatitude(), latLonPoint
                                                .getLongitude()))
                                .visible(throughPointMarkerVisible)
                                .icon(getThroughPointBitDes())
                                .title("\u9014\u7ECF\u70B9")));
            }
        }
    }
}
 
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: 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 #5
Source File: PointsUtil.java    From SmoothMove with MIT License 6 votes vote down vote up
/**
 * 如果在垂足在端点,直接返回端点的下标
 *
 * @param points
 * @param point
 * @return
 */
public static Pair<Integer, LatLng> calShortestDistancePoint(List<LatLng> points, LatLng point) {
    List<DPoint> dPoints = new ArrayList<DPoint>();
    int index = 0;
    for (LatLng latLng : points) {
        dPoints.add(new DPoint(latLng.latitude, latLng.longitude));
        if (latLng.equals(point)) {
            return new Pair(index, point);
        }
        index++;
    }
    DPoint dPoint = new DPoint(point.latitude, point.longitude);
    Pair<Integer, DPoint> pair = calShortestDistancePoint(dPoints, dPoint);
    if (pair != null) {

        return new Pair(pair.first, new LatLng(pair.second.x, pair.second.y));
    }
    return null;
}
 
Example #6
Source File: AmapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
private void makeMarker(MyPoiModel poi, boolean isClear) {
    if (isClear) {
        clearMarker();
    }

    int distance = 0;
    if (null != BApp.MY_LOCATION) {
        distance = (int) AMapUtils.calculateLineDistance(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude()),
                new LatLng(poi.getLatitude(), poi.getLongitude()));
    }
    Marker marker = mAmap.addMarker(new MarkerOptions().position(new LatLng(poi.getLatitude(), poi.getLongitude())).title(poi.getName()).snippet(distance + "").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding_2)));
    markerList.add(marker);

    ((MainActivity) getActivity()).showPoiLay(poi, distance);

}
 
Example #7
Source File: TraceActivity_Simple.java    From TraceByAmap with MIT License 6 votes vote down vote up
public void initView() {

//		BitmapDescriptor mPoint = BitmapDescriptorFactory.fromResource(R.drawable.start);
//		// 设置司机定位点
//		MyLocationStyle myLocationStyle;
//		myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类
//		myLocationStyle.myLocationIcon(mPoint);
//		myLocationStyle.myLocationType(LOCATION_TYPE_LOCATE);//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
//		myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
//		aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
//		aMap.getUiSettings().setMyLocationButtonEnabled(true); // 设置默认定位按钮是否显示,非必需设置。
//		aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
//
//		lbsTraceClient = LBSTraceClient.getInstance(this);

		if (originPosList == null) {
			originPosList = new ArrayList<>();
			originPosList = TraceAsset.parseLocationsData(this.getAssets(),
					"traceRecord" + File.separator + "AMapTrace.txt");
			LatLng positionLatLng = new LatLng(originPosList.get(0).getLatitude(),originPosList.get(0).getLongitude());
			aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(positionLatLng, 16));
		}

		timer.schedule(task, 500, 500);
	}
 
Example #8
Source File: BusRouteOverlay.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
private void addRailwayMarkers(RouteRailwayItem railway) {
	LatLng Departureposition = AMapUtil.convertToLatLng(railway
			.getDeparturestop().getLocation());
	String Departuretitle = railway.getDeparturestop().getName()+"上车";
	String Departuresnippet = railway.getName();

	addStationMarker(new MarkerOptions().position(Departureposition).title(Departuretitle)
			.snippet(Departuresnippet).anchor(0.5f, 0.5f).visible(nodeIconVisible)
			.icon(getBusBitmapDescriptor()));
	
	
	LatLng Arrivalposition = AMapUtil.convertToLatLng(railway
			.getArrivalstop().getLocation());
	String Arrivaltitle = railway.getArrivalstop().getName()+"下车";
	String Arrivalsnippet = railway.getName();

	addStationMarker(new MarkerOptions().position(Arrivalposition).title(Arrivaltitle)
			.snippet(Arrivalsnippet).anchor(0.5f, 0.5f).visible(nodeIconVisible)
			.icon(getBusBitmapDescriptor()));
}
 
Example #9
Source File: BusRouteOverlay.java    From TraceByAmap with MIT License 6 votes vote down vote up
private void addRailwayMarkers(RouteRailwayItem railway) {
	LatLng Departureposition = AMapUtil.convertToLatLng(railway
			.getDeparturestop().getLocation());
	String Departuretitle = railway.getDeparturestop().getName()+"上车";
	String Departuresnippet = railway.getName();

	addStationMarker(new MarkerOptions().position(Departureposition).title(Departuretitle)
			.snippet(Departuresnippet).anchor(0.5f, 0.5f).visible(nodeIconVisible)
			.icon(getBusBitmapDescriptor()));
	
	
	LatLng Arrivalposition = AMapUtil.convertToLatLng(railway
			.getArrivalstop().getLocation());
	String Arrivaltitle = railway.getArrivalstop().getName()+"下车";
	String Arrivalsnippet = railway.getName();

	addStationMarker(new MarkerOptions().position(Arrivalposition).title(Arrivaltitle)
			.snippet(Arrivalsnippet).anchor(0.5f, 0.5f).visible(nodeIconVisible)
			.icon(getBusBitmapDescriptor()));
}
 
Example #10
Source File: MapActivity.java    From WechatHook-Dusan with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null
            && aMapLocation.getErrorCode() == 0) {
        //longitude = aMapLocation.getLongitude();
        //latitude = aMapLocation.getLatitude();
        if (!aMapLocation.getCountry().equals("中国")){
            changeToGoogleMapView();
        } else {
            amap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude), 15));
        }
        //Toast.makeText(context,aMapLocation.getCountry(),Toast.LENGTH_LONG).show();
        mIsAuto = false;
        mcheckbtn.setChecked(false);
        //setCurrentPositionInfo();
    } else {
        String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
        LogUtils.debug("AmapErr", errText);
        Toast.makeText(context, errText, Toast.LENGTH_LONG).show();
    }
}
 
Example #11
Source File: AMapViewManager.java    From react-native-amap with MIT License 6 votes vote down vote up
@ReactProp(name = "region")
public void setRegion(MapView mapView, @Nullable ReadableMap region) {
    if (region == null) return;
    AMap map = mapView.getMap();
    Double lat = region.getDouble("latitude");
    Double lng = region.getDouble("longitude");
    Double lngDelta = region.getDouble("longitudeDelta");
    Double latDelta = region.getDouble("latitudeDelta");
    LatLngBounds bounds = new LatLngBounds(
        new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
        new LatLng(lat + latDelta / 2, lng + lngDelta / 2)  // northeast
    );
    if (mapView.getHeight() <= 0 || mapView.getWidth() <= 0) {
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 10));
        boundsToMove = bounds;
    } else {
        map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
    }
}
 
Example #12
Source File: WalkRouteOverlay.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
/**
* 添加步行路线到地图中。
* @since V2.1.0
*/
  public void addToMap() {

      initPolylineOptions();
      try {
          List<WalkStep> walkPaths = walkPath.getSteps();
          mPolylineOptions.add(startPoint);
          for (int i = 0; i < walkPaths.size(); i++) {
              WalkStep walkStep = walkPaths.get(i);
              LatLng latLng = AMapServicesUtil.convertToLatLng(walkStep
                      .getPolyline().get(0));
              
		addWalkStationMarkers(walkStep, latLng);
              addWalkPolyLines(walkStep);
             
          }
          mPolylineOptions.add(endPoint);
          addStartAndEndMarker();

          showPolyline();
      } catch (Throwable e) {
          e.printStackTrace();
      }
  }
 
Example #13
Source File: AmapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void getFavoriteList() {
    if (null != mFavMarkerList && !mFavMarkerList.isEmpty()) {
        for (Marker o : mFavMarkerList) {
            o.remove();
        }
        mFavMarkerList.clear();
    }
    if (null != mFavoriteInteracter) {
        List<MyPoiModel> favoriteList = mFavoriteInteracter.getFavoriteList();
        if (null != favoriteList && !favoriteList.isEmpty()) {
            for (MyPoiModel poi : favoriteList) {
                BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.ic_grade_point_2);
                Marker marker = mAmap.addMarker(new MarkerOptions().position(new LatLng(poi.getLatitude(), poi.getLongitude())).title(poi.getName()).snippet("").anchor(0.5f, 0.5f).icon(bitmapDescriptor));
                mFavMarkerList.add(marker);
            }
        }
    }
}
 
Example #14
Source File: GaoDeMapAiLineManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
private void deleteMarker(boolean isMapPoint, LatLng homeLocation) {
    if (!isMapPoint) {
        if (this.mMarkerList.size() != 0) {
            this.mSelectMarker = (Marker) this.mMarkerList.get(this.mMarkerList.size() - 1);
        } else {
            return;
        }
    }
    if (this.mSelectMarker == null) {
        return;
    }
    if (((MapPointLatLng) this.mSelectMarker.getObject()).isIntertestPoint) {
        removeInterestPoint();
    } else {
        removeLinePoint(homeLocation);
    }
}
 
Example #15
Source File: RideRouteOverlay.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
/**
 * 添加骑行路线到地图中。
 * @since V3.5.0
 */
public void addToMap() {
	
	initPolylineOptions();
	try {
		List<RideStep> ridePaths = ridePath.getSteps();
		mPolylineOptions.add(startPoint);
		for (int i = 0; i < ridePaths.size(); i++) {
			RideStep rideStep = ridePaths.get(i);
			LatLng latLng = AMapUtil.convertToLatLng(rideStep
					.getPolyline().get(0));
			
			addRideStationMarkers(rideStep, latLng);
			addRidePolyLines(rideStep);
		}
		mPolylineOptions.add(endPoint);
		addStartAndEndMarker();
		
		showPolyline();
	} catch (Throwable e) {
		e.printStackTrace();
	}
}
 
Example #16
Source File: RideRouteOverlay.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 添加骑行路线到地图中。
 * @since V3.5.0
 */
public void addToMap() {
	
	initPolylineOptions();
	try {
		List<RideStep> ridePaths = ridePath.getSteps();
		for (int i = 0; i < ridePaths.size(); i++) {
			RideStep rideStep = ridePaths.get(i);
			LatLng latLng = AMapUtil.convertToLatLng(rideStep
					.getPolyline().get(0));
			
			addRideStationMarkers(rideStep, latLng);
			addRidePolyLines(rideStep);
		}
		addStartAndEndMarker();
		
		showPolyline();
	} catch (Throwable e) {
		e.printStackTrace();
	}
}
 
Example #17
Source File: GeoFence_Polygon_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
private void resetView_polygon() {
	tvGuide.setBackgroundColor(getResources().getColor(R.color.red));
	tvGuide.setText("请点击地图选择围栏的边界点,至少3个点");
	tvGuide.setVisibility(View.VISIBLE);
	tvGuide.setVisibility(View.VISIBLE);
	polygonPoints = new ArrayList<LatLng>();
	btAddFence.setEnabled(false);
}
 
Example #18
Source File: GeoFence_Round_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
private void drawCircle(GeoFence fence) {
	LatLng center = new LatLng(fence.getCenter().getLatitude(),
			fence.getCenter().getLongitude());
	// 绘制一个圆形
	mAMap.addCircle(new CircleOptions().center(center)
			.radius(fence.getRadius()).strokeColor(Const.STROKE_COLOR)
			.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH));
	boundsBuilder.include(center);
}
 
Example #19
Source File: GeoFence_Nearby_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
private void drawCircle(GeoFence fence) {
	LatLng center = new LatLng(fence.getCenter().getLatitude(),
			fence.getCenter().getLongitude());
	// 绘制一个圆形
	mAMap.addCircle(new CircleOptions().center(center)
			.radius(fence.getRadius()).strokeColor(Const.STROKE_COLOR)
			.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH));
	boundsBuilder.include(center);
}
 
Example #20
Source File: PolylineActivitybase.java    From TraceByAmap with MIT License 5 votes vote down vote up
private List<LatLng> readLatLngs() {
	List<LatLng> points = new ArrayList<LatLng>();
	for (int i = 0; i < coords.length; i += 2) {
		points.add(new LatLng(coords[i+1], coords[i]));
	}
	return points;
}
 
Example #21
Source File: AmapSelectPoiFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
public void requestLoc() {
    if (clickLocNum++ > 1) {
        clickLocNum = 0;
    }

    isRequest = true;
    if (null != mLocClient) {


        if (clickLocNum == 2) {
            btnLocation.setImageResource(R.drawable.ic_explore_24dp);
            mLocClient.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE);
            mAmap.setMyLocationStyle(mLocClient);
            Toast.makeText(getActivity(), "罗盘模式", Toast.LENGTH_SHORT).show();
        } else {
            btnLocation.setImageResource(R.drawable.ic_my_location_24dp);
            mLocClient.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
            mAmap.setMyLocationStyle(mLocClient);

            mAmap.moveCamera(CameraUpdateFactory.changeBearing(0));
            mAmap.moveCamera(CameraUpdateFactory.changeTilt(0));

        }

        if (null != BApp.MY_LOCATION) {
            mAmap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())));
        }


    } else {
        initAmapSdk();
    }
}
 
Example #22
Source File: PolylineActivitybase.java    From TraceByAmap with MIT License 5 votes vote down vote up
private void addPolylinesWithTexture() {
	//四个点
	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);
	
	//用一个数组来存放纹理
	List<BitmapDescriptor> texTuresList = new ArrayList<BitmapDescriptor>();
	texTuresList.add(BitmapDescriptorFactory.fromResource(R.drawable.map_alr));
	texTuresList.add(BitmapDescriptorFactory.fromResource(R.drawable.custtexture));
	texTuresList.add(BitmapDescriptorFactory.fromResource(R.drawable.map_alr_night));
	
	//指定某一段用某个纹理,对应texTuresList的index即可, 四个点对应三段颜色
	List<Integer> texIndexList = new ArrayList<Integer>();
	texIndexList.add(0);//对应上面的第0个纹理
	texIndexList.add(2);
	texIndexList.add(1);
	
	
	PolylineOptions options = new PolylineOptions();
	options.width(20);//设置宽度
	
	//加入四个点
	options.add(A,B,C,D);
	
	//加入对应的颜色,使用setCustomTextureList 即表示使用多纹理;
	options.setCustomTextureList(texTuresList);
	
	//设置纹理对应的Index
	options.setCustomTextureIndex(texIndexList);
	
	aMap.addPolyline(options);
}
 
Example #23
Source File: GeoFence_Nearby_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {
	markerOption.icon(ICON_YELLOW);
	centerLatLng = latLng;
	addCenterMarker(centerLatLng);
	tvGuide.setBackgroundColor(getResources().getColor(R.color.gary));
	tvGuide.setText("选中的坐标:" + centerLatLng.longitude + ","
			+ centerLatLng.latitude);
}
 
Example #24
Source File: DrivingRouteOverlay.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 获取两点间距离
 *
 * @param start
 * @param end
 * @return
 */
public static int calculateDistance(LatLng start, LatLng end) {
    double x1 = start.longitude;
    double y1 = start.latitude;
    double x2 = end.longitude;
    double y2 = end.latitude;
    return calculateDistance(x1, y1, x2, y2);
}
 
Example #25
Source File: AmapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
public void requestLoc() {
    if (clickLocNum++ > 1) {
        clickLocNum = 0;
    }

    isRequest = true;
    if (null != mLocClient) {


        if (clickLocNum == 2) {
            btnLocation.setImageResource(R.drawable.ic_explore_24dp);
            mLocClient.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE);
            mAmap.setMyLocationStyle(mLocClient);
            Toast.makeText(getActivity(), "罗盘模式", Toast.LENGTH_SHORT).show();
        } else {
            btnLocation.setImageResource(R.drawable.ic_my_location_24dp);
            mLocClient.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
            mAmap.setMyLocationStyle(mLocClient);

            mAmap.moveCamera(CameraUpdateFactory.changeBearing(0));
            mAmap.moveCamera(CameraUpdateFactory.changeTilt(0));

        }

        if (null != BApp.MY_LOCATION) {
            mAmap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())));
        }


    } else {
        initAmapSdk();
    }
}
 
Example #26
Source File: GeoFence_Round_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {
	markerOption.icon(ICON_YELLOW);
	centerLatLng = latLng;
	addCenterMarker(centerLatLng);
	tvGuide.setBackgroundColor(getResources().getColor(R.color.gary));
	tvGuide.setText("选中的坐标:" + centerLatLng.longitude + ","
			+ centerLatLng.latitude);
}
 
Example #27
Source File: AmapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void makeRangingMarker(MyPoiModel poi) {
    //构建Marker图标
    ImageView imageView = new ImageView(getActivity());
    imageView.setImageResource(R.drawable.shape_point);

    BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(imageView);

    Marker marker = mAmap.addMarker(new MarkerOptions().icon(bitmap).anchor(0.5f, 0.5f).position(new LatLng(poi.getLatitude(), poi.getLongitude())));

    if (null == mRangingMarkerList) {
        mRangingMarkerList = new ArrayList<>();
    }
    mRangingMarkerList.add(marker);
}
 
Example #28
Source File: GeoFence_Round_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
private void drawCircle(GeoFence fence) {
	LatLng center = new LatLng(fence.getCenter().getLatitude(),
			fence.getCenter().getLongitude());
	// 绘制一个圆形
	mAMap.addCircle(new CircleOptions().center(center)
			.radius(fence.getRadius()).strokeColor(Const.STROKE_COLOR)
			.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH));
	boundsBuilder.include(center);
}
 
Example #29
Source File: GeoFence_Multiple_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
private void drawCircle(GeoFence fence) {
	LatLng center = new LatLng(fence.getCenter().getLatitude(),
			fence.getCenter().getLongitude());
	// 绘制一个圆形
	mAMap.addCircle(new CircleOptions().center(center)
			.radius(fence.getRadius()).strokeColor(Const.STROKE_COLOR)
			.fillColor(Const.FILL_COLOR).strokeWidth(Const.STROKE_WIDTH));
	boundsBuilder.include(center);
}
 
Example #30
Source File: BusRouteOverlay.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * @param busStep
 */
private void addWalkSteps(BusStep busStep) {
	RouteBusWalkItem routeBusWalkItem = busStep.getWalk();
	List<WalkStep> walkSteps = routeBusWalkItem.getSteps();
	for (int j = 0; j < walkSteps.size(); j++) {
		WalkStep walkStep = walkSteps.get(j);
		if (j == 0) {
			LatLng latLng = AMapUtil.convertToLatLng(walkStep
					.getPolyline().get(0));
			String road = walkStep.getRoad();// 道路名字
			String instruction = getWalkSnippet(walkSteps);// 步行导航信息
			addWalkStationMarkers(latLng, road, instruction);
		}

		List<LatLng> listWalkPolyline = AMapUtil
				.convertArrList(walkStep.getPolyline());
		this.latLng = listWalkPolyline.get(listWalkPolyline.size() - 1);

		addWalkPolyline(listWalkPolyline);

		// 假如步行前一段的终点和下的起点有断开,断画直线连接起来,避免断线问题
		if (j < walkSteps.size() - 1) {
			LatLng lastLatLng = listWalkPolyline.get(listWalkPolyline
					.size() - 1);
			LatLng firstlatLatLng = AMapUtil
					.convertToLatLng(walkSteps.get(j + 1).getPolyline()
							.get(0));
			if (!(lastLatLng.equals(firstlatLatLng))) {
				addWalkPolyline(lastLatLng, firstlatLatLng);
			}
		}

	}
}