Map and Moving Marker using Google Maps API
Asked Answered
O

1

2

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.

enter image description here

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)
Oribella answered 7/9, 2017 at 19:20 Comment(10)
Firstly you have to show your marker to current location. then draw the polyline between 2 point and continuously change the position of marker on Location change.Pretended
may I know why you want to close it... I already given good tries, wrote programs many times for the same... I've even people has asked direct questions here they used to get solution, but in mine case you are not thinking that I have given everything for 7 last to get this only.Oribella
@Pretended have a look at this: #46083418Oribella
You have not posted one line of code, yet you want us to write some for you...You should read stackoverflow.com/help/on-topic stackoverflow.com/help/dont-ask Try to visit the meta sites for this kind of question android.stackexchange.comCharlettecharley
@JonGoodwin I believe you have not visited so links those I have shared above... please check them...Oribella
I don't know why few people are voting to close it. Mates I have posted code, links, what I achieved and what I want everything above... this is my humble request work like a team to achieve this... please review my question one more time for me, for you and for usOribella
For #2 create 2 lines, one line is a thin line from origin to dest, the second line is a line with a thicker width from origin to current plane position. There is no "highlight" option for poyllinesEscurial
Is the use of Leaflet or OpenLayers on the side a possibility ? They do a bit more eye candy than google and they don't necessarily exclude one another.Horsemint
Suggestions are welcome :) target is to get this teamOribella
@Oribella do you know the flight coordinates from source to destination to draw curved polyline. You would also require the current lat lng point of the flight to draw solid polyline. Looking for vimeo.com/234121464 ?? The curved line may not be the flight path as in the video. But you would require flight path in a real scenario i guessThenna
G
1

For Polyline google map use PolylineOptions

  1. curved line use z-index
  2. pattern() add dash item
Ginsburg answered 16/9, 2017 at 22:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.