为了账号安全,请及时绑定邮箱和手机立即绑定

有没有办法在 mapbox 中绘制半径为米的圆?

有没有办法在 mapbox 中绘制半径为米的圆?

隔江千里 2023-04-13 09:48:40
我正在尝试在 mapbox 中围绕用户当前位置绘制半径为 500 米的圆。当我使用下面提供的代码时,它会绘制一个大圆圈,它也不会随地图倾斜。CircleManager circleManager = new CircleManager(mapView, mapboxMap, style);CircleOptions options = new CircleOptions();options.withLatLng(new LatLng(location.getLatitude(), location.getLongitude()));options.withCircleRadius(500f);options.withCircleOpacity(0.5f);options.withCircleColor(ColorUtils.colorToRgbaString(getResources().getColor(R.color.blue2)));circleManager.create(options);我希望我的应用程序像这样工作:https://i.stack.imgur.com/huLZ3.gif 但目前我遇到了这个问题:
查看完整描述

1 回答

?
千巷猫影

TA贡献1829条经验 获得超7个赞

CircleManager 本身不支持此功能,但您可以使用mapbox-java中的 Turf将所需的属性转换为多边形/填充:

  /**
   * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians,
   * miles, or kilometers; and steps for precision. This uses the {@link #DEFAULT_STEPS} and
   * {@link TurfConstants#UNIT_DEFAULT} values.
   *
   * @param center a {@link Point} which the circle will center around
   * @param radius the radius of the circle
   * @return a {@link Polygon} which represents the newly created circle
   * @since 3.0.0
   */
  public static Polygon circle(@NonNull Point center, double radius) {    return circle(center, radius, 64, TurfConstants.UNIT_DEFAULT);
  }

您可以将此几何图形与注释插件中的 FillManager 结合使用。


查看完整回答
反对 回复 2023-04-13
?
qq_花开花谢_0

TA贡献1835条经验 获得超6个赞

查看完整回答
反对 回复 2023-04-13
  • 1 回答
  • 0 关注
  • 229 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信