当前位置: 首页>>代码示例>>Java>>正文


Java BitmapDescriptor类代码示例

本文整理汇总了Java中com.amap.api.maps.model.BitmapDescriptor的典型用法代码示例。如果您正苦于以下问题:Java BitmapDescriptor类的具体用法?Java BitmapDescriptor怎么用?Java BitmapDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitmapDescriptor类属于com.amap.api.maps.model包,在下文中一共展示了BitmapDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBitmapDes

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
 * 获取每个聚合点的绘制样式
 */
private BitmapDescriptor getBitmapDes(Cluster cluster) {
    View cluster_in_map = LayoutInflater.from(mContext).inflate(R.layout.view_cluster_in_map, null, false);
    RelativeLayout container = (RelativeLayout) cluster_in_map.findViewById(R.id.container);
    container.setLayoutParams(new ViewGroup.LayoutParams(dp2px(mContext, 70), dp2px(mContext, 70)));

    TextView cluster_count = (TextView) cluster_in_map.findViewById(R.id.cluster_count);
    ImageView first_image = (ImageView) cluster_in_map.findViewById(R.id.first_photo);

    if (cluster.getClusterCount() <= 1) {   //只有一个用户
        cluster_count.setVisibility(View.INVISIBLE);  //隐藏数量
    }
    cluster_count.setText(String.valueOf(cluster.getClusterCount()));
    first_image.setImageDrawable(getDrawAble((RegionItem) cluster.getClusterItems().get(0)));  //显示第一个用户的图片

    BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromView(cluster_in_map);

    return bitmapDescriptor;
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:22,代码来源:ClusterOverlay.java

示例2: ClusterOverlay

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
 * 构造函数,批量添加聚合元素时,调用此构造函数
 *
 * @param amap
 * @param clusterItems 聚合元素
 * @param clusterSize
 * @param context
 */
public ClusterOverlay(AMap amap, List<ClusterItem> clusterItems, int clusterSize, Context context) {
    //默认最多会缓存80张图片作为聚合显示元素图片,根据自己显示需求和app使用内存情况,可以修改数量
    mLruCache = new LruCache<Integer, BitmapDescriptor>(80) {
        protected void entryRemoved(boolean evicted, Integer key, BitmapDescriptor oldValue, BitmapDescriptor newValue) {
            oldValue.getBitmap().recycle();
        }
    };
    if (clusterItems != null) {
        mClusterItems = clusterItems;
    } else {
        mClusterItems = new ArrayList<>();
    }
    mContext = context;
    mClusters = new ArrayList<>();
    this.mAMap = amap;
    mClusterSize = clusterSize;
    mPXInMeters = mAMap.getScalePerPixel();
    mClusterDistance = mPXInMeters * mClusterSize;
    amap.setOnCameraChangeListener(this);
    amap.setOnMarkerClickListener(this);
    initThreadHandler();
    assignClusters();
}
 
开发者ID:xiaogu-space,项目名称:android-cluster-marker-master,代码行数:32,代码来源:ClusterOverlay.java

示例3: getBitmapDes

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
 * 获取每个聚合点的绘制样式
 */
private BitmapDescriptor getBitmapDes(int num) {
    BitmapDescriptor bitmapDescriptor = mLruCache.get(num);
    if (bitmapDescriptor == null) {
        TextView textView = new TextView(mContext);
        if (num > 1) {
            String tile = String.valueOf(num);
            textView.setText(tile);
        }
        textView.setGravity(Gravity.CENTER);
        textView.setTextColor(Color.BLACK);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
        if (mClusterRender != null && mClusterRender.getDrawAble(num) != null) {
            textView.setBackgroundDrawable(mClusterRender.getDrawAble(num));
        } else {
            textView.setBackgroundResource(R.drawable.defaultcluster);
        }
        bitmapDescriptor = BitmapDescriptorFactory.fromView(textView);
        mLruCache.put(num, bitmapDescriptor);

    }
    return bitmapDescriptor;
}
 
开发者ID:xiaogu-space,项目名称:android-cluster-marker-master,代码行数:26,代码来源:ClusterOverlay.java

示例4: addMarkerInBeijing

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void addMarkerInBeijing(int number) {
    Random random = new Random();

    //new LatLng(39.90403, 116.407525)
    double tem_lat = 39.9;
    double tem_lon = 116.4;
    BitmapDescriptor descriptor = BitmapDescriptorFactory.defaultMarker();
    if (number == 1) {
        aMap.addMarker(new MarkerOptions().position(new LatLng(tem_lat, tem_lon)).icon
                (descriptor));
        return;
    }

    for (int i = 0; i < number; i++) {
        LatLng latLng = new LatLng(tem_lat + random.nextDouble() * (random.nextBoolean() ? 1
                : -1), tem_lon + random.nextDouble() * (random.nextBoolean() ? 1 : -1));
        aMap.addMarker(new MarkerOptions().position(latLng).icon(descriptor));
    }

}
 
开发者ID:facexxyz,项目名称:SmoothMove,代码行数:21,代码来源:MainActivity.java

示例5: ClusterOverlay

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
     * 构造函数,批量添加聚合元素时,调用此构造函数
     *
     * @param amap
     * @param clusterItems 聚合元素
     * @param clusterSize
     * @param context
     */
    public ClusterOverlay(AMap amap, List<ClusterItem> clusterItems,
                          int clusterSize, Context context) {
//默认最多会缓存80张图片作为聚合显示元素图片,根据自己显示需求和app使用内存情况,可以修改数量
        mLruCache = new LruCache<Integer, BitmapDescriptor>(80) {
            protected void entryRemoved(boolean evicted, Integer key, BitmapDescriptor oldValue, BitmapDescriptor newValue) {
                oldValue.getBitmap().recycle();
            }
        };
        if (clusterItems != null) {
            mClusterItems = clusterItems;
        } else {
            mClusterItems = new ArrayList<ClusterItem>();
        }
        mContext = context;
        mClusters = new ArrayList<Cluster>();
        this.mAMap = amap;
        mClusterSize = clusterSize;
        mPXInMeters = mAMap.getScalePerPixel();
        mClusterDistance = mPXInMeters * mClusterSize;
        amap.setOnCameraChangeListener(this);
        amap.setOnMarkerClickListener(this);
        initThreadHandler();
        assignClusters();
    }
 
开发者ID:amap-demo,项目名称:android-cluster-marker,代码行数:33,代码来源:ClusterOverlay.java

示例6: SetUpMap2

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void SetUpMap2()
    {

        ArrayList<BitmapDescriptor> giflist = new ArrayList<BitmapDescriptor>();
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point1));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point2));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point3));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point4));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point5));

        //    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point6));
        marker = mapView.getMap().addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
                .icons(giflist).period(50));
        // 自定义系统定位小蓝点
        MyLocationStyle myLocationStyle = new MyLocationStyle();
