android实现显示雷达和谷歌地图上的圆形涟漪效应

描述:

android实现显示雷达和谷歌地图上的圆形涟漪效应

应用截图:

google

 

google

 

代码:

    // mMap is GoogleMap object, latLng is the location on map from which ripple should start

            MapRipple mapRipple = new MapRipple(mMap, latLng, context);
            mapRipple.startRippleMapAnimation();      //in onMapReadyCallBack

            @Override
            protected void onStop() {
                super.onStop();
                if (mapRipple.isAnimationRunning()) {
                    mapRipple.stopRippleMapAnimation();
                }
            }
    // Start Animation again only if it is not running
            if (!mapRipple.isAnimationRunning()) {
                mapRipple.startRippleMapAnimation();
            }

    // mMap is GoogleMap object, latLng is the location on map from which ripple should start

            mapRipple = new MapRipple(mMap, latLng, context);
            mapRipple.withNumberOfRipples(3);
            mapRipple.withFillColor(Color.BLUE);
            mapRipple.withStrokeColor(Color.BLACK);
            mapRipple.withStrokewidth(10);      // 10dp
            mapRipple.withDistance(2000);      // 2000 metres radius
            mapRipple.withRippleDuration(12000);    //12000ms
            mapRipple.withTransparency(0.5f);
            mapRipple.startRippleMapAnimation();
    // Use same procedure to stop Animation and start it again as mentioned anove in Default Ripple Animation Sample
// after implementing **LocationListener** interface to current class use:
        @Override
        public void onLocationChanged(Location location) {
            mapRipple.withLatLng(new LatLng(location.getLatitude(), location.getLongitude()));
        }
//See the sample for more help.

    // mMap is GoogleMap object, latLng is the location on map from which ripple should start

            MapRadar mapRadar = new MapRadar(mMap, latLng, context);
    mapRadar.withDistance(2000);
    mapRadar.withOuterCircleStrokeColor(Color.parseColor("#fccd29"));
    mapRadar.withRadarColors(Color.parseColor("#00fccd29"), Color.parseColor("#fffccd29"));
        //withRadarColors() have two parameters, startColor and tailColor respectively
        //startColor should start with transparency, here 00 in front of fccd29 indicates fully transparent
        //tailColor should end with opaqueness, here f in front of fccd29 indicates fully opaque
    mapRadar.startRadarAnimation();      //in onMapReadyCallBack

            @Override
            protected void onStop() {
                super.onStop();
                if (mapRadar.isAnimationRunning()) {
                    mapRadar.stopRadarAnimation();
                }
            }
    // mMap is GoogleMap object, latLng is the location on map from which ripple should start

            MapRadar mapRadar = new MapRadar(mMap, latLng, context);
    mapRadar.withDistance(2000);
    mapRadar.withOuterCircleStrokeColor(Color.parseColor("#fccd29"));
    mapRadar.withOuterCircleStrokewidth(7);
    mapRadar.withOuterCircleTransparency(0.4f);
    mapRadar.withClockWiseAnticlockwise(true);      //enable both side rotation
    mapRadar.withClockwiseAnticlockwiseDuration(2);
    //withClockwiseAnticlockwiseDuration(duration), here duration denotes how much cycles should animation makes in 
    //one direction
    mapRadar.withOuterCircleFillColor(Color.parseColor("#12000000"));            
    mapRadar.withRadarColors(Color.parseColor("#00fccd29"), Color.parseColor("#fffccd29"));
        //withRadarColors() have two parameters, startColor and tailColor respectively
        //startColor should start with transparency, here 00 in front of fccd29 indicates fully transparent
        //tailColor should end with opaqueness, here f in front of fccd29 indicates fully opaque
    mapRadar.withRadarSpeed(5); //controls radar speed
    mapRadar.withRadarTransparency(0.4f);
    mapRadar.startRadarAnimation();      //in onMapReadyCallBack

            @Override
            protected void onStop() {
                super.onStop();
                if (mapRadar.isAnimationRunning()) {
                    mapRadar.stopRadarAnimation();
                }
            }

源码下载:https://github.com/aarsy/GoogleMapsAnimations

未经允许不得转载:安度博客 » android实现显示雷达和谷歌地图上的圆形涟漪效应

赞 (0)
分享到:更多 ()

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址