腾讯地图

集成参考腾讯地图API官方文档 https://lbs.qq.com/index.html
腾讯地图参考手册: https://lbs.qq.com/AndroidDocs/doc_3d/index.html

腾讯地图定位,添加图层等都可以参考官方的demo
记录部分demo没有的方法

1.设置不要定位的蓝色圆圈

TencentMap tencentMap = mapview.getMap();
 MyLocationStyle myLocationStyle = new MyLocationStyle();
 myLocationStyle.strokeColor(Color.argb(0, 0, 0, 0));
 myLocationStyle.fillColor(Color.argb(0, 0, 0, 0));
 tencentMap.setMyLocationStyle(myLocationStyle);

2.地图移动到任意一个位置,或回到我的位置,带动画

 LatLng latLng = new LatLng(lat, lont);
//这个方法没有移动的动画, 是一下回到当前位置
 tencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));
//这个方法有移动的动画效果
 tencentMap.animateCamera(CameraUpdateFactory.newCameraPosition
                        (new CameraPosition(latLng, 16, 0, 0)), 500, null);

animateCamera官网的方法说明

#

3.自定义View添加标注,自定义样式添加图层,并为Marker添加点击事件, 设置Marker的时候设置一个tag,方便获取id

 /**
  * 自定义标注样式
  */
public View getMarkerCountView(String names, int icon) {
        View view = this.getLayoutInflater().inflate(R.layout.around_marker_items, null);
        ImageView imageView = view.findViewById(R.id.portratir);
        imageView.setImageResource(icon);
        TextView txt_count = view.findViewById(R.id.nameTv);
        txt_count.setText(names);
        return view;
    }

 View view = getMarkerCountView("标题", R.mipmap.tupian);
//显示资源图片的方法
//icon(BitmapDescriptorFactory.fromBitmap( BitmapFactory.decodeResource(getResources(), R.mipmap.liwu))).
//设置一个tag,当你需要点击Marker的时候,可以获取到相应的id
int tag=id;
 Marker zhouweimarker = tencentMap.addMarker(new MarkerOptions()
                        .tag(tags)
                        .position(new LatLng(lat, lnt))
                        .icon(BitmapDescriptorFactory.fromView(view))
                        .anchor(0.1f, 0.1f));
//标注的点击事件设置
tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                //这个tag就是我们在设置图层的时候设置的ID
                int id= marker.getTag();

                return false;
            }
        });

4.加减缩放地图

//把地图放大一级
 tencentMap.animateCamera(CameraUpdateFactory.zoomIn());
//把地图缩小一级
 tencentMap.animateCamera(CameraUpdateFactory.zoomOut());
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容