zoukankan      html  css  js  c++  java
  • 【Android】ImageMap,图片地图

    https://github.com/CFutureTeam/android-image-map

    package com.*.imagemap;
    
    import *.imagemap.ImageMap;
    import *.imagemap.core.Bubble;
    import *.imagemap.core.CircleShape;
    import *.imagemap.core.Shape;
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.TextView;
    
    public class MainActivity extends Activity {
    
        private ImageMap map; // lib库里面自定义试图对象
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            map = (ImageMap) findViewById(R.id.imagemap);
            // 用资源文件创建一个bitmap,地图
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.imm_01, new BitmapFactory.Options());
            // 把图加载到ImageMap上面去
            map.setMapBitmap(bitmap);
            // 加载一个用来标注位置的视图view,这个view自己可以定义的
            View bubble = getLayoutInflater().inflate(R.layout.popup, null);
            // 把试图加进ImageMap
            map.setBubbleView(bubble, new Bubble.RenderDelegate() {
                @Override
                public void onDisplay(Shape shape, View bubbleView) {
                    ImageView logo = (ImageView) bubbleView.findViewById(R.id.logo); //
                    // 通过bubbleView得到相应的控件
                    TextView name = (TextView) bubbleView.findViewById(R.id.name);
                    name.setText("我的位置"); // 标注上面显示一个文本
                    logo.setImageResource(R.drawable.kfc_logo); // 图片
                }
            });
    
            // 该方法可以实现一个圆点,用于和bubble进行绑定,并且最终显示在地图上
            CircleShape black = new CircleShape("NO", Color.RED); // Color.BLUE,圆点的颜色
            double x = Math.random() * 100 + 100; // 随机x坐标,实际中,可以从服务器获取
            double y = Math.random() * 100 + 100; // 随机y坐标
            black.setValues(String.format("%.5f,%.5f,15", x, y)); // 设置圆点的位置和大小
            map.addShapeAndRefToBubble(black); // 加到地图上
    
            // 该方法可以实现一个圆点,用于和bubble进行绑定,并且最终显示在地图上
            CircleShape black2 = new CircleShape("NO2", Color.BLUE); // Color.BLUE,圆点的颜色
            double x1 = Math.random() * 300 + 100; // 随机x坐标,实际中,可以从服务器获取
            double y1 = Math.random() * 300 + 100; // 随机y坐标
            black2.setValues(String.format("%.5f,%.5f,15", x1, y1)); // 设置圆点的位置和大小
            map.addShape(black2); // 加到地图上
    
            // 该方法可以实现一个圆点,用于和bubble进行绑定,并且最终显示在地图上
            CircleShape black3 = new CircleShape("NO3", Color.YELLOW); // Color.BLUE,圆点的颜色
            double x2 = Math.random() * 500 + 100; // 随机x坐标,实际中,可以从服务器获取
            double y2 = Math.random() * 500 + 100; // 随机y坐标
            black3.setValues(String.format("%.5f,%.5f,15", x2, y2)); // 设置圆点的位置和大小
            map.addShape(black3); // 加到地图上
    
        }
    
    }
  • 相关阅读:
    Anders Hejlsberg 和 Erich Gamma
    node-webkit
    用户密码加密存储十问十答,一文说透密码安全存储
    Spring Security-- 验证码功能的实现
    BigDecimal 专题
    基于微信开发 专题
    unwrapThrowable
    Android PullToRefreshExpandableListView的点击事件
    Android The content of the adapter has changed but ListView did not receive a notification
    Android入门:广播发送者与广播接收者
  • 原文地址:https://www.cnblogs.com/niray/p/4366581.html
Copyright © 2011-2022 走看看