zoukankan      html  css  js  c++  java
  • Android基于mAppWidget实现手绘地图(十六)–处理一次触摸多个地图对象

    最好的处理方式就是弹出一个对话框,将用户触摸过的控件罗列出来。你可以通过实现OnMapTouchListener来处理。

    参考以下代码,实现上述功能:

    mapWidget.setOnMapTouchListener(new OnMapTouchListener() {    
       public void onTouch(MapWidget map, MapTouchedEvent event) {
                   
           List objectTouchEvents = event.getTouchedObjectIds();
           
           // X coordinate of the touch in original image coordinates
           int mapX = event.getMapX();         
           // Y coordinate of the touch in original image coordinates
           int mapY = event.getMapY();  
           // X coordinate of the touch in screen coordinates
           int screenX = event.getScreenX();
           // Y coordinate of the touch in screen coordinates
           int screenY = event.getScreenY();
                   
           if (objectTouchEvents.size() == 1) {
               ObjectTouchEvent objectTouchEvent = objectTouchEvents.get(0);
                       
           // Id of the layer that the map object belongs to
               long layerId = objectTouchEvent.getLayerId();
           // Id of the map object that was touched.
               Object objectId = objectTouchEvent.getObjectId();
                       
           // Handle single object touch event here
           } else if (objectTouchEvents.size() > 1) {
                 List ids = new ArrayList();
                 // Getting id's of the touched objects
                 for (ObjectTouchEvent objectTouchEvent:objectTouchEvents){
                      // Id of the layer the object belongs to
                      long layerId = objectTouchEvent.getLayerId();
                      // Id of the object
                      Object objectId = objectTouchEvent.getObjectId();
                      ids.add(objectId);
                 }
                       
                 // Show dialog with the list of objects here using ids
           } else {
                 // Ignore touch event
           }
       }
    });
  • 相关阅读:
    Gulp使用入门操作---压缩JS
    Linux如何查看进程及如何杀死进程
    连不上GitHub,也ping不通,亲测解决方案
    idea一键生成mybatis工具
    idea逆向生成hibernate工程
    idea常用快捷键大全
    mysql日期函数
    数据库事务
    idea激活码
    oracle创建表前校验是否存在
  • 原文地址:https://www.cnblogs.com/Joanna-Yan/p/4730442.html
Copyright © 2011-2022 走看看