地图覆盖物(平面图、室内图)

来源:互联网 发布:小型电动粉碎机淘宝网 编辑:程序博客网 时间:2024/04/30 22:55

这里写代码片

public class MainActivity extends AppCompatActivity {    private DataAdapter adapter = new DataAdapter();    private Bitmap bmp;    List<PathUnit> unitList = new ArrayList<>();    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        InDoorView view = (InDoorView) findViewById(R.id.surface);        view.setAdapter(adapter);//初始化        http("http://i1.buimg.com/598337/5976cc13e9b48b93.jpg");    }    //图案列表    private void getUnitList() {        PathUnit unit = new PathUnit(getList());        unitList.add(unit);    }    //每个图案的坐标组合    private List<PointF> getList() {        List<PointF> pointList = new ArrayList<>();        pointList.add(new PointF(163,231));        pointList.add(new PointF(277,231));        pointList.add(new PointF(279,332));        pointList.add(new PointF(164,330));        return pointList;    }    private void http(final String url) {        String pdf = url;        String path = Environment.getExternalStorageDirectory().getPath() + File.separator;        RequestParams requestParams = new RequestParams(pdf);        requestParams.setSaveFilePath(path);        x.http().get(requestParams, new Callback.ProgressCallback<File>() {            @Override            public void onWaiting() {            }            @Override            public void onStarted() {            }            @Override            public void onLoading(long total, long current, boolean isDownloading) {                int pro = (int) (current * 100 / total);            }            @Override            public void onSuccess(final File result) {                File file = result;//                System.out.println(file.length());                BitmapFactory.Options opt = new BitmapFactory.Options();                opt.inPreferredConfig = Bitmap.Config.RGB_565;                final Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), opt); //将图片的长和宽缩小味原来的1/2//                final Bitmap bitmap=BitmapFactory.decodeFile(file.getAbsolutePath());                new Thread(new Runnable() {                    @Override                    public void run() {                        //背景图//                        BitmapFactory.Options opt = new BitmapFactory.Options();//                        opt.inPreferredConfig = Bitmap.Config.RGB_565;//                        bmp = BitmapFactory.decodeResource(getResources(), R.drawable.test, opt);//图片资源                        bmp = bitmap;                        System.out.println(bmp.getWidth());                        adapter.setBmp(bmp);//设置图片                        bmp = null;                        getUnitList();//设置数组                        adapter.setList(unitList);//设置数组                        adapter.refreshData();                        runOnUiThread(new Runnable() {                            @Override                            public void run() {                                findViewById(R.id.tip).setVisibility(View.GONE);                            }                        });                    }                }).start();            }            @Override            public void onError(Throwable ex, boolean isOnCallback) {            }            @Override            public void onCancelled(CancelledException cex) {            }            @Override            public void onFinished() {            }        });    }}
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.zhjy.assetslocation.MainActivity">    <com.zhjy.assetslocation.karonl.instance.InDoorView        android:id="@+id/surface"        android:layout_width="match_parent"        android:layout_height="match_parent" />    <TextView        android:visibility="gone"        android:id="@+id/frames"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:textSize="18sp"        android:textColor="@android:color/white"        android:background="@android:color/black"        android:text="FPS: 60" />    <TextView        android:id="@+id/tip"        android:layout_centerInParent="true"        android:textSize="20sp"        android:textColor="@android:color/white"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="加载地图数据.."/></RelativeLayout>

github地址
https://github.com/karonl/InDoorSurfaceView

也可以看看这个

https://github.com/dreamlivemeng/HotImg