快照 google 在两点之间映射 api v2
Snapshot google maps api v2 between two points
我正在 android 工作室做一个应用程序,我想做的是一个路线跟踪应用程序,用户触摸一个播放按钮,他可以在地图上看到一个标记和他的路线由折线绘制。
我已经这样做了,但我需要你的帮助,因为当用户触摸停止按钮时,我想拍摄完整路线(包括起点和终点)的快照,但我不知道如何这样做,因为如果路线很长并且缩放距离地图很近,那么起点将不会显示...
希望您能理解并帮助我! :)
对不起我的英语,我在我的代码中使用这个例子来缩放所有标记,它很简单我使用一个循环来添加 LatLng 并缩放所有.. 使用 CameraUpdateFactory.newLatLngBounds(bounds_latandlog,padding);
,然后你拍摄快照...
LatLngBounds.Builder builder = new LatLngBounds.Builder();
///this is an example
LatLng latLng;// create var LatLng
for(int i=0;i<=10;i++)// you will do a type of cycle, tu add lat and long
{
latLng = new LatLng(lat, lon);// in this line put you lat and long
builder.include(latLng); //add latlng to builder
}
//create a lat long bounds
LatLngBounds bounds = builder.build();
//create a padding of the points and the camera of the map
int padding = 0; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
//finally move the camera, to zoom all the polylines
/// move the camera
googleMap.moveCamera(cu);
//or animate the camera...
googleMap.animateCamera(cu);
这是link,了解更多信息
Android map v2 zoom to show all the markers
如果你看到错误,或者你有更好的语法,请解释我,我想学习它。
我正在 android 工作室做一个应用程序,我想做的是一个路线跟踪应用程序,用户触摸一个播放按钮,他可以在地图上看到一个标记和他的路线由折线绘制。
我已经这样做了,但我需要你的帮助,因为当用户触摸停止按钮时,我想拍摄完整路线(包括起点和终点)的快照,但我不知道如何这样做,因为如果路线很长并且缩放距离地图很近,那么起点将不会显示...
希望您能理解并帮助我! :)
对不起我的英语,我在我的代码中使用这个例子来缩放所有标记,它很简单我使用一个循环来添加 LatLng 并缩放所有.. 使用 CameraUpdateFactory.newLatLngBounds(bounds_latandlog,padding);
,然后你拍摄快照...
LatLngBounds.Builder builder = new LatLngBounds.Builder();
///this is an example
LatLng latLng;// create var LatLng
for(int i=0;i<=10;i++)// you will do a type of cycle, tu add lat and long
{
latLng = new LatLng(lat, lon);// in this line put you lat and long
builder.include(latLng); //add latlng to builder
}
//create a lat long bounds
LatLngBounds bounds = builder.build();
//create a padding of the points and the camera of the map
int padding = 0; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
//finally move the camera, to zoom all the polylines
/// move the camera
googleMap.moveCamera(cu);
//or animate the camera...
googleMap.animateCamera(cu);
这是link,了解更多信息
Android map v2 zoom to show all the markers
如果你看到错误,或者你有更好的语法,请解释我,我想学习它。