Arcigis for android api 100.1加载google地图
来源:互联网 发布:网络教育统考查询 编辑:程序博客网 时间:2024/05/22 03:07
Arcgis 新的pi改动了许多,加载google地图的方式也改变了
package com.landac.yutu.landacquisition.map.googlemap;import android.app.Activity;import com.esri.arcgisruntime.arcgisservices.LevelOfDetail;import com.esri.arcgisruntime.arcgisservices.TileInfo;import com.esri.arcgisruntime.data.TileKey;import com.esri.arcgisruntime.geometry.Envelope;import com.esri.arcgisruntime.geometry.Point;import com.esri.arcgisruntime.geometry.SpatialReference;import com.esri.arcgisruntime.geometry.SpatialReferences;import com.esri.arcgisruntime.layers.ImageTiledLayer;import com.esri.arcgisruntime.layers.ServiceImageTiledLayer;import com.esri.arcgisruntime.security.UserCredential;import com.landac.yutu.landacquisition.utils.MyLog;import com.landac.yutu.landacquisition.utils.SreenUtil;import java.io.BufferedInputStream;import java.io.ByteArrayOutputStream;import java.net.HttpURLConnection;import java.net.URL;import java.util.ArrayList;import java.util.List;import java.util.Random;import java.util.concurrent.Executors;import java.util.concurrent.RejectedExecutionException;import static android.R.attr.level;/** * Created by xhg on 2017/9/20. */public class GoogleMapLayer extends ImageTiledLayer { // 枚举 public enum MapType { VECTOR, //矢量标注地图 IMAGE, //影像地图 ROAD //道路标注图层 } private static GoogleMapLayer googleMapLayer; private static TileInfo mTileInfo; private MapType mMapType; private Activity mactivity; public static double[] iScale = { 591657527.591555, 295828763.795777, 147914381.897889, 73957190.948944, 36978595.474472, 18489297.737236, 9244648.868618, 4622324.434309, 2311162.217155, 1155581.108577, 577790.554289, 288895.277144, 144447.638572, 72223.819286, 36111.909643, 18055.954822, 9027.977411, 4513.988705, 2256.994353, 1128.497176, }; public static double[] iRes = { 156543.033928, 78271.5169639999, 39135.7584820001, 19567.8792409999, 9783.93962049996, 4891.96981024998, 2445.98490512499, 1222.99245256249, 611.49622628138, 305.748113140558, 152.874056570411, 76.4370282850732, 38.2185141425366, 19.1092570712683, 9.55462853563415, 4.77731426794937, 2.38865713397468, 1.19432856685505, 0.597164283559817, 0.298582141647617, }; public GoogleMapLayer(MapType mapType,TileInfo tileInfo, Envelope fullExtent) { super(tileInfo, fullExtent); this.mMapType = mapType;// setBufferSize(BufferSize.MEDIUM); } public static GoogleMapLayer getInstance(MapType mapType,TileInfo tileInfo, Envelope fullExtent){ if (googleMapLayer==null){ googleMapLayer=new GoogleMapLayer(mapType,tileInfo,fullExtent); } return googleMapLayer; } private void initLayer() {// tile } @Override protected byte[] getTile(TileKey tileKey) { byte[] iResult = null; try { URL iURL = null; byte[] iBuffer = new byte[1024]; HttpURLConnection iHttpURLConnection = null; BufferedInputStream iBufferedInputStream = null; ByteArrayOutputStream iByteArrayOutputStream = null; iURL = new URL(this.getMapUrl(tileKey)); iHttpURLConnection = (HttpURLConnection) iURL.openConnection(); iHttpURLConnection.connect(); iBufferedInputStream = new BufferedInputStream(iHttpURLConnection.getInputStream()); iByteArrayOutputStream = new ByteArrayOutputStream(); while (true) { int iLength = iBufferedInputStream.read(iBuffer); if (iLength > 0) { iByteArrayOutputStream.write(iBuffer, 0, iLength); } else { break; } } iBufferedInputStream.close(); iHttpURLConnection.disconnect(); iResult = iByteArrayOutputStream.toByteArray(); } catch (Exception ex) { ex.printStackTrace(); } return iResult; } private String getMapUrl(TileKey tileKey) { String iResult = null; Random iRandom = null; int level=tileKey.getLevel(); int col=tileKey.getColumn(); int row=tileKey.getRow(); iResult = "http://mt"; iRandom = new Random(); iResult = iResult + iRandom.nextInt(4); switch (this.mMapType) { case VECTOR: iResult = iResult + ".google.cn/vt/lyrs=m@212000000&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s==Galil"; break; case IMAGE: iResult = iResult + ".google.cn/vt/lyrs=s@126&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s==Galil"; break; case ROAD: iResult = iResult + ".google.cn/vt/imgtp=png32&lyrs=h@212000000&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s==Galil"; break; default: return null; } return iResult; } @Override public TileInfo getTileInfo() { MyLog.i("getTileInfo"); return mTileInfo; } public static TileInfo buildTileInfo(Activity activity) {// Point iPoint = new Point(x,y,SpatialReference.create(102113)); Point iPoint = new Point(-20037508.342787,20037508.342787,SpatialReference.create(102113)); List<LevelOfDetail> levelOfDetails=new ArrayList<>(); for (int i=0;i<iRes.length;i++){ LevelOfDetail levelOfDetail=new LevelOfDetail(i,iRes[i],iScale[i]); levelOfDetails.add(levelOfDetail); } mTileInfo = new TileInfo(160, TileInfo.ImageFormat.UNKNOWN, levelOfDetails, iPoint, SpatialReference.create(102113), 256, 256); return mTileInfo; }// @Override// protected String getTileUrl(TileKey tileKey) {// String iResult = null;// Random iRandom = null;// int level=tileKey.getLevel();// int col=tileKey.getColumn();// int row=tileKey.getRow();// iResult = "http://mt";// iRandom = new Random();// iResult = iResult + col%4;// switch (this.mMapType) {// case VECTOR:// iResult = iResult + ".google.cn/vt/lyrs=m@212000000&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s==Galil";// break;// case IMAGE:// iResult = iResult + ".google.cn/vt/lyrs=s@126&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s==Galil";// break;// case ROAD:// iResult = iResult + ".google.cn/vt/imgtp=png32&lyrs=h@212000000&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s==Galil";// break;// default:// return null;// }// MyLog.i("url=="+iResult);// return iResult;// }//// @Override// public String getUri() {// MyLog.i("getUri");// return null;// }}
阅读全文
1 0
- Arcigis for android api 100.1加载google地图
- Google 地图 API for Android
- Google 地图 API for Android
- ArcGIS API for Silverlight 加载google地图
- arcgis api for js 加载google地图
- 成功使用ArcGIS API for iOS加载Google地图
- ArcGIS API for Silverlight加载google地图(后续篇)
- ArcGIS Api For Android学习之(二)加载地图
- 离线谷歌卫星地图加载服务中间件调用示例For Google API
- Google Maps API加载MBTiles离线地图
- ArcGIS API for Silverlight 使用google地图
- ArcGIS for Silverlight API google地图操作
- arcgis api for js 加载百度地图
- Google Maps API V2 for Android 上路一之配置地图
- android Google Map API V2(显示地图)
- android Google Map API V2(显示地图)
- Google Maps JavaScript API V3 根据地址 加载地图
- ArcGIS Api For Android学习之(二)加载地图续-加载sd卡中的切片数据
- Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupLis
- React Native
- 树状数组模板
- 04 模块 Prism For WPF
- Gartner发布2017年数据管理技术成熟度曲线
- Arcigis for android api 100.1加载google地图
- 使用JMeter 完成接口测试
- Displaying multiple records in one row
- “巴巴罗莎计划---我的崛起之路
- Git带你回到过去和未来【6】#匿名分支
- MiniUI 在线示例
- 【SQL】ORACLE更新多行数据,利用decode函数,对应关系,改数据
- 工作中使用率较高的命令:1.linux简单命令分享
- 关于LINQ与Lamba的说明