簡體   English   中英

在Google Maps上畫一個圓靜態鏈接

[英]Drawing a circle on google maps static link

根據此SO答案https://stackoverflow.com/a/38100481/1520234 ,我嘗試通過向getCircleAsPolyline提供Location數據,然后使用PolyUtil.encode進行編碼,在靜態地圖上繪制圓。

不幸的是,輸出結果不是一個圓,而是類似以下內容:

輸出

有人可以請我解釋為什么會這樣嗎,是否有可能形成一個真正的圈子,如果是這樣,怎么做?

謝謝

編輯

抱歉,我不太清楚,我忘了提到我的getCircleAsPolyline與鏈接的對象略有不同,因為我使用SphericalUtil.computeOffset來計算坐標; 無論如何,下面是我的getCircleAsPolyline函數:

private static ArrayList<LatLng> getCircleAsPolyline(Location center, float radius) {
    ArrayList<LatLng> circlePath = new ArrayList<>();
    double step = 5.0;
    double centerLatitude = center.getLatitude();
    double centerLongitude = center.getLongitude();
    for (double angle = 0.0; angle < 360.0; angle += step) {
        LatLng circlePoint = SphericalUtil.computeOffset(
                new LatLng(centerLatitude, centerLongitude),
                radius,
                (90.0 - angle + 360.0) % 360.0
        );
        circlePath.add(circlePoint);
    }
    return circlePath;
}

但結果是圖片中顯示的那個

對於那些來這里也遇到相同問題的人,我只是避免了對折線進行編碼:只要我放下PolyUtil.encode並將點附加為|,就有效。 長,經度| 我已經能夠畫出一個完美的圓圈。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM