Android 定义路线之间的所有区域纬度和经度
我正在使用谷歌地图应用程序。当我定义一条路线时,例如从一号城市到二号城市。那么我如何才能得到一号城市和二号城市之间所有地方的经纬度呢Android 定义路线之间的所有区域纬度和经度,android,Android,我正在使用谷歌地图应用程序。当我定义一条路线时,例如从一号城市到二号城市。那么我如何才能得到一号城市和二号城市之间所有地方的经纬度呢 destinationid= (EditText) findViewById(R.id.destinationid); String clocation = destinationid.getText().toString(); List<Address> addressList=null; if(clocation!=
destinationid= (EditText) findViewById(R.id.destinationid);
String clocation = destinationid.getText().toString();
List<Address> addressList=null;
if(clocation!= null || clocation!="")
{
Geocoder geocoder=new Geocoder(this);
try {
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q="+clocation+""));
startActivity(intent);
addressList= geocoder.getFromLocationName(clocation,1);
}
catch (IOException e)
{
e.printStackTrace();
}
Address address= addressList.get(0);
LatLng latLng=new LatLng(address.getLatitude(),address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("Current Location "));
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.addMarker(new MarkerOptions().position(latLng).title("Current Location "));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15.0f));
mMap.animateCamera(CameraUpdateFactory.zoomIn()); mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null); CameraPosition cameraPosition = new CameraPosition.Builder()
.target(latLng)
.zoom(15)
.bearing(150)
.tilt(70)
.build();
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
mMap.setTrafficEnabled(true);
}'
destinationid=(EditText)findViewById(R.id.destinationid);
字符串clocation=destinationid.getText().toString();
List addressList=null;
if(clo阳离子!=null | | clo阳离子!=“”)
{
Geocoder Geocoder=新的Geocoder(本);
试一试{
意向意向=新意向(android.content.Intent.ACTION\u视图,
parse(“google.navigation:q=“+clocation+”);
星触觉(意向);
addressList=geocoder.getFromLocationName(clocation,1);
}
捕获(IOE异常)
{
e、 printStackTrace();
}
地址=地址列表。获取(0);
LatLng LatLng=新LatLng(address.getLatitude(),address.getLongitude());
mMap.addMarker(新的MarkerOptions().position(latLng.title)(“当前位置”);
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.addMarker(新的MarkerOptions().position(latLng.title)(“当前位置”);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,15.0f));
mMap.animateCamera(CameraUpdateFactory.zoomIn());mMap.animateCamera(CameraUpdateFactory.zoomTo(15),2000,null);CameraPosition CameraPosition=new CameraPosition.Builder()
.目标(latLng)
.zoom(15)
.轴承(150)
.倾斜(70)
.build();
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
mMap.setTrafficEnabled(真);
}'
要回答上述评论中的第一个问题,
1] 要显示路线上的任何特定点B,您可以使用标记
,这是google maps API的一项功能,有关此功能的详细信息,您可以找到
2] 要检查半径内是否有人,可以使用
Geo-fence
API。你可以找到更多细节为什么你想要纬度和经度的列表?实际上我正在做大学最后一年的项目。这是一个公交系统应用程序,当司机从位置A移动到位置C时,我希望在中间停车时收到通知,如位置B,其次,当我接近位置C时,半径几乎为25米,我想检查附近是否有学生……因此,如果你能帮我,我将非常高兴,请补充在你的问题中有上述描述,请在下面找到我的答案。事实上,标记器用于在地图上定位我想要的位置,当我到达位置b时,它应该会向驾驶员和学生发出通知……我还不专业,但我对地理围栏还不了解……如果你能提供更多指导。。