百度地图相关
来源:互联网 发布:nba2k16麦迪捏脸数据 编辑:程序博客网 时间:2024/06/06 03:02
更换地图主题
将设置好的主题样式放入assets中
代码中(在setContentView(R.layout.activity_main)之前调用)
private void initBaiduMap(){ SDKInitializer.initialize(this); new Thread(new Runnable() { @Override public void run() { try { File mapStyleFile = new File(getFilesDir().getAbsolutePath() + "/custom_config_dark.txt");//主题样式的 if(!mapStyleFile.exists()) { InputStream is = getAssets().open("customConfigdir/custom_config_dark.txt"); FileOutputStream fos = new FileOutputStream(mapStyleFile); byte[] buffer = new byte[1024]; int byteCount = 0; while ((byteCount = is.read(buffer)) != -1) {//循环从输入流读取 buffer字节 fos.write(buffer, 0, byteCount);//将读取的输入流写入到输出流 } fos.flush();//刷新缓冲区 is.close(); fos.close(); } TextureMapView.setCustomMapStylePath(mapStyleFile.getAbsolutePath()); TextureMapView.setMapCustomEnable(true); } catch (Exception e){ e.printStackTrace(); } } }).start(); }
最后在需要出现这个地图主题的ativity中
map.setMapCustomEnable(true); //设置个性化地图样式是否生效
去除logo
View child = map.getChildAt(1); if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) { child.setVisibility(View.INVISIBLE); }
多个market的点击事件
循环设置market
private void setMarket(latitude,longitude) { LatLng point = new LatLng(latitude, longitude); //定义Maker坐标点// //构建Marker图标 BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.mipmap.ic_empoison_commonly); //构建MarkerOption,用于在地图上添加Marker OverlayOptions options = new MarkerOptions() .position(point) //设置marker的位置 .icon(bitmap) //设置marker图标// .zIndex(2) //设置marker所在层级 .draggable(false); //设置手势拖拽 //在地图上添加Marker,并显示 Overlay marker = mBaiduMap.addOverlay(options); Bundle bundle = new Bundle(); bundle.putSerializable("point", point); marker.setExtraInfo(bundle); } private void setCircle(latitude,longitude) { LatLng point = new LatLng(latitude,longitude); int circleColor = 0; switch (dataMap.type) { case 1: circleColor = getResources().getColor(R.color.item_good); break; case 2: circleColor = getResources().getColor(R.color.item_opacitas); break; case 3: circleColor = getResources().getColor(R.color.item_alga); break; case 4: circleColor = getResources().getColor(R.color.item_element); break; } OverlayOptions ooCircle = new CircleOptions() .fillColor(circleColor) .center(point)// .stroke(new Stroke(5, circleColor)) .radius(1400); mBaiduMap.addOverlay(ooCircle); }
onCreate中设置mBaiduMap的监听
mBaiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { DataMap dataMap = (DataMap) marker.getExtraInfo().get("point"); return true; } });
百度地图在listview/recyclerview的滑动冲突
mBaiduMap.setOnMapStatusChangeListener(new BaiduMap.OnMapStatusChangeListener() { LatLng startLng, finishLng; @Override public void onMapStatusChangeStart(MapStatus mapStatus) { startLng = mapStatus.target; } @Override public void onMapStatusChange(MapStatus mapStatus) { } @Override public void onMapStatusChangeFinish(MapStatus mapStatus) { // 滑动搜索 finishLng = mapStatus.target; if (startLng.latitude != finishLng.latitude || startLng.longitude != finishLng.longitude) { Projection ject = mBaiduMap.getProjection(); Point startPoint = ject.toScreenLocation(startLng); Point finishPoint = ject.toScreenLocation(finishLng); double x = Math.abs(finishPoint.x - startPoint.x); double y = Math.abs(finishPoint.y - startPoint.y); if (x > 50 || y > 50) { //在这处理滑动 ll_detail.setVisibility(View.GONE); } } } });
阅读全文
0 0
- 百度地图相关问题
- 百度地图相关
- 百度地图api相关
- 百度地图开发相关
- 百度地图相关
- 百度地图相关
- 百度地图相关整理
- 百度地图API相关点
- Android百度地图相关总结
- 百度地图开发相关技术
- 百度地图API相关教程
- 获取百度地图相关代码
- 百度地图Android API相关错误总结
- 关于百度地图二次开发相关资料下载
- 百度地图坐标系相关学习总结
- 基于百度地图的相关开发
- 百度地图开发之隐藏相关百度控件
- 百度地图相关(1)百度地图的首次默认加载
- Kali Linux(2)-VMware虚拟机安装Kali Linux 2017
- spawn expect send 命令使用方法
- PAT (Advanced Level) Practise 1037 Magic Coupon (25)
- Mac 安装使用Battery Historian遇到的问题
- noSql--redis笔记
- 百度地图相关
- ros移动机器人之SLAM (2)slam概述和一些杂七杂八的东西
- Dubbo与spring-boot使用
- hdu2255 奔小康赚大钱【最大权完美匹配】
- iOS hidesBottomBarWhenPushed的正确用法
- java编程语言关键字
- 原生js事件委托与简单的jquery事件委托方法
- 字符集互转的方法
- 在wap中启动 app(利用URL Scheme打开APP并传递数据 )