Map and Moving Marker using Google Maps API

爷,独闯天下 提交于 2019-12-04 14:33:39

问题


I have to write a demo, that should work like Moving Map within Flight and need to draw same curved Polyline between two geo points / locations as you can see in below image.

Even, I would not mind switching to some other SDK like Mapbox SDK (If someone of you can really help me in getting What I need actually)

To draw a Polyline between two points, I am using:

   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);

    }

To Update Location and Animate Marker, I am using:

@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));
        }

    }

My Requirements:

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:


For Polyline google map use PolylineOptions

  1. curved line use z-index
  2. pattern() add dash item


来源:https://stackoverflow.com/questions/46103680/map-and-moving-marker-using-google-maps-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!