如何利用谷歌地图的路径,因为我搬家? [英] How to draw path on google map as I am moving?

查看:149
本文介绍了如何利用谷歌地图的路径,因为我搬家?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制路径谷歌地图。我能画出起点和终点之间的路径,但我想画的路径,因为我感动。请帮我画的路径,因为我上移动谷歌地图。

I am trying to draw path in google map. I am able to draw a path between start point and end point but I want to draw path as I am moving. Please help me to draw path as I am moving on google map.

谢谢 Monali

推荐答案

注册 LocationListener的和方法<一href="http://developer.android.com/reference/android/location/LocationListener.html#onLocationChanged%28android.location.Location%29"相对=nofollow> onLocationChanged 绘制起点,并且已经点之间的路径。

Register LocationListener and in method onLocationChanged draw a path between start point and the point that has come.

    private void addLocationListener(LocationListener locationListener) {
    LocationProvider locationProvider = getLocationManager().getProvider(LocationManager.GPS_PROVIDER);

    getLocationManager().requestLocationUpdates(locationProvider.getName(), LOCATION_UPDATE_INTERVAL,
            LOCATION_UPDATE_MIN_DISTANCE, locationListener);
}

private LocationManager getLocationManager() {
    return (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
}

private void startGpsListening(Location start) {
   this.startLocation = start;
   addLocationListener(new MyLocationListener());
}

private Location startLocation = new Location("");

private class MyLocationListener extends LocationListener {

    public void onLocationChanged(Location location) {
        Log.d(LOG_TAG, "New location has come: " + location);
        // draw path between startLocarion and this location
    }
    ...
}

这篇关于如何利用谷歌地图的路径,因为我搬家?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