//        myLocationStyle.myLocationIcon(BitmapDescriptorFactory
//                .fromResource(R.drawable.location_marker));// 设置小蓝点的图标
        myLocationStyle.strokeColor(Color.BLACK);// 设置圆形的边框颜色
        myLocationStyle.radiusFillColor(Color.argb(100, 0, 0, 180));// 设置圆形的填充颜色
        // myLocationStyle.anchor(int,int)//设置小蓝点的锚点
        myLocationStyle.strokeWidth(0.1f);// 设置圆形的边框粗细
        aMap.setMyLocationStyle(myLocationStyle);
//        aMap.setMyLocationRotateAngle(180);
        aMap.getUiSettings().setCompassEnabled(true);// 设置默认定位按钮是否显示
    }
 
开发者ID:Tsroad,项目名称:Road,代码行数:26,代码来源:SetFenceActivity.java

示例7: getBitmapDes

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
* 获取每个聚合点的绘制样式
* */
private BitmapDescriptor getBitmapDes(int num) {
	TextView textView = new TextView(mContext);
	if (num > 1) {
		String tile = String.valueOf(num);
		textView.setText(tile);
	}
	textView.setGravity(Gravity.CENTER);

	textView.setTextColor(Color.BLACK);
	textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
	if (mClusterRender != null && mClusterRender.getDrawAble(num) != null) {
		textView.setBackgroundDrawable(mClusterRender.getDrawAble(num));
	} else {
		textView.setBackgroundResource(R.drawable.defaultcluster);
	}
	return BitmapDescriptorFactory.fromView(textView);
}
 
开发者ID:amapapi,项目名称:Android_ClusterMarker,代码行数:21,代码来源:ClusterOverlay.java

示例8: getIcon

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
private BitmapDescriptor getIcon() {
    if (hasCustomMarkerView) {
        // creating a bitmap from an arbitrary view
        if (iconBitmapDescriptor != null) {
            //Bitmap viewBitmap = createDrawable();
            //int width = Math.max(iconBitmap.getWidth(), viewBitmap.getWidth());
            //int height = Math.max(iconBitmap.getHeight(), viewBitmap.getHeight());
            //Bitmap combinedBitmap = Bitmap.createBitmap(width, height, iconBitmap.getConfig());
            //Canvas canvas = new Canvas(combinedBitmap);
            //canvas.drawBitmap(iconBitmap, 0, 0, null);
            //canvas.drawBitmap(viewBitmap, 0, 0, null);
            //return BitmapDescriptorFactory.fromBitmap(combinedBitmap);
            ImageView image = (ImageView) this.view.findViewById(R.id.icon);
            Bitmap bitmap = MLRoundedImageView.getCroppedBitmap(Bitmap.createScaledBitmap(iconBitmap, 120, 120, true), 60);
            image.setImageBitmap(bitmap);
            return BitmapDescriptorFactory.fromView(this.view);
        } else {
            return BitmapDescriptorFactory.fromBitmap(createDrawable());
        }
    } else if (iconBitmapDescriptor != null) {
        // use local image as a marker
        return iconBitmapDescriptor;
    } else {
        // render the default marker pin
        return BitmapDescriptorFactory.defaultMarker(this.markerHue);
    }
}
 
开发者ID:laoqiu,项目名称:react-native-amap,代码行数:28,代码来源:AMapMarker.java

示例9: addPolylineInPlayGround

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void addPolylineInPlayGround() {
    List<LatLng> list = readLatLngs();
    List<Integer> colorList = new ArrayList<Integer>();
    List<BitmapDescriptor> bitmapDescriptors = new ArrayList<BitmapDescriptor>();

    int[] colors = new int[]{Color.argb(255, 0, 255, 0), Color.argb(255, 255, 255, 0), Color
            .argb(255, 255, 0, 0)};

    //用一个数组来存放纹理
    List<BitmapDescriptor> textureList = new ArrayList<BitmapDescriptor>();
    textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.custtexture));

    List<Integer> texIndexList = new ArrayList<Integer>();
    texIndexList.add(0);//对应上面的第0个纹理
    texIndexList.add(1);
    texIndexList.add(2);

    Random random = new Random();
    for (int i = 0; i < list.size(); i++) {
        colorList.add(colors[random.nextInt(3)]);
        bitmapDescriptors.add(textureList.get(0));

    }

    aMap.addPolyline(new PolylineOptions().setCustomTexture(BitmapDescriptorFactory
            .fromResource(R.drawable.custtexture)) //setCustomTextureList(bitmapDescriptors)
            //				.setCustomTextureIndex(texIndexList)
            .addAll(list)
            .useGradient(true)
            .width(18));
}
 
开发者ID:facexxyz,项目名称:SmoothMove,代码行数:32,代码来源:MainActivity.java

示例10: setDescriptor

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
public void setDescriptor(BitmapDescriptor descriptor) {
    if (this.descriptor != null) {
        this.descriptor.recycle();
    }
    this.descriptor = descriptor;
    if (marker != null) {
        marker.setIcon(descriptor);
    }
}
 
开发者ID:facexxyz,项目名称:SmoothMove,代码行数:10,代码来源:SmoothMarker.java

示例11: setUpMap

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
 * 设置一些amap的属性
 */
private void setUpMap() {
    ArrayList<BitmapDescriptor> giflist = new ArrayList<BitmapDescriptor>();
    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point1));
    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point2));
    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point3));
    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point4));
    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point5));
//    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point6));
    marker = aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
            .icons(giflist).period(50));
    // 自定义系统定位小蓝点
    MyLocationStyle myLocationStyle = new MyLocationStyle();
    myLocationStyle.myLocationIcon(BitmapDescriptorFactory
            .fromResource(R.drawable.location_marker));// 设置小蓝点的图标
    myLocationStyle.strokeColor(Color.BLACK);// 设置圆形的边框颜色
    myLocationStyle.radiusFillColor(Color.argb(100, 0, 0, 180));// 设置圆形的填充颜色
    // myLocationStyle.anchor(int,int)//设置小蓝点的锚点
    myLocationStyle.strokeWidth(0.1f);// 设置圆形的边框粗细
    aMap.setMyLocationStyle(myLocationStyle);
    aMap.setMyLocationRotateAngle(180);
    aMap.setLocationSource(this);// 设置定位监听
    aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
    aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
    //设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
    aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
}
 
开发者ID:Tsroad,项目名称:Road,代码行数:30,代码来源:PositionButtonActivity.java

示例12: setUpMap

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void setUpMap() {
        ArrayList<BitmapDescriptor> giflist = new ArrayList<BitmapDescriptor>();
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point1));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point2));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point3));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point4));
        giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point5));

        //    giflist.add(BitmapDescriptorFactory.fromResource(R.drawable.point6));
        marker = mapView.getMap().addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
                .icons(giflist).period(50));
        // 自定义系统定位小蓝点
        MyLocationStyle myLocationStyle = new MyLocationStyle();
//        myLocationStyle.myLocationIcon(BitmapDescriptorFactory
//                .fromResource(R.drawable.location_marker));// 设置小蓝点的图标
        myLocationStyle.strokeColor(Color.BLACK);// 设置圆形的边框颜色
        myLocationStyle.radiusFillColor(Color.argb(100, 0, 0, 180));// 设置圆形的填充颜色
        myLocationStyle.describeContents();
        // myLocationStyle.anchor(int,int)//设置小蓝点的锚点
        myLocationStyle.strokeWidth(0.1f);// 设置圆形的边框粗细
        aMap.setMyLocationStyle(myLocationStyle);
        aMap.setMyLocationRotateAngle(180);


        aMap.setLocationSource(this);// 设置定位监听
        aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
        aMap.getUiSettings().setCompassEnabled(true);// 设置默认定位按钮是否显示
//        aMap.getUiSettings().setZoomControlsEnabled(false);
        aMap.getUiSettings().setZoomPosition(AMapOptions.ZOOM_POSITION_RIGHT_CENTER);



        aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
        //设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
        aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);

    }
 
开发者ID:Tsroad,项目名称:Road,代码行数:38,代码来源:RouteActivity.java

示例13: onBeforeClusterRendered

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
 * Called before the marker for a Cluster is added to the map.
 * The default implementation draws a circle with a rough count of the number of items.
 */
protected void onBeforeClusterRendered(Cluster<T> cluster, MarkerOptions markerOptions) {
    int bucket = getBucket(cluster);
    BitmapDescriptor descriptor = mIcons.get(bucket);
    if (descriptor == null) {
        mColoredCircleBackground.getPaint().setColor(getColor(bucket));
        descriptor = BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket)));
        mIcons.put(bucket, descriptor);
    }
    // TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often)
    markerOptions.icon(descriptor);
}
 
开发者ID:jp1017,项目名称:TheSceneryAlong,代码行数:16,代码来源:DefaultClusterRenderer.java

示例14: choose

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
@Override
public void choose(MarkerOptions markerOptions, ClusterPoint clusterPoint) {
	Context context = contextRef.get();
	if (context != null) {
		Resources res = context.getResources();
		boolean isCluster = clusterPoint.size() > 1;
		boolean hasTwoToasters = clusterPoint.containsInputPoint(twoToasters);
		BitmapDescriptor icon;
		String title;
		if (isCluster) {
			title = res.getQuantityString(R.plurals.count_points, clusterPoint.size(), clusterPoint.size());
			int clusterSize = clusterPoint.size();
			if (hasTwoToasters) {
				icon = BitmapDescriptorFactory.fromBitmap(getClusterBitmap(res, R.drawable.ic_map_pin_cluster_toaster, clusterSize));
				title = res.getString(R.string.including_two_toasters, title);
			} else {
				icon = BitmapDescriptorFactory.fromBitmap(getClusterBitmap(res, R.drawable.ic_map_pin_cluster, clusterSize));
				title = res.getQuantityString(R.plurals.count_points, clusterSize, clusterSize);
			}
		} else {
			MarkerData data = (MarkerData)clusterPoint.getPointAtOffset(0).getTag();
			if (hasTwoToasters) {
				icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin_toaster);
				title = data.getLabel();
			} else {
				icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin);
				title = res.getString(R.string.point_number_x, data.getLabel());
			}
		}
		markerOptions.icon(icon);
		markerOptions.title(title);
		markerOptions.anchor(0.5f, 1.0f);
	}
}
 
开发者ID:mikezit,项目名称:cluster-amap,代码行数:35,代码来源:ToastedMarkerOptionsChooser.java

示例15: entryRemoved

import com.amap.api.maps.model.BitmapDescriptor; //导入依赖的package包/类
protected void entryRemoved(boolean evicted, Integer key, BitmapDescriptor oldValue, BitmapDescriptor newValue) {
    oldValue.recycle();
}
 
开发者ID:amap-demo,项目名称:android-collision-marker,代码行数:4,代码来源:RankerOverlay.java


注:本文中的com.amap.api.maps.model.BitmapDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。