本文介绍了动画或移动标记以及GoogleMap上的溃败路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用google maps,我陷入了非常危急的境地.实际上,我想为标记和多段线(绘制的折线)设置动画,在这方面,我尝试了许多代码,但没有一种方法会被激发.

First time i am working with google maps and i am stuck in very critical situation.Actually i want to animate marker along with poly line(rout drawn), in this regard i have been attempted many codes but not single one approach is going to fire.

我正在使用什么方法,这是我第一次画出黑白相间的骑手和用户目的地,在病房结束后,随着骑手的经久变化,我将他的经久推向火力基地.同时,我在地图上将骑手到用户端的更新时间延长了,然后进行了抽奖.

What approach i am using that is first time i draw a rout b/w rider and user destinations, After Ward as the lat long of rider is changes i push his lat long to firebase. Meanwhile i am getting the update lat long of rider to user side in map and then rout draw.

为了让您更好地理解,这里是我的代码.

For your better understanding here is my code.

这是我如何绘制黑白骑手和用户的路...

Here is how i draw path b/w rider and user...

public void pathDraw(String startLat,String startLon,String endLat,String endLon,int orginDrawable, int desTinationDrawable){

    LatLng origin = new LatLng(Double.parseDouble(startLat), Double.parseDouble(startLon));
    LatLng destination = new LatLng(Double.parseDouble(endLat), Double.parseDouble(endLon));
    DrawRouteMaps.getInstance(this)
            .draw(origin, destination, mGoogleMap);
    DrawMarker.getInstance(this).draw(mGoogleMap, origin,orginDrawable, "Origin Location");
    DrawMarker.getInstance(this).draw(mGoogleMap, destination, desTinationDrawable, "Destination Location");
    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(origin)
            .include(destination).build();
    Point displaySize = new Point();
    getWindowManager().getDefaultDisplay().getSize(displaySize);
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, displaySize.x, 1000, 15));
}

这是每次长时间更新后的Firebase方法.

And here is the Firebase method cal every time when lat long update.

  public void mapChangeAnimation(final boolean user){
    mDatebaseTracking.keepSynced(true);
    DatabaseReference query = mDatebaseTracking.child(order_id);

    query.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            rider_lat = ""+dataSnapshot.child("rider_lat").getValue();
            rider_long = ""+dataSnapshot.child("rider_long").getValue();
            String latlong = rider_lat + " "+ rider_long;

            if(!user) {
                LatLng latLngBegin = new LatLng(Double.parseDouble(rider_lat),Double.parseDouble(rider_long));
                LatLng latLngEnd = new LatLng(Double.parseDouble(rest_lat),Double.parseDouble(rest_long));
            }
            else {
                LatLng latLngBegin = new LatLng(Double.parseDouble(rider_lat),Double.parseDouble(rider_long));
                LatLng latLngEnd = new LatLng(Double.parseDouble(user_lat),Double.parseDouble(user_long));
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}

您的建议将不胜感激.另外,如果您请根据我的情况发布代码.预先感谢

You suggestion will be appreciated. Also if you please post a code according to my scenario.Thanks in advance

推荐答案

要沿从起点到终点的路径对标记进行动画处理,可以参考此代码.

To animate your marker along the route path from starting point to an ending point, you can refer to this code.

https://gist.github.com/broady/6314689

如果想要更轻松地实现,可以使用可用的库来完成此操作.

If you want for easier implementation, you can use libraries available to do the same.

  1. https://github.com/amalChandran/trail-android
  2. https://github.com/amanjeetsingh150/UberCarAnimation
  1. https://github.com/amalChandran/trail-android
  2. https://github.com/amanjeetsingh150/UberCarAnimation

这些库没有确切的实现,您可能需要对其进行一些调整.

The libraries do not have exact implementation and you may have to tweak it a bit.

这篇关于动画或移动标记以及GoogleMap上的溃败路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:53
查看更多