鸿蒙开源组件—省份地图组件

jacksky
发布于 2021-12-22 18:08
浏览
0收藏

 

ChinaMapView

项目介绍

  • 项目名称:ChinaMapView
  • 所属系列:openharmony的第三方组件适配移植
  • 功能:实现通过绘制map的方式进行统计,通过着色器来修改地图上各个组件颜色的操作(由于鸿蒙不支持事件分发机制不完善,导致滑动事件冲突未实现)
  • 项目移植状态:主功能完成
  • 调用差异:无
  • 基线版本 Release v1.0.4
  • 开发版本:sdk6,DevEco Studio2.2 Beta1

效果演示鸿蒙开源组件—省份地图组件-鸿蒙开发者社区

安装教程

1.在项目根目录下的build.gradle文件中,

allprojects {
   repositories {
       maven {
           url 'https://s01.oss.sonatype.org/content/repositories/releases/'
       }
   }
}

2.在entry模块的build.gradle文件中,

dependencies {
   implementation('com.gitee.chinasoft_ohos:chinamapview:1.0.0')
   implementation('com.gitee.chinasoft_ohos:ohos-colorpicker:1.0.0')
   ......  
}

在sdk6,DevEco Studio2.2 Beta1 下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下

使用说明

布局文件中引入ChinaMapView

 <com.noteam.chinamapview.HVScaleScrollView
                ohos:id="$+id:scrollView"
                ohos:width="match_parent"
                ohos:height="450vp"
                ohos:layout_alignment="center">
                <DirectionalLayout
                    ohos:id="$+id:rl_map"
                    ohos:width="match_parent"
                    ohos:height="450vp"
                    >
                    <com.noteam.chinamapview.ChinaMapView
                        ohos:id="$+id:mapView"
                        ohos:width="match_parent"
                        ohos:height="450vp"
                        ohos:layout_alignment="center"
                        />
                </DirectionalLayout>
   </com.noteam.chinamapview.HVScaleScrollView>

ChinaMapView 地图绘制主view, HVScaleScrollView是地图手势缩放的辅助类

 1. 通过Id获取组件
  mapView = (ChinaMapView) findComponentById(ResourceTable.Id_mapView);
 2. 设置是否缩放
  mapView.setOnlyClick(isChecked);  //isChecked 为false不缩放、ture 缩放

使用colorPicker

  打开diolog样式的着色器
         new ColorPickerPopup.Builder(this)
                        .initialColor(Color.RED.getValue())
                        .enableBrightness(true)
                        .enableAlpha(true)
                        .okTitle("确定")
                        .cancelTitle("取消")
                        .showIndicator(true)
                        .showValue(true)
                        .setButtonClickListener(new ColorPickerPopup.ButtonClickListener() {
                            @Override
                            public void okClick(int color) {
                                mapView.setProvinceColor(color);
                            }
                            @Override
                            public void cancelClick() {
                            }
                        })
                        .build()
                        .show(myLayout, new ColorPickerPopup.ColorPickerObserver() {
                            @Override
                            public void onColorPicked(int color) {
                                
                            }
                    });

MapView一些设置color的公共方法

method 参数类型 说明
setUnSelectBorderColor int color 设置未选中省份的边框颜色
setSelectBorderColor int color 修改选中省份的边框颜色
setProvinceColor int color 修改省份的颜色
isShowCityName boolean color 是否显示省份名称
setColorChangeListener interface ColorChangeListener 着色器颜色选择监听

测试信息

CodeCheck代码测试无异常

CloudTest代码测试无异常

病毒安全检测通过

当前版本demo功能与原组件基本无差异

版本迭代

  • 1.0.0

版权和许可信息

    Copyright (c) [2018] [static]
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

ChinaMapView-master.zip 3.74M 15次下载
已于2021-12-22 18:08:02修改
收藏
回复
举报
回复
    相关推荐