使用Google Maps API地图和移动标记

时间:2017-09-07 19:20:50

标签: android google-maps google-maps-api-3 android-maps-v2

我必须编写演示,它应该像在飞行中移动地图一样工作,并且需要绘制相同的曲线 Polyline between two geo points / locations 正如你在下面的图片中看到的那样。

enter image description here

即便如此,我would not mind switching还有一些其他SDK,例如 Mapbox SDK (如果有人可以really help me in getting我实际需要什么)

要在两点之间绘制折线,我正在使用:

   private void polyLine() {

        LatLng starting = new LatLng(##.######, ##.######);
        LatLng ending = new LatLng(##.######, ##.######);

        PolylineOptions line = new PolylineOptions().add(starting, ending);

        mGoogleMap.addMarker(new MarkerOptions().position(starting).title("Start"));
        mGoogleMap.addMarker(new MarkerOptions().position(ending).title("End"));

        mGoogleMap.addPolyline(line);

    }

要更新位置和动画标记,我正在使用:

@Override
    public void onLocationChanged(Location location)
    {
        Toast.makeText(this, "Location Changed " + location.getLatitude()
                + location.getLongitude(), Toast.LENGTH_LONG).show();

        mLastLocation = location;

        if (mCurrLocationMarker != null) {
            mCurrLocationMarker.remove();
        }

        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

        if(ourGlobalMarker == null) { // First time adding marker to map
            ourGlobalMarker = mGoogleMap.addMarker(new MarkerOptions().position(latLng)
                    .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)));
            MarkerAnimation.animateMarkerToICS(ourGlobalMarker, latLng, new LatLngInterpolator.Spherical());
            mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
        } else {
            MarkerAnimation.animateMarkerToICS(ourGlobalMarker, latLng, new LatLngInterpolator.Spherical());
            mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
        }

    }

我的要求:

POLYLINE

1. I have to create a Polyline the same you can see in attached image (curved one) 

1.1. Dotted curved (if area not started yet)

1.2. Regular curved (in case area already covered)

CURRENT MARKER

2. Showing current Location marker at right side of Polyline 

(whereas, I want to show Animate marker on Polyline path)

1 个答案:

答案 0 :(得分:1)

对于折线谷歌地图,请使用PolylineOptions

  1. 曲线使用z-index
  2. pattern()添加短划线项目