Giter Club home page Giter Club logo

chinamap's Introduction

ChinaMapView


一个用Path 绘制的**省份地图


演示


##使用

  • 布局文件中
<com.uqi.path.ChinaMapView
        android:id="@+id/vp"
        android:background="#FFFF6F"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
  • 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,用宽度来计算高度,建议layout_width使用match_parent
  • 2.View中没有对移动做边界处理
  • 3.View中缩放没有指定缩放坐标,因此在缩放后会感觉跑偏

##地图数据来源

SVG**地图

chinamap's People

Contributors

xchengx avatar

Watchers

James Cloos avatar anrywang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.