代码拉取完成,页面将自动刷新
ChinaMapView:这是一个可拖拽,可点击,可手势放大的自定义中国地图组件,使用简单,具备一个自定义View应有的基本素质
常规使用 | 下拉刷新及其他滑动冲突 |
---|---|
展示省份名字(1.0.2新增支持) | 只允许点击,不允许缩放和拖动(1.0.4新增支持) |
---|---|
属性(均包含set、get方法) | 类型 | 作用 |
---|---|---|
provinceslist | List | 包含所有的省份model |
isShowName | boolean | 设置是否展示省份名字 |
属性(均包含set、get方法) | 类型 | 作用 |
---|---|---|
color | int | 省份填充的颜色 |
normalBorderColor | int | 省份未选中状态下的边框颜色 |
selectBorderColor | int | 省份未选中状态下的边框颜色 |
nameColor | int | 省份名字颜色,每个省份名字的颜色可以不一致 |
方法 | 参数 | 作用 |
---|---|---|
setEnableTouch | boolean | 设置是否可以消费事件(默认为true) |
setEnableScroll | boolean | 设置是否可以缩放和拖动(默认为true) |
setScaleMin | int | 设置缩放的最小倍数,最终结果>=0 |
setScaleMax | int | 设置缩放的最大倍数,最终结果>=1 |
getChinaMapModel | ChinaMapModel | 返回ChinaMapModel对象,用于之后的修改刷新view的展示 |
setOnProvinceClickLisener | ChinaMapView.onProvinceClickLisener | 省份点击选中接口 |
setOnPromiseParentTouchListener | ChinaMapView.onPromiseParentTouchListener | 通知外界是否允许chinamapview之上的view拦截事件 |
notifyDataChanged | void | 修改ChinaMapModel对象后,刷新View |
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.NoEndToLF:ChinaMapView:1.0.4'
}
<com.wxy.chinamapview.view.ChinaMapView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/map"></com.wxy.chinamapview.view.ChinaMapView>
chinaMapModel = map.getChinaMapModel();
map.setScaleMin(1);
map.setScaleMax(3);
for (ProvinceModel provinceModel:chinaMapModel.getProvinceslist()){
provinceModel.setColor(color);
}
map.notifyDataChanged();
for (ProvinceModel provinceModel:chinaMapModel.getProvinceslist()){
provinceModel.setNormalBordercolor(color);
}
map.notifyDataChanged();
for (ProvinceModel provinceModel:chinaMapModel.getProvinceslist()){
provinceModel.setSelectBordercolor(color);
}
map.notifyDataChanged();
for (ProvinceModel provinceModel:chinaMapModel.getProvincesList()){
provinceModel.setNameColor(color);
}
map.notifyDataChanged();
map.setOnProvinceClickLisener(new ChinaMapView.onProvinceClickLisener() {
@Override
public void onSelectProvince(String provinceName) {
tvName.setText(provinceName);
}
});
chinamapView.setOnPromiseParentTouchListener(new ChinaMapView.onPromiseParentTouchListener() {
@Override
public void onPromiseTouch(boolean promise) {
swipe.setEnabled(promise);
}
});
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
chinamapView.setEnableTouch(false);
//模拟耗时
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
String namestring = ColorChangeUtil.nameStrings[++currentColor % ColorChangeUtil.nameStrings.length];
btnChange.setText(namestring);
colorView.setList(colorView_hashmap.get(namestring));
//重置map各省份颜色
ColorChangeUtil.changeMapColors(chinaMapModel, namestring);
chinamapView.notifyDataChanged();
swipe.setRefreshing(false);
chinamapView.setEnableTouch(true);
}
},2000);
}
});
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。