我正在嘗試在 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 結合使用。

qq_花開花謝_0
TA貢獻1835條經驗 獲得超7個贊
添加回答
舉報
0/150
提交
取消