내 응용 프로그램은 java google map 웹 응용 프로그램입니다. 2 점을 받고 Google에 보내십시오 http://maps.googleapis.com/maps/api/directions/json?origin="+saddr+"&destination="+daddr+"&sensor=false
, 그것은 json을줍니다. 그럼 난 overview_polyline
디코딩을했습니다. 내 문제는 때로는 확장 된 가치를 부여합니다.Google지도 overview_polyline이 잘못된 값을 제공합니다.
이것은 내 디코드 부분입니다.
public static ArrayList<Location> decodePoly(String encoded) {
ArrayList<Location> poly = new ArrayList<Location>();
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;
Location p = new Location((((double) lat/1E5)),
(((double) lng/1E5)));
// System.out.println("==p==" +p.getLatitude());
// System.out.println("==p==" +p.getLongitude());
poly.add(p);
}
return poly;
}
검은 색 마크는 담당자가 해당 경로로 이동하지 않았다. 그러나 그 것처럼 그려졌다. http://maps.googleapis.com/maps/api/directions/json?origin=6.95522,79.8864&destination=6.96165,79.8958&sensor=false
이 overview_polyline
이 2 잘못된 경로가
이 을 그려 [email protected]}xqfNEkEM{@[email protected]@[email protected]@[email protected]@gA}@qD_DiDgD{MoN_DeDJEVGvBS
입니다 내 DB 샘플 데이터 ...
몇 가지 아이디어를 제공하세요? 문제가 무엇인가요? 사전에
감사합니다. 에 기재된
이 결과를 제공하는 샘플 출발지 및 도착지를 제공 할 수 있습니까? 디코딩 한 인코딩 된 폴리 라인을 제공 할 수 있습니까? 길을 따라가는 것처럼 보입니다. 요청한 것일 수도 있고 반환 된 폴리 라인에있는 것일 수도 있습니다. – geocodezip
샘플 코드 – Piraba
을 업데이트했습니다. 추가적으로 샘플 원본 및 대상이 예제 코드화 된 폴리 라인을 생성하는 것이 무엇인지 명확하지 않습니다. – geocodezip