zoukankan      html  css  js  c++  java
  • 《ArcGIS Runtime SDK for Android开发笔记》——(13)、图层扩展方式加载Google地图

    1、前言

    http://mt2.google.cn/vt/lyrs=m@225000000&hl=zh-CN&gl=cn&x=420&y=193&z=9&s=Galil

    通过图层扩展类的方式加载Google地图的是我们通常获取Google地图的一种方式,根据这种方式我们可以通过拼接地图瓦片Url字符串获取瓦片数据,关于Google瓦片算法的解析网上有很多,以下仅列出博客地址,及具体实现类。

    Google瓦片地图算法解析 :http://blog.csdn.net/hugoandpig/article/details/7719307

    转载请注明出处:http://www.cnblogs.com/gis-luq/p/5443498.html 

    2、Google地图的自定义扩展类

    package com.seraph.collect.BaseComp.MapLayer;
    
    import java.util.Map;
    import java.util.concurrent.RejectedExecutionException;
    
    import android.util.Log;
    
    import com.esri.android.map.TiledServiceLayer;
    import com.esri.core.geometry.Envelope;
    import com.esri.core.geometry.Point;
    import com.esri.core.geometry.SpatialReference;
    
    /**
     *Google地图加载
     */
    public class GoogleMapLayer extends TiledServiceLayer {
    
        private int minLevel = 0;
        private int maxLevel = 19;
    
        private String[] subDomains = new String[] { "mt1", "mt2", "mt3" };
    
        private double[] scales = new double[] { 591657527.591555,
                295828763.79577702, 147914381.89788899, 73957190.948944002,
                36978595.474472001, 18489297.737236001, 9244648.8686180003,
                4622324.4343090001, 2311162.217155, 1155581.108577, 577790.554289,
                288895.277144, 144447.638572, 72223.819286, 36111.909643,
                18055.954822, 9027.9774109999998, 4513.9887049999998, 2256.994353,
                1128.4971760000001 };
        private double[] resolutions = new double[] { 156543.03392800014,
                78271.516963999937, 39135.758482000092, 19567.879240999919,
                9783.9396204999593, 4891.9698102499797, 2445.9849051249898,
                1222.9924525624949, 611.49622628138, 305.748113140558,
                152.874056570411, 76.4370282850732, 38.2185141425366,
                19.1092570712683, 9.55462853563415, 4.7773142679493699,
                2.3886571339746849, 1.1943285668550503, 0.59716428355981721,
                0.29858214164761665 };
    
        private Point origin = new Point(-20037508.342787, 20037508.342787);
    
        private int dpi = 96;
    
        private int tileWidth = 256;
        private int tileHeight = 256;
    
        public GoogleMapLayer() {
            super(true);
            this.init();
        }
    
        private void init() {
            try {
                getServiceExecutor().submit(new Runnable() {
                    public void run() {
                        GoogleMapLayer.this.initLayer();
                    }
                });
            } catch (RejectedExecutionException rejectedexecutionexception) {
                Log.e("Google Map Layer", "initialization of the layer failed.",
                        rejectedexecutionexception);
            }
        }
    
        protected byte[] getTile(int level, int col, int row) throws Exception {
            if (level > maxLevel || level < minLevel)
                return new byte[0];
            String subDomain = subDomains[(level + col + row) % subDomains.length];
        
         //构建待拼接字符串
         String _mapType = "m@225000000"; String url = "http://" + subDomain + ".google.cn/vt/lyrs=" + _mapType + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; Map<String, String> map = null; return com.esri.core.internal.io.handler.a.a(url, map); } protected void initLayer() { if (getID() == 0L) { nativeHandle = create(); changeStatus(com.esri.android.map.event.OnStatusChangedListener.STATUS .fromInt(-1000)); } else { this.setDefaultSpatialReference(SpatialReference.create(102113)); this.setFullExtent(new Envelope(-22041257.773878, -32673939.6727517, 22041257.773878, 20851350.0432886)); this.setTileInfo(new TileInfo(origin, scales, resolutions, scales.length, dpi, tileWidth, tileHeight)); super.initLayer(); } } }
  • 相关阅读:
    燕园笔记之一——穿梭
    openvc学习笔记(1)——简单应用
    匆匆过客
    opencv学习(3)——高斯平滑图像
    为什么(win10系统)电脑上面的鼠标(触摸板)突然用不了?怎么开启和关闭、
    SqlServer自动备份数据库
    CodeSmith批量生成实体类
    XML文件的序列化和反序列化
    AjaxPro的使用
    设计模式之——策略模式
  • 原文地址:https://www.cnblogs.com/gis-luq/p/5443498.html
Copyright © 2011-2022 走看看