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

这里写代码片

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

魑魅魍魉9527

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值