本文介绍了如何绘制我的当前位置地图到特定的纬度经度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用android创建Google Map,获取当前位置的纬度经度值并使用其他一些纬度经度值。现在如何在2位置绘制最短路径线。
我的主Activity.java:

I create the Google Map using android i get my current location latitude longitude values and using some other latitude longitude value.Now how to draw the shortest path line in 2 location.My Main Activity.java:

public class MainActivity extends Activity {
GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
            .getMap();
    map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    LatLng latLng = new LatLng(13.0847992, 80.2125527);
    map.addMarker(new MarkerOptions().position(latLng).title("Anna Nagar"));

    map.setMyLocationEnabled(true);
    map.getUiSettings().setZoomControlsEnabled(true);
    map.getUiSettings().setCompassEnabled(true);
    map.getUiSettings().setMyLocationButtonEnabled(true);
    map.getUiSettings().setAllGesturesEnabled(true);
    map.setTrafficEnabled(true);

}
}


推荐答案

在您的位置与另一个使用库的位置之间绘制一条路径。

Draw a path between your location to another location used MapNavigator library. It easy to used.

例如,

eg.

LatLng startLocation = new LatLng(start_lat, start_long);
LatLng endLocation = new LatLng(end_lat, end_long);

map.addMarker(new MarkerOptions().position(startLocation ).title("start"));
map.addMarker(new MarkerOptions().position(endLocation ).title("end"));

Navigator navigator = new Navigator(map, startLocation, endLocation);
navigator.findDirections(true);

这篇关于如何绘制我的当前位置地图到特定的纬度经度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 14:47
查看更多