Android 百度地图2.4.2版本标注动画效果

 ImageView latestMapEventImageView = null;
    // 更新震中位置
    private void updateMapEventOverlay() {      
        mMapEventOverlay.removeAll();
        if (latestMapEventImageView != null) {
			mMapView.removeView(latestMapEventImageView);
			latestMapEventImageView.setImageDrawable(null);
			latestMapEventImageView = null;
			mMapView.refreshDrawableState();
		}
        for (int i = 0; i < currentEqEventList.size(); i++) {
        	String eventId = currentEqEventList.get(i).DzEventId;
        	String eventLevel = currentEqEventList.get(i).DzLevel;
        	String eventLongitude = currentEqEventList.get(i).DzLon;
        	String eventLatitude = currentEqEventList.get(i).DzLat;
            float fLevel = 0;
            float fLatitude = 0;
            float fLongitude = 0;
            
            try {
                fLevel = Float.parseFloat(eventLevel);
                fLongitude = Float.parseFloat(eventLongitude);
                fLatitude = Float.parseFloat(eventLatitude);
            } catch (Exception e) {
                e.printStackTrace();
            }
            
            // 转GPS坐标为百度坐标
            GeoPoint point = CoordinateConvert.fromWgs84ToBaidu(
                    new GeoPoint((int)(fLatitude * 1e6), (int)(fLongitude * 1e6)));
            OverlayItem item = new OverlayItem(point, eventId, "");
            TextView mapEventView;
            if (fLevel > 6.9) {
                // 大圈
                mapEventView = (TextView)findViewById(
                        R.id.mymap_bottombar_control_dzpos_lv3);
            } else if (fLevel > 3.9) {
                // 中圈
                mapEventView = (TextView)findViewById(
                        R.id.mymap_bottombar_control_dzpos_lv2);
            } else {
                // 小圈
                mapEventView = (TextView)findViewById(
                        R.id.mymap_bottombar_control_dzpos_lv1);
            }
            
            
            mapEventView.setText("" + fLevel);            
            Bitmap bmpMpuMarket = getBitmapFromView(mapEventView);
            Drawable drawableMpuMarket = new BitmapDrawable(
                    getResources(), bmpMpuMarket);
                      
            
            if (i == 0) {
            	MapView.LayoutParams mapviewLp = new MapView.LayoutParams(  
                        MapView.LayoutParams.WRAP_CONTENT,MapView.LayoutParams.WRAP_CONTENT,  
                        point,MapView.LayoutParams.BOTTOM_CENTER);    
	                      
            	latestMapEventImageView=new ImageView(mContext);  
            	latestMapEventImageView.setImageResource(R.drawable.map_icon_earthquake_lv3);
	            //iv.setImageDrawable(drawableMpuMarket);
	            AlphaAnimation alphaAnimation1 = new AlphaAnimation(0.1f, 1.0f);  
	            alphaAnimation1.setDuration(1000);  
	            alphaAnimation1.setRepeatCount(Animation.INFINITE);  
	            alphaAnimation1.setRepeatMode(Animation.REVERSE);  
	            latestMapEventImageView.setAnimation(alphaAnimation1);  
	            alphaAnimation1.start(); 
	            
//	            Animation anim=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.anim_mapevent);
//	            iv.setAnimation(anim);  	      
	            mMapView.addView(latestMapEventImageView,mapviewLp);  
			}
            else {
            	 item.setMarker(drawableMpuMarket); 
            	 mMapEventOverlay.addItem(item);  
			}        
                      
		}        
        mMapView.refresh();
    }

  

posted on 2015-06-19 14:45  Alwaysyouare  阅读(854)  评论(0编辑  收藏  举报

导航