Need help with ChinaMap?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

xchengx
130 Stars 44 Forks 7 Commits 3 Opened issues

Description

一个用Path画出来的中国地图

Services available

!
?

Need anything else?

Contributors list

# 356,335
Java
7 commits

ChinaMapView


一个用Path 绘制的中国省份地图


演示


使用

  • 布局文件中
    Xml
    
    
  • Java中

1.监听选中的省份

ChinaMapView lView = (ChinaMapView)findViewById(R.id.vp);
        lView.setOnProvinceSelectedListener(new ChinaMapView.OnProvinceSelectedListener() {
            @Override
            public void onprovinceSelected(ChinaMapView.Area pArea) {
                Toast.makeText(MainActivity.this,"您选择了-->"+pArea.name(),Toast.LENGTH_SHORT).show();
            }
        });

2.高亮某个省份

ChinaMapView lView = (ChinaMapView)findViewById(R.id.vp);
lView.setPaintColor(ChinaMapView.Area.SiChuan, Color.rgb(0x5c,0xad,0xad),true);

3.默认选中某个省份

ChinaMapView lView = (ChinaMapView)findViewById(R.id.vp);
lView.selectAProvince(ChinaMapView.Area.XinJiang);

4.移动

ChinaMapView lView = (ChinaMapView)findViewById(R.id.vp);
lView.up();//上
lView.down();//下
lView.left();//左
lView.right();//右
lView.restPosition();//复位

4.放大缩小

ChinaMapView lView = (ChinaMapView)findViewById(R.id.vp);
lView.zoomIn();//放大
lView.zoomOut();//缩小
lView.restScale();//原始大小

Tips: * 1.View会使用的时候重新计算大小,等比缩放View,用宽度来计算高度,建议layoutwidth使用matchparent * 2.View中没有对移动做边界处理 * 3.View中缩放没有指定缩放坐标,因此在缩放后会感觉跑偏

地图数据来源


SVG中国地图

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.