0
我在網絡中看到了這個 所以我確認可以在Google地圖的一個路徑中填寫2條不同的折線。在Google地圖中將折線對齊到道路邊緣
要試驗這個,我想先使用此代碼只添加一個折線:
public static void drawEncodedPolyOnMap(String encoded, GoogleMap map) {
List<LatLng> points = new ArrayList<>();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
LatLng p = new LatLng((((double) lat/1E5)),
(((double) lng/1E5)));
points.add(p);
}
map.addPolyline(new PolylineOptions().width(7).color(Color.RED).geodesic(true).addAll(points));
}
但它不給我,我預期
基本上顯示在我的情況下,即使標記位於道路邊緣,多段線也會居中對齊,這種情況我不喜歡發生。
是否可以將折線與Android中的標記對齊?怎麼樣?