All Projects → NoEndToLF → Chinamapview

NoEndToLF / Chinamapview

自定义View,可缩放、可平移、可点击的中国地图,有中国地图的全部省份,具备每个省份的点击接口

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Chinamapview

ChinaMapView
自定义View,可缩放、可平移、可点击的中国地图,有中国地图的全部省份,具备每个省份的点击接口
Stars: ✭ 1,211 (-3.12%)
Mutual labels:  map, android-view
Yiqingditu
新冠肺炎,疫情地图
Stars: ✭ 79 (-93.68%)
Mutual labels:  map
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (-9.76%)
Mutual labels:  map
Map
PHP Map package for easy and elegant handling of PHP arrays as array-like map objects
Stars: ✭ 1,180 (-5.6%)
Mutual labels:  map
Cluster
Easy Map Annotation Clustering 📍
Stars: ✭ 1,132 (-9.44%)
Mutual labels:  map
Agilework
可视化低代码快速开发平台,面向业务、企业管理系统定制开发平台和应用平台,包括设计器、应用端。提供业务配置和集成开发能力,用户通过可视化拖拉拽配置式操作即可快速构建出能同时在PC和移动端运行的各类管理系统,对于企业客户的信息系统在管理模式、业务流程、表单界面、数据可视化展示、IoT管控等个性化需求,可以通过设计器,快速的进行个性化配置。并支持企业微信,公众号,钉钉等移动集成,实现用户跨区域移动办公。从而构建企业个性化的行业应用、集成应用和复杂的业务报表。
Stars: ✭ 76 (-93.92%)
Mutual labels:  map
React Usa Map
React component with all USA States with customizable options. No D3 needed.
Stars: ✭ 63 (-94.96%)
Mutual labels:  map
Dyno
Package dyno is a utility to work with dynamic objects at ease.
Stars: ✭ 81 (-93.52%)
Mutual labels:  map
Itiriri Async
A library for asynchronous iteration.
Stars: ✭ 78 (-93.76%)
Mutual labels:  map
Vector Analog Clock
A Simple Customizable VectorAnalogClock Android View
Stars: ✭ 73 (-94.16%)
Mutual labels:  android-view
Unity Plane Mesh Splitter
Unity Plane Mesh Splitter
Stars: ✭ 71 (-94.32%)
Mutual labels:  map
Leaflet Ng2
Angular.io integration of Leaflet
Stars: ✭ 66 (-94.72%)
Mutual labels:  map
Hms Mapkit Demo
HMS Map Kit demo provides an example of intergrating HMS Map Android SDK. Personalizing how your map displays and interacts with your users tailors their experience to them
Stars: ✭ 76 (-93.92%)
Mutual labels:  map
Callbag Map Promise
Callbag map promise
Stars: ✭ 64 (-94.88%)
Mutual labels:  map
Bob74 ipl
Topic on FiveM Forums:
Stars: ✭ 80 (-93.6%)
Mutual labels:  map
Mpk Ttss
Improved www.ttss.krakow.pl
Stars: ✭ 63 (-94.96%)
Mutual labels:  map
Exploretrees Sg
🌳 Explore Trees in Singapore 🇸🇬
Stars: ✭ 68 (-94.56%)
Mutual labels:  map
Arcpointer
Arc pointer - simple customized progress bar in the form of an arch
Stars: ✭ 75 (-94%)
Mutual labels:  android-view
Pulsator
Pulse animation for iOS
Stars: ✭ 1,238 (-0.96%)
Mutual labels:  map
Quizzity
A fast-paced geography quiz
Stars: ✭ 80 (-93.6%)
Mutual labels:  map

区域热力地图 ChinaMapView

ChinaMapView:这是一个可拖拽,可点击,可手势放大的自定义中国地图组件,使用简单,具备一个自定义View应有的基本素质

  • 原理 :画地图用path,缩放拖拽用Matrix,判断点击位置用Region,判断滑动和缩放过程中的Map边界用Matrix.mapRect
  • 功能
    • 1、可随手势拖动,到边界抵消相应方向的滑动,且只有down的点在map内才可以拖动。
    • 2、可随缩放手势放大缩小,放大缩小的手势不做任何限制,只要在View内即可。
    • 3、点击某个省份回调该Select事件,传递出省份名字
    • 4、提供了刷新入口(Data改变刷新)
  • 基本素质
    • 1、旋转屏幕状态不丢失,转之前啥样,回来还是啥样(处理好onSaveInstanceState和onRestoreInstanceState)
    • 2、暴露事件冲突接口,允许外界操作父控件的事件及该view自己的事件(因为这只是个View,没办法直接处理所有的滑动冲突场景)
    • 3、内存抖动要小,防止内存溢出。

示例(真机还比较流畅,压缩的GIF丢帧严重)

Demo演示了普通用法和涉及到SwipeRefreshLayout+AppBarLayout等类似的滑动冲突的用法(细节请看代码)。

  • 1、普通使用 :只有Down的点在map的范围内才可以响应拖拽事件,否则通知父控件拦截;缩放事件不做限制。
  • 2、下拉刷新及其他滑动冲突
    • 1、拖拽事件:Down的点在map内,通过onPromiseParentTouchListener方法中使用SwipeRefreshLayout.setEnabled(promise)通知外界设置SwipeRefreshLayout不可以滑动。
    • 2、缩放事件:在MyScaleGestureDetector的onScaleBegin方法中通过onPromiseParentTouchListener方法中使用SwipeRefreshLayout.setEnabled(promise)通知外界设置SwipeRefreshLayout不可以滑动。
    • 3、在SwipeRefreshLayout的OnRefreshListener中设置ChinaMapView的setEnableTouch(false)方法通知刷新期间,ChinaMapView不响应任何事件。
    • 4、同理,监听AppBarLayout的滚动高度来控制只有完全展开才允许SwipeRefreshLayout下拉刷新和ChinaMapView的事件响应,否则都禁止
常规使用 下拉刷新及其他滑动冲突
normal fix
展示省份名字(1.0.2新增支持) 只允许点击,不允许缩放和拖动(1.0.4新增支持)
name fix

开始使用

基本API

所有的省份、自治区、直辖市

安徽,北京,重庆,福建,广东,甘肃,广西,贵州,海南,河北,河南,香港,黑龙江,湖南,湖北,吉林,江苏,江西,辽宁,澳门,内蒙古,宁夏,青海,陕西,四川,山东,上海市,山西,天津,台湾,新疆,西藏,云南,浙江

Data实例类 ChinaMapModel,通过ChinaMapView.getChinaMapModel()获得,以下为使用期间会接触到的属性,别的属性都是为绘制准备的,不用关心,也不用去设置。

属性(均包含set、get方法) 类型 作用
provinceslist List 包含所有的省份model
isShowName boolean 设置是否展示省份名字

Data实例类 ProvinceModel,通过chinaMapModel.getProvinceslist()获得,以下为使用期间会接触到的属性,别的属性都是为绘制准备的,不用关心,也不用去设置。

属性(均包含set、get方法) 类型 作用
color int 省份填充的颜色
normalBorderColor int 省份未选中状态下的边框颜色
selectBorderColor int 省份未选中状态下的边框颜色
nameColor int 省份名字颜色,每个省份名字的颜色可以不一致

ChinaMapView

方法 参数 作用
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'
}

布局XML中添加

布局XML中添加与系统View使用方式一样,宽高如果只确定其一,另一个根据parent的宽高和map的比例取最小值确定。最终map的宽度和高度由padding决定

<com.wxy.chinamapview.view.ChinaMapView
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:id="@+id/map"></com.wxy.chinamapview.view.ChinaMapView>

代码中修改Data和View属性

代码中通过ChinaMapView的getChinaMapModel()方法拿到ChinaMapModel,通过修改ChinaMapModel的属性来刷新ChinaMapView的显示效果,其他的缩放倍数和接口通过ChinaMapView直接设置,Demo中的SwipRefreshAppbarActivity和NormalActivity中有详细使用代码

拿到ChinaMapModel
chinaMapModel = map.getChinaMapModel();
设置缩放的最大最小值
map.setScaleMin(1);
      map.setScaleMax(3);
修改省份颜色,这里所有省份都处理成一样了,实际场景可给省份设置不同的颜色,修改完后map.notifyDataChanged()刷新View
for (ProvinceModel provinceModel:chinaMapModel.getProvinceslist()){
                                  provinceModel.setColor(color);
                              }
                              map.notifyDataChanged();
修改省份未选中状态下边框颜色,这里所有省份都处理成一样了,实际场景可给省份设置不同的颜色,修改完后map.notifyDataChanged()刷新View
for (ProvinceModel provinceModel:chinaMapModel.getProvinceslist()){
                                  provinceModel.setNormalBordercolor(color);
                              }
                              map.notifyDataChanged();
修改省份选中状态下边框颜色,这里所有省份都处理成一样了,实际场景可给省份设置不同的颜色,修改完后map.notifyDataChanged()刷新View
for (ProvinceModel provinceModel:chinaMapModel.getProvinceslist()){
                                    provinceModel.setSelectBordercolor(color);
                                }
                                map.notifyDataChanged();
修改省份名字的颜色,这里所有省份都处理成一样了,实际场景可给省份设置不同的颜色,修改完后map.notifyDataChanged()刷新View
for (ProvinceModel provinceModel:chinaMapModel.getProvincesList()){
                                    provinceModel.setNameColor(color);
                                }
                                map.notifyDataChanged();
设置省份点击事件,这里传递的是省份或者直辖市或者自治区的名字(上方有全部的name)
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);
            }

        });
修改完chinamapmodel的数据后,刷新数据用chinamapView.notifyDataChanged(),且刷新期间禁止chinamapView响应事件chinamapView.setEnableTouch(true);;
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);
            }
        });

反馈与建议

License

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].