• overlayItems 全部显示


    如果有时间加了很多overlayItem,由于缩放问题 有些不能显示为了全部显示

    Java代码 复制代码 收藏代码
    1. public void centerOverlays() {    
    2.     int minLat = 81 * MapStoresController.MAP_SCALE;    
    3.     int maxLat = -81 * MapStoresController.MAP_SCALE;    
    4.     int minLon = 181 * MapStoresController.MAP_SCALE;    
    5.     int maxLon = -181 * MapStoresController.MAP_SCALE;    
    6.     
    7.     for (int i = 0; i < overlayItems.size(); i++) {    
    8.         Store s = overlayItems.getItem(i).getStore();    
    9.         minLat = (int) ((minLat > (s.getLocation().getLatitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLatitude() * MapStoresController.MAP_SCALE :    minLat);    
    10.         maxLat = (int) ((maxLat < (s.getLocation().getLatitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLatitude() * MapStoresController.MAP_SCALE : maxLat);    
    11.         minLon = (int) ((minLon > (s.getLocation().getLongitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLongitude() * MapStoresController.MAP_SCALE : minLon);    
    12.         maxLon = (int) ((maxLon < (s.getLocation().getLongitude() * MapStoresController.MAP_SCALE)) ? .getLocation().getLongitude() * MapStoresController.MAP_SCALE : maxLon);    
    13.     }    
    14.     
    15.     GeoPoint gp = controller.getUserLocation();    
    16.     
    17.     minLat = (minLat > gp.getLatitudeE6()) ? gp.getLatitudeE6() : minLat;    
    18.     maxLat = (maxLat < gp.getLatitudeE6()) ? gp.getLatitudeE6() : maxLat;    
    19.     minLon = (minLon > gp.getLongitudeE6()) ? gp.getLongitudeE6() : minLon;    
    20.     maxLon = (maxLon < gp.getLongitudeE6()) ? gp.getLongitudeE6() : maxLon;    
    21.     
    22.     mapView.getController().zoomToSpan((maxLat - minLat), (maxLon - minLon));    
    23.     mapView.getController().animateTo(new GeoPoint((maxLat + minLat) / 2, (maxLon + minLon) / 2));    
    24. }   
    public void centerOverlays() { 
        int minLat = 81 * MapStoresController.MAP_SCALE; 
        int maxLat = -81 * MapStoresController.MAP_SCALE; 
        int minLon = 181 * MapStoresController.MAP_SCALE; 
        int maxLon = -181 * MapStoresController.MAP_SCALE; 
     
        for (int i = 0; i < overlayItems.size(); i++) { 
            Store s = overlayItems.getItem(i).getStore(); 
            minLat = (int) ((minLat > (s.getLocation().getLatitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLatitude() * MapStoresController.MAP_SCALE :    minLat); 
            maxLat = (int) ((maxLat < (s.getLocation().getLatitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLatitude() * MapStoresController.MAP_SCALE : maxLat); 
            minLon = (int) ((minLon > (s.getLocation().getLongitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLongitude() * MapStoresController.MAP_SCALE : minLon); 
            maxLon = (int) ((maxLon < (s.getLocation().getLongitude() * MapStoresController.MAP_SCALE)) ? .getLocation().getLongitude() * MapStoresController.MAP_SCALE : maxLon); 
        } 
     
        GeoPoint gp = controller.getUserLocation(); 
     
        minLat = (minLat > gp.getLatitudeE6()) ? gp.getLatitudeE6() : minLat; 
        maxLat = (maxLat < gp.getLatitudeE6()) ? gp.getLatitudeE6() : maxLat; 
        minLon = (minLon > gp.getLongitudeE6()) ? gp.getLongitudeE6() : minLon; 
        maxLon = (maxLon < gp.getLongitudeE6()) ? gp.getLongitudeE6() : maxLon; 
     
        mapView.getController().zoomToSpan((maxLat - minLat), (maxLon - minLon)); 
        mapView.getController().animateTo(new GeoPoint((maxLat + minLat) / 2, (maxLon + minLon) / 2)); 
    } 
    

    2.

    Java代码 复制代码 收藏代码
    1. /**  
    2.  * Fits the map with the passed in points so all points are visible.  
    3.  * @param mapController MapView controller  
    4.  * @param points list of points you want the map to contain  
    5.  */  
    6. private static void fitPoints(MapController mapController, List points) {   
    7.     // set min and max for two points   
    8.     int nwLat = -90 * 1000000;   
    9.     int nwLng = 180 * 1000000;   
    10.     int seLat = 90 * 1000000;   
    11.     int seLng = -180 * 1000000;   
    12.     // find bounding lats and lngs   
    13.     for (GeoPoint point : points) {   
    14.     nwLat = Math.max(nwLat, point.getLatitudeE6());    
    15.     nwLng = Math.min(nwLng, point.getLongitudeE6());   
    16.     seLat = Math.min(seLat, point.getLatitudeE6());   
    17.         seLng = Math.max(seLng, point.getLongitudeE6());   
    18.     }   
    19.     GeoPoint center = new GeoPoint((nwLat + seLat) / 2, (nwLng + seLng) / 2);   
    20.     // add padding in each direction   
    21.     int spanLatDelta = (int) (Math.abs(nwLat - seLat) * 1.1);   
    22.     int spanLngDelta = (int) (Math.abs(seLng - nwLng) * 1.1);   
    23.     
    24.     // fit map to points   
    25.     mapController.animateTo(center);   
    26.     mapController.zoomToSpan(spanLatDelta, spanLngDelta);   
    27. }  
  • 相关阅读:
    sql datepart ,dateadd,datediff,DateName函数
    DEV控件:gridControl常用属性设置
    师兄建议:
    .GRIDVIEW奇偶行变色
    C#中在主窗体中用ShowDialog方法显示子窗体的使用技巧
    Dev 控件lookUpEdit的数据绑定及其获取从UI界面赋给lookupedit的值
    从VS界面把图片导入数据库:①:把图片转换为二进制数据,②再把二进制数存进数据库
    YYKit之YYText
    分享使用method swizzling的经历
    autoreleasepool的笔记
  • 原文地址:https://www.cnblogs.com/luluping/p/2223286.html
Copyright © 2020-2023  润新知