Android 问题是,如何使用相同的点更改路径?例如,在Google map v3中,我可以拖动路径,但在我的情况下,我将使用按钮生成路径。在我的情况下,我通过GPS获得起点,而我的目的地是当我点击地图时。此时会出现一个对话框,要求生成路线/路径。。但是,如果我必须生成
Android 问题是,如何使用相同的点更改路径?例如,在Google map v3中,我可以拖动路径,但在我的情况下,我将使用按钮生成路径。在我的情况下,我通过GPS获得起点,而我的目的地是当我点击地图时。此时会出现一个对话框,要求生成路线/路径。。但是,如果我必须生成,android,Android,问题是,如何使用相同的点更改路径?例如,在Google map v3中,我可以拖动路径,但在我的情况下,我将使用按钮生成路径。在我的情况下,我通过GPS获得起点,而我的目的地是当我点击地图时。此时会出现一个对话框,要求生成路线/路径。。但是,如果我必须生成另一条路线/路径,我如何通过单击另一个按钮来实现呢?。非常感谢。非常感谢您的回答barkausen。。这给了我很多想法:)你对此有想法吗?。这是我的另一篇文章。。你能给我一些代码来帮助我吗?非常感谢。。我没有得到你的指导,因为我是安卓谷歌地图的
问题是,如何使用相同的点更改路径?例如,在Google map v3中,我可以拖动路径,但在我的情况下,我将使用按钮生成路径。在我的情况下,我通过GPS获得起点,而我的目的地是当我点击地图时。此时会出现一个对话框,要求生成路线/路径。。但是,如果我必须生成另一条路线/路径,我如何通过单击另一个按钮来实现呢?。非常感谢。非常感谢您的回答barkausen。。这给了我很多想法:)你对此有想法吗?。这是我的另一篇文章。。你能给我一些代码来帮助我吗?非常感谢。。我没有得到你的指导,因为我是安卓谷歌地图的初学者。:)我能帮你吗?你已经有了从谷歌地图解码数据的代码,你只需要找到Xa Xb和Ya Yb之间的一个浮点数,并将其放入请求中。在我的情况下,我通过GPS获得起点,我的目的地是当我点击地图时。此时会出现一个对话框,要求生成路线/路径。。但是,如果我必须生成另一条路线/路径,我如何通过单击另一个按钮来实现呢?。非常感谢。非常感谢您的回答barkausen。。这给了我很多想法:)你对此有想法吗?。这是我的另一篇文章。。你能给我一些代码来帮助我吗?非常感谢。。我没有得到你的指导,因为我是安卓谷歌地图的初学者。:)我能帮你吗?你已经有了从谷歌地图解码数据的代码,你只需要在xaxb和yayb之间找到一个浮点数,然后把它放到请求O.O中
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;
}
https://maps.google.com/maps?saddr=START_POINT&daddr=MIDDLE_POINT+to:DESTINATION_POINT
https://maps.google.com/maps?saddr=START_POINT&daddr=XX.YYYYY,WW.ZZZZZ+to:DESTINATION_POINT
public List<GeoPoint> findCoordinatesInACircle(double lat, double longi,double radius){
double newLat;
double newLong;
List<GeoPoint> searchpoints = new ArrayList<GeoPoint>();
double rLat=(radius/6371)*(180/Math.PI);
double rLon= rLat/Math.cos(longi * (Math.PI/180));
for(int i =0 ; i < 181; i++ ){
double iRad = i*(Math.PI/180);
newLat = lat + (rLat * Math.sin(iRad));
newLong = longi + (rLon * Math.cos(iRad));
GeoPoint onePoint = new GeoPoint((int)(float)(newLat),(int)(float)(newLong));
if(i%pointInterval == 0){
searchpoints.add(onePoint);
}
}
return searchpoints;
}
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=" + startLatitude + "," + startLongitude + "&daddr=" + destlat + "," + destlon));
startActivity(intent);