필자의 논문에서 안드로이드 구글 맵을 개발 중이다. 안드로이드에서 길 찾기에 대해 물어볼 수 있는가?안드로이드 구글 맵 운전 방향
여기 내 질문입니다.
"버튼을 클릭하면 무작위로 길 찾기를 시작하여 안드로이드 Google지도에서 임의의 운전 방향을 어떻게 생성 할 수 있습니까?"
고맙습니다!.
나는 이것을 통해 Google지도를 요청했습니다.
private void parsing(GeoPoint start, GeoPoint end) throws ClientProtocolException, IOException, JSONException, URISyntaxException{
HttpClient httpclient = new DefaultHttpClient();
StringBuilder urlstring = new StringBuilder();
urlstring.append("https://maps.googleapis.com/maps/api/directions/json?origin=")
.append(Double.toString((double)start.getLatitudeE6()/1E6)).append(",").append(Double.toString((double)start.getLongitudeE6()/1E6)).append("&destination=")
.append(Double.toString((double)end.getLatitudeE6()/1E6)).append(",").append(Double.toString((double)end.getLongitudeE6()/1E6))
.append("&sensor=false");
//urlstring.append("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=true");
url = new URI(urlstring.toString());
HttpPost httppost = new HttpPost(url);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = null;
is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line = "0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
reader.close();
String result = sb.toString();
JSONObject jsonObject = new JSONObject(result);
JSONArray routeArray = jsonObject.getJSONArray("routes");
JSONObject routes = routeArray.getJSONObject(0);
JSONObject overviewPolylines = routes.getJSONObject("overview_polyline");
String encodedString = overviewPolylines.getString("points");
List<GeoPoint> pointToDraw = decodePoly(encodedString);
//Added line:
mv_mapview.getOverlays().add(new RoutePathOverlay(pointToDraw));
}
지도에 표시되어 있습니다.
class MapOverlay extends Overlay {
@Override
public boolean onTap(final GeoPoint p, MapView mapView) {
// TODO Auto-generated method stub
geop_Tpoint = p;
mcon_mapcontrol = mapView.getController();
mcon_mapcontrol.animateTo(p);
mv_mapview.invalidate();
longitude = (int)(p.getLongitudeE6()*1E6);
latitude = (int)(p.getLatitudeE6()*1E6);
new AlertDialog.Builder(ShowMap.this)
.setTitle("Routes")
.setMessage("Display Routes?")
.setNegativeButton("NO",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
textlocation.setText("Tap in the Map for Destination!");
dialog.dismiss();
}
})
.setPositiveButton("YES",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
try{
textlocation.setText("");
parsing(geop_startpoint,geop_Tpoint);
geocodeExecuter(geop_startpoint,geop_Tpoint);
showButton.setEnabled(true);
}catch(Exception e){
textlocation.setText(""+ e.getMessage());
}
}
}).show();
showButton.setEnabled(true);
return true;
}
출발점은 GPS를 통해입니다 그것은 당신이지도를 Google에 방향을 물어 않는 방법에 따라 달라집니다 곳 메신저 I.
이 질문은 너무 광범위합니다. 너 뭐 해봤 니? – sschrass
미안하지만 내 문법은 유감 스럽다. 내 요점은 이것이다. 나는 출발점과 목적지 지점이있다. 이제 내 응용 프로그램은 JSON을 사용하여 시작 지점에서 대상 지점까지 경로를 그릴 수 있습니다. 제 질문은 어떻게하면 같은 지점으로 경로를 변경할 수 있습니까? 예를 들어 Google지도 v3에서 경로를 드래그 할 수 있지만 내가 그것을 생성하는 버튼을 사용합니다. – HaTeRs